Skip to content

Commit e9268e4

Browse files
fixed undefined pen id
1 parent 1cb132f commit e9268e4

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

app.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pens,geojson,data/Farm AL_8.29.25.geojson,id,,,id," {
4141
]
4242
}
4343
]}"
44-
movement,csv,data/Farm AL Centroid Data Cleaned 9.9.25.csv,ID,,DATE,," {
44+
movement,csv,data/FarmAL.dataraw_subset.csv,ID,,DATE,," {
4545
""renderer"": {
4646
""type"": ""simple"",
4747
""symbol"": {

js/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ function setup_interface(_event_settings){
196196
if(obj.end){
197197
obj.end= obj.end.trim()
198198
}
199-
record_manager.populate_days(event_data[obj.label],obj.start.trim(),obj.end,end_date)
199+
if(obj.start!=null){
200+
record_manager.populate_days(event_data[obj.label],obj.start.trim(),obj.end,end_date)
201+
}
200202

201203
}
202204
load_data("images/cow.svg","",populate_legend)
@@ -216,7 +218,7 @@ function setup_interface(_event_settings){
216218

217219
}
218220
//
219-
console.log(event_data)
221+
//console.log(event_data)
220222

221223
}else{
222224
record_manager.search_by_date(moment.unix($("#filter_date .filter_slider_box").slider("values")[0]).utc())

js/record_manager.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,13 @@ class Record_Manager {
135135
}
136136
}
137137
}
138+
138139
//artificially populate the CURRENT PEN value - we want to know where the cow moved from
139140
if($("#CURRENT_PEN").val()==0){
140141
console.log("Artificially populate the CURRENT PEN")
141-
for(var i=1;i<this.json_data.length;i++){
142+
for(var i=0;i<this.json_data.length;i++){
142143
// populate the "CURRENT PEN" value with the previous record matching the cow id
143-
for(var j=i-1;j>0;j--){
144+
for(var j=i-1;j>=0;j--){
144145
if(this.json_data[i]["ID"]==this.json_data[j]["ID"]){
145146
this.json_data[i]["CURRENT PEN"]= this.json_data[j]["TO PEN"]
146147
break
@@ -319,7 +320,7 @@ class Record_Manager {
319320
for(var j=i+1;j<this.json_data.length;j++){
320321
var c = this.json_data[j] // create a reference to the current pen (c) record
321322
// where the ids match and the to (t) pen matches the current (c) pan
322-
if(t["ID"] == c["ID"] && t["TO PEN"] == c["CURRENT PEN"]){
323+
if(t["ID"] == c["ID"] ){//&& t["TO PEN"] == c["CURRENT PEN"]
323324
// for clarity add an "IN PEN"
324325
t["IN PEN"]=t["TO PEN"]
325326
// clean up the data by using 'start' and 'end' as date objects

0 commit comments

Comments
 (0)