· 5 years ago · Mar 29, 2020, 10:29 PM
1
2var im_arr_nsensor_overlay = [];
3var im_arr_misat_overlay = [];
4var im_arr_misat_fieldView_img_overlay = [];
5var im_arr_rtk_overlay = [];
6var im_arr_uav_overlay = [];
7var im_arr_migrass_overlay = [];
8var im_arr_rgb_overlay = [];
9var im_arr_yield_overlay = [];
10var im_arr_cigreen_overlay = [];
11var im_arr_cigreen_fieldView_img_overlay = [];
12var im_arr_cvi_overlay = [];
13var im_arr_cvi_fieldView_img_overlay = [];
14var im_polygon_overlay = [];
15var im_arr_conductivity_overlay = [];
16var im_polygon_overlay_temp_customer_overlay = [];
17var im_arr_misat_variety_view_img_overlay = [];
18var im_arr_cigreen_variety_view_img_overlay = [];
19var im_nsensor_url = "https://api.mi.farm/static/images/nsensor/";
20var im_misat_url = "https://api.mi.farm/static/images/ndvi_v2/";
21var im_uav_url = "https://api.mi.farm/static/images/uav/";
22var im_migrass_url = "https://api.mi.farm/static/images/migrass_v2/";
23var im_conductivity_url = "https://api.mi.farm/static/images/conductivity/";
24var im_rgb_url = "https://api.mi.farm/static/images/rgb_v2/";
25var im_yield_url = "https://api.mi.farm/static/images/yield/";
26var im_cdax_img_url = "https://api.mi.farm/static/images/cdax/";
27const im_cigreen_url = "https://api.mi.farm/static/images/cigreen_v2/";
28var im_cvi_url = "https://api.mi.farm/static/images/cvi/";
29var im_bImgTypeDatesAjax_loading = false;
30var im_bAjax_loading = false;
31var im_bMapDataLoaded = false;
32var im_arr_n_sensor_NAS_dates = [];
33var im_arr_n_sensor_BI_dates = [];
34var im_arr_n_sensor_N_dates = [];
35
36var im_arr_ndmi_dates = [];
37var im_arr_ndmi_dates_NoCloudCover = [];
38var im_arr_ndmi_dates_HasCloud = [];
39var im_arr_ndmi_dates_PartialCloudCover = [];
40var im_arr_fvat_dates = [];
41var im_arr_fvat_dates_NoCloudCover = [];
42var im_arr_fvat_dates_PartialCloudCover = [];
43var im_arr_fvat_dates_HasCloud = [];
44var im_arr_rgb_dates = [];
45var im_arr_rgb_dates_NoCloudCover = [];
46var im_arr_rgb_dates_PartialCloudCover = [];
47var im_arr_rgb_dates_HasCloud = [];
48
49var im_arr_cigreen_dates = [];
50var im_arr_cigreen_dates_NoCloudCover = [];
51var im_arr_cigreen_dates_PartialCloudCover = [];
52var im_arr_cigreen_dates_HasCloud = [];
53
54var im_arr_cvi_dates = [];
55var im_arr_cvi_dates_NoCloudCover = [];
56var im_arr_cvi_dates_PartialCloudCover = [];
57var im_arr_cvi_dates_HasCloud = [];
58
59var lyr_selectedLock = "";
60//afbi
61var im_arr_afbi_cdax_img_overlay = [];
62
63var tmp_img_lyr_misat_current_day = "";
64var tmp_img_lyr_misat_current_month = "";
65var tmp_img_lyr_misat_current_yr = "";
66
67var tmp_img_lyr_cigreen_current_day = "";
68var tmp_img_lyr_cigreen_current_month = "";
69var tmp_img_lyr_cigreen_current_yr = "";
70
71var tmp_img_lyr_cvi_current_day = "";
72var tmp_img_lyr_cvi_current_month = "";
73var tmp_img_lyr_cvi_current_yr = "";
74
75var tmp_img_lyr_variety_current_day = "";
76var tmp_img_lyr_variety_current_month = "";
77var tmp_img_lyr_variety_current_yr = "";
78
79var misat_sub_season_end_date_txt = "";
80
81$(".fvat_subscription_link").click(function () {
82 $("#favtSubscription").modal({ backdrop: 'static', keyboard: false });
83 $("#favtSubscription .modal-dialog").attr("style", "width:90%;");
84 $("#fvatInfo").hide();
85
86 //insert date expiry text
87 if (misat_sub_season_end_date_txt != "") {
88 $("#fvat_subscription_date_exp").empty().text("This subscription will end on " + misat_sub_season_end_date_txt + " which is the end of your current season.");
89 }
90
91 $(".fvat_terms_cond").prop('checked', false);
92
93 if ($("#fvatSubscriptionServiceFarmsList option").length == 1) {
94 //hide farm list;
95 $("#fvatSubscriptionServiceFarmsList").hide();
96 $("#fvatSubscriptionServiceFarmsList").prev("label").hide();
97 }
98 else {
99 $("#fvatSubscriptionServiceFarmsList").show();
100 $("#fvatSubscriptionServiceFarmsList").prev("label").show();
101 }
102});
103
104$("#fvatSubscriptionServiceSubmit").click(function () {
105 $("#fvatInfo").hide();
106 if (!$(".fvat_terms_cond").is(":checked")) {
107 $("#fvatErrInfo").empty().text("Please tick the terms and conditions checkbox.").show();
108 }
109 else {
110 $("#fvatErrInfo").empty().hide();
111 //submit subscription
112
113 if ($("#fVATServices").find(":selected").val() != "0") {
114 $.ajax({
115 type: "POST",
116 url: urlPrepend + "/layerdata/favtsubscription/",
117 data: { service: $("#fVATServices").find(":selected").text(), serviceId: $("#fVATServices").find(":selected").val(), farmId: $("#fvatSubscriptionServiceFarmsList").find(":selected").val(), seasonId: $("#customerSeason").find(":selected").val() }
118 }).done(function (data) {
119 if (data == "3") {
120 displayErrMsg("Your subscription was not successful. Please try again.");
121 $("#favtSubscription").modal("hide");
122 }
123 else if(data == "1") {
124 displaySuccessMsg("Your subscription was successful.");
125 $("#favtSubscription").modal("hide");
126 }
127 else {
128 //subscripton already exists
129 $("#fvatInfo").show();
130 }
131
132 });
133 }
134 else {
135 $("#fvatErrInfo").empty().text("Please select a service.").show();
136 }
137 }
138
139 //deselect from left hand panel.
140 $(".fvat_subscription_link").removeClass("form_item_selected");
141});
142
143//set t&c link
144$(".favt_terms_cond_lnk").click(function () {
145 window.open("https://portal.precisiondecisions.co.uk/termsandconditions.aspx");
146
147 $(".fvat_terms_cond").prop('checked', true);
148})
149
150$(document).on("click", "#fvatSubscription_close_modal", function () {
151 $("#favtSubscription").modal('hide');
152});
153
154
155function img_displayImageOverLaySubType(date, layerMode, layerSubMode, arr) {
156
157 debugger;
158 var newDateFormat = date.replace(/-/g, '/');
159 var layerSubModeName = "";
160
161 if (layerMode == 1) {
162 layerSubModeName = "NAS";
163 if (layerSubMode == 6) {
164 layerSubModeName = "BI";
165 }
166 if (layerSubMode == 5) {
167 layerSubModeName = "N";
168 }
169 }
170
171 if (layerMode == 6) {
172 layerSubModeName = "EM Difference";
173 if (layerSubMode == 8) {
174 layerSubModeName = "EM Shallow";
175 }
176 if (layerSubMode == 7) {
177 layerSubModeName = "EM Deep";
178 }
179 }
180
181
182 //empty legend container
183 $(".imagery_layer_legend").empty();
184 img_clearOverlay();
185
186 if (!loadLocalMapLayerImgData(layerMode, newDateFormat + " - " + layerSubModeName + "|" + layerSubMode)) {
187 debugger;
188 im_getOverlayByDate(newDateFormat + " - " + layerSubModeName, layerMode, layerSubMode);
189 }
190 else {
191 debugger;
192 processImagerySubTypeObjectArrays(arr, newDateFormat, layerMode, layerSubModeName + "|" + layerSubMode);
193
194 }
195}
196
197
198function img_displayImageOverLay(date, layerMode, arr) {
199 debugger;
200 var newDateFormat = date.replace(/-/g, '/')
201 //empty legend container
202 $(".imagery_layer_legend").empty();
203 img_clearOverlay();
204
205 if (!loadLocalMapLayerImgData(layerMode, newDateFormat)) {
206
207 im_getOverlayByDate(newDateFormat, layerMode, 0);
208 }
209 else {
210
211 im_loadSubTypeStatus(layerMode, date);
212 processImageryObjectArrays(arr, newDateFormat, layerMode);
213 }
214}
215
216function refeshBISensorCal() {
217 debugger;
218 //refresh calendar
219 $(".n_sensor_cal").datepicker("destroy");
220 $(".n_sensor_cal").datepicker({
221 beforeShowDay: function (date) {
222 return (im_arr_n_sensor_BI_dates.indexOf(date.toISOString()) > -1) ? [true, "n_sensor_calendar_date_BI"] : [false, ""];
223 },
224 dateFormat: "dd-mm-yy",
225 defaultDate: new Date(im_arr_n_sensor_BI_dates[0]),
226 minDate: new Date(im_arr_n_sensor_BI_dates[im_arr_n_sensor_BI_dates.length - 1]),
227 onSelect: function (data) {
228 img_displayImageOverLaySubType(data, 1, 6, im_arr_nsensor_overlay);
229 displaySelectedCalDate(data, 1);
230 },
231 maxDate: '0'
232 });
233
234 if ($('.n_sensor_cal > .layer-calendar-skip-months').length === 0) {
235 $(".n_sensor_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>");
236 $('.layer-calendar-skip-months:visible').fadeOut(5000);
237 }
238}
239
240function refeshNSensorCal() {
241 //refresh calendar
242 $(".n_sensor_cal").datepicker("destroy");
243 $(".n_sensor_cal").datepicker({
244 beforeShowDay: function (date) {
245 return (im_arr_n_sensor_N_dates.indexOf(date.toISOString()) > -1) ? [true, "n_sensor_calendar_date_N"] : [false, ""];
246 },
247 dateFormat: "dd-mm-yy",
248 defaultDate: new Date(im_arr_n_sensor_N_dates[0]),
249 minDate: new Date(im_arr_n_sensor_N_dates[im_arr_n_sensor_N_dates.length - 1]),
250 onSelect: function (data) {
251 img_displayImageOverLaySubType(data, 1, 4, im_arr_nsensor_overlay);
252 displaySelectedCalDate(data, 1);
253 },
254 maxDate:'0'
255 });
256
257 if ($('.n_sensor_cal > .layer-calendar-skip-months').length === 0) {
258 $(".n_sensor_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
259 $('.layer-calendar-skip-months:visible').fadeOut(5000);
260 }
261}
262
263function refeshNASSensorCal() {
264 //refresh calendar
265 $(".n_sensor_cal").datepicker("destroy");
266 $(".n_sensor_cal").datepicker({
267 beforeShowDay: function (date) {
268 return (im_arr_n_sensor_NAS_dates.indexOf(date.toISOString()) > -1) ? [true, "n_sensor_calendar_date_NAS"] : [false, ""];
269 },
270 dateFormat: "dd-mm-yy",
271 defaultDate: new Date(im_arr_n_sensor_NAS_dates[0]),
272 minDate: new Date(im_arr_n_sensor_NAS_dates[im_arr_n_sensor_NAS_dates.length - 1]),
273 onSelect: function (data) {
274 debugger;
275 img_displayImageOverLaySubType(data, 1, 4, im_arr_nsensor_overlay);
276 displaySelectedCalDate(data, 1);
277 },
278 maxDate: '0'
279 });
280
281 if ($('.n_sensor_cal > .layer-calendar-skip-months').length === 0) {
282 $(".n_sensor_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
283 $('.layer-calendar-skip-months:visible').fadeOut(5000);
284 }
285}
286
287function refreshRTKCal() {
288 //refresh calendar
289 $(".conductivity_cal").datepicker("destroy");
290 $(".conductivity_cal").datepicker({
291 beforeShowDay: function (date) {
292 return (im_arr_conductivity_Diff_dates.indexOf(date.toISOString()) > -1) ? [true, "conductivity_calendar_date_Diff"] : [false, ""];
293 },
294 dateFormat: "dd-mm-yy",
295 defaultDate: new Date(im_arr_conductivity_Diff_dates[0]),
296 onSelect: function (data) {
297 img_displayImageOverLaySubType(data, 6, 9, im_arr_conductivity_overlay);
298 displaySelectedCalDate(data, 6);
299 },
300 maxDate: '0'
301 });
302}
303
304function refreshMigrassCal() {
305 //refresh calendar
306 $(".migrass_cal").datepicker("destroy");
307 $(".migrass_cal").datepicker({
308 beforeShowDay: function (date) {
309 return (im_arr_ndmi_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_ndmi_dates_NoCloudCover, im_arr_ndmi_dates_HasCloud, im_arr_ndmi_dates_PartialCloudCover)] : [false, ""];
310 },
311 dateFormat: "dd-mm-yy",
312 defaultDate: new Date(im_arr_ndmi_dates[0]),
313 minDate: new Date(im_arr_ndmi_dates[im_arr_ndmi_dates.length - 1]),
314 onSelect: function (data) {
315 img_displayImageOverLay(data, 7, im_arr_migrass_overlay);
316 displaySelectedCalDate(data, 7);
317 },
318 maxDate: '0'
319 });
320
321 if ($('.migrass_cal > .layer-calendar-skip-months').length === 0) {
322 $(".migrass_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
323 $('.layer-calendar-skip-months:visible').fadeOut(5000);
324 }
325
326}
327
328function refreshMisatCal() {
329
330
331 //refresh calendar
332 $(".misat_cal").datepicker("destroy");
333 $(".misat_cal").datepicker({
334 beforeShowDay: function (date) {
335 return (im_arr_fvat_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_fvat_dates_NoCloudCover, im_arr_fvat_dates_HasCloud, im_arr_fvat_dates_PartialCloudCover)] : [false, ""];
336 },
337 dateFormat: "dd-mm-yy",
338 defaultDate: new Date(im_arr_fvat_dates[0]),
339 minDate: new Date(im_arr_fvat_dates[im_arr_fvat_dates.length - 1]),
340 onSelect: function (data) {
341 img_displayImageOverLay(data, 2, im_arr_misat_overlay);
342 displaySelectedCalDate(data, 2);
343 },
344 maxDate: '0'
345 });
346
347 if ($('.misat_cal > .layer-calendar-skip-months').length === 0) {
348 $(".misat_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
349 $('.layer-calendar-skip-months:visible').fadeOut(5000);
350 }
351
352}
353
354function refreshCIgreenCal() {
355 debugger;
356 $('.lyr_lock').show();
357 if ($('.misat_cal_options_wrapper').children().length) {
358 refreshMisatCal();
359 } else if ($('.cigreen_cal_options_wrapper').children().length) {
360
361 $('.satSelectIcons').removeClass('hoveredIcon selectedIcon');
362 $('#ci_green_icon').addClass('selectedIcon');
363
364 $('#satelliteTypeName').text('CI Green');
365
366 $(".cigreen_date_selected").empty();
367 var setDefaultDate = new Date(im_arr_cigreen_dates[0]);
368 if ((tmp_img_lyr_cigreen_current_month != "") && (tmp_img_lyr_cigreen_current_yr != "")) {
369 //user has browsed misat calendar months
370 setDefaultDate = (new Date(tmp_img_lyr_cigreen_current_month + '/01/' + tmp_img_lyr_cigreen_current_yr)).toISOString()
371 }
372
373
374 $(".cigreen_cal").datepicker({
375 beforeShowDay: function (date) {
376 return (im_arr_cigreen_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_cigreen_dates_NoCloudCover, im_arr_cigreen_dates_HasCloud, im_arr_cigreen_dates_PartialCloudCover)] : [false, ""];
377 },
378 dateFormat: "dd-mm-yy",
379 defaultDate: new Date(setDefaultDate),
380 minDate: new Date(im_arr_cigreen_dates[im_arr_cigreen_dates.length - 1]),
381 onSelect: function (data) {
382 debugger;
383 img_displayImageOverLay(data, 17, im_arr_cigreen_overlay);
384 displaySelectedCalDate(data, 17);
385 tmp_img_lyr_cigreen_current_day = data.split('-')[0];
386 tmp_img_lyr_cigreen_current_month = data.split('-')[1];
387 tmp_img_lyr_cigreen_current_yr = data.split('-')[2];
388 },
389 maxDate: '0',
390 onChangeMonthYear: function (year, month) {
391 tmp_img_lyr_cigreen_current_month = month;
392 tmp_img_lyr_cigreen_current_yr = year;
393 }
394 });
395
396 // TT added
397 //$(".cigreen_cal_options_wrapper").append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div><div class=\"lyr_lock_txt\">Lock this layer</div></div><div class=\"lyr_cigreen_view_wrapper\"><input name=\"cigreenView\" type=\"radio\" id=\"cigreenFarmView\" checked /><label for=\"cigreenFarmView\">Farm View</label><br/><input type=\"radio\" name=\"cigreenView\" id=\"cigreenFieldView\" /><label class=\"lyr_cigreen_selected\" for=\"cigreenFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_date_selected\"></p>");
398
399 //if ($('.cigreen_cal > .layer-calendar-skip-months').length === 0) {
400 // $(".cigreen_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
401 // $('.layer-calendar-skip-months:visible').fadeOut(5000);
402 //}
403 } else if ($('.rgb_cal_options_wrapper').children().length) {
404 refreshRGBCal();
405 }
406
407 //refresh calendar
408 //$(".cigreen_cal").datepicker("destroy");
409 //// TT added
410 //$(".misat_cal").datepicker("destroy");
411 //$(".rgb_cal").datepicker("destroy");
412
413
414
415 //$('.misat_cal_options_wrapper').empty();
416 //$('.cigreen_cal_options_wrapper').empty();
417 //$('.rgb_cal_options_wrapper').empty();
418 //
419
420 //$('.satSelectIcons').removeClass('hoveredIcon selectedIcon');
421 //$('#ci_green_icon').addClass('selectedIcon');
422
423 //$('#satelliteTypeName').text('CI Green');
424
425 //$(".cigreen_date_selected").empty();
426 //var setDefaultDate = new Date(im_arr_cigreen_dates[0]);
427 //if ((tmp_img_lyr_cigreen_current_month != "") && (tmp_img_lyr_cigreen_current_yr != "")) {
428 // //user has browsed misat calendar months
429 // setDefaultDate = (new Date(tmp_img_lyr_cigreen_current_month + '/01/' + tmp_img_lyr_cigreen_current_yr)).toISOString()
430 //}
431
432
433 //$(".cigreen_cal").datepicker({
434 // beforeShowDay: function (date) {
435 // return (im_arr_cigreen_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_cigreen_dates_NoCloudCover, im_arr_cigreen_dates_HasCloud, im_arr_cigreen_dates_PartialCloudCover)] : [false, ""];
436 // },
437 // dateFormat: "dd-mm-yy",
438 // defaultDate: new Date(setDefaultDate),
439 // minDate: new Date(im_arr_cigreen_dates[im_arr_cigreen_dates.length - 1]),
440 // onSelect: function (data) {
441 // debugger;
442 // img_displayImageOverLay(data, 17, im_arr_cigreen_overlay);
443 // displaySelectedCalDate(data, 17);
444 // tmp_img_lyr_cigreen_current_day = data.split('-')[0];
445 // tmp_img_lyr_cigreen_current_month = data.split('-')[1];
446 // tmp_img_lyr_cigreen_current_yr = data.split('-')[2];
447 // },
448 // maxDate: '0',
449 // onChangeMonthYear: function (year, month) {
450 // tmp_img_lyr_cigreen_current_month = month;
451 // tmp_img_lyr_cigreen_current_yr = year;
452 // }
453 //});
454
455 //// TT added
456 ////$(".cigreen_cal_options_wrapper").append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div><div class=\"lyr_lock_txt\">Lock this layer</div></div><div class=\"lyr_cigreen_view_wrapper\"><input name=\"cigreenView\" type=\"radio\" id=\"cigreenFarmView\" checked /><label for=\"cigreenFarmView\">Farm View</label><br/><input type=\"radio\" name=\"cigreenView\" id=\"cigreenFieldView\" /><label class=\"lyr_cigreen_selected\" for=\"cigreenFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_date_selected\"></p>");
457
458 ////if ($('.cigreen_cal > .layer-calendar-skip-months').length === 0) {
459 //// $(".cigreen_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
460 //// $('.layer-calendar-skip-months:visible').fadeOut(5000);
461 ////}
462
463}
464
465function refreshRGBCal() {
466 //refresh calendar
467 $(".rgb_cal").datepicker("destroy");
468 $(".rgb_cal").datepicker({
469 beforeShowDay: function (date) {
470 return (im_arr_rgb_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_rgb_dates_NoCloudCover, im_arr_rgb_dates_HasCloud, im_arr_rgb_dates_PartialCloudCover)] : [false, ""];
471 },
472 dateFormat: "dd-mm-yy",
473 defaultDate: new Date(im_arr_rgb_dates[0]),
474 minDate: new Date(im_arr_rgb_dates[im_arr_rgb_dates.length - 1]),
475 onSelect: function (data) {
476 img_displayImageOverLay(data, 8, im_arr_rgb_overlay);
477 displaySelectedCalDate(data, 8);
478 },
479 maxDate: '0'
480 });
481
482 if ($('.rgb_cal > .layer-calendar-skip-months').length === 0) {
483 $(".rgb_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
484 $('.layer-calendar-skip-months:visible').fadeOut(5000);
485 }
486
487}
488
489function refreshYieldCal() {
490
491 //refresh calendar
492 $(".rgb_cal").datepicker("destroy");
493 $(".rgb_cal").datepicker({
494 beforeShowDay: function (date) {
495 return (im_arr_yield_overlay.indexOf(date.toISOString()) > -1) ? [true, "conductivity_calendar_date_Diff"] : [false, ""];
496 },
497 dateFormat: "dd-mm-yy",
498 defaultDate: new Date(im_arr_yield_overlay[0]),
499 minDate: new Date(im_arr_yield_overlay[im_arr_yield_overlay.length - 1]),
500 onSelect: function (data) {
501 img_displayImageOverLay(data, 9, im_arr_yield_overlay);
502 displaySelectedCalDate(data, 9);
503 },
504 maxDate: '0'
505 });
506
507 if ($('.rgb_cal > .layer-calendar-skip-months').length === 0) {
508 $(".rgb_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
509 $('.layer-calendar-skip-months:visible').fadeOut(5000);
510 }
511
512}
513
514function refreshRTKCal() {
515 //refresh calendar
516 $(".rtk_cal").datepicker("destroy");
517 $(".rtk_cal").datepicker({
518 beforeShowDay: function (date) {
519 return (tempArrRtkdate.indexOf(date.toISOString()) > -1) ? [true, "conductivity_calendar_date_Diff"] : [false, ""];
520 },
521 dateFormat: "dd-mm-yy",
522 defaultDate: new Date(tempArrRtkdate[0]),
523 minDate: new Date(tempArrRtkdate[tempArrRtkdate.length - 1]),
524 onSelect: function (data) {
525 img_displayImageOverLay(data, 3, im_arr_rtk_overlay);
526 displaySelectedCalDate(data, 3);
527 },
528 maxDate: '0'
529 });
530
531 if ($('.rtk_cal > .layer-calendar-skip-months').length === 0) {
532 $(".rtk_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
533 $('.layer-calendar-skip-months:visible').fadeOut(5000);
534 }
535
536}
537
538function refreshUAVCal() {
539 //refresh calendar
540 $(".uav_cal").datepicker("destroy");
541 $(".uav_cal").datepicker({
542 beforeShowDay: function (date) {
543 return (tempArrUavdate.indexOf(date.toISOString()) > -1) ? [true, ""] : [false, ""];
544 },
545 dateFormat: "dd-mm-yy",
546 defaultDate: new Date(tempArrUavdate[0]),
547 minDate: new Date(tempArrUavdate[tempArrUavdate.length - 1]),
548 onSelect: function (data) {
549 img_displayImageOverLay(data, 4, im_arr_uav_overlay);
550 displaySelectedCalDate(data, 4);
551 },
552 maxDate: '0'
553 });
554
555 if ($('.uav_cal > .layer-calendar-skip-months').length === 0) {
556 $(".uav_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
557 $('.layer-calendar-skip-months:visible').fadeOut(5000);
558 }
559}
560
561$(document).on("click", ".conductivity_cal_options", function () {
562 //close legend panel.
563 displayLeftDetailsPanel(false);
564 var sub = 0;
565 var subTxT = "";
566 if ($(this).val() == "DIFF") {
567 sub = 9;
568 subTxT = "EM Difference";
569 }
570
571 if ($(this).val() == "Shall") {
572 sub = 8;
573 subTxT = "EM Shallow";
574 }
575
576 if ($(this).val() == "Deep") {
577 sub = 7;
578 subTxT = "EM Deep";
579
580 }
581 $(".conductivity_subtype").empty().text(subTxT);
582
583
584 im_getOverlayByDate("-" + subTxT, 6, sub);
585
586});
587
588$(document).on('mouseenter', '#ci_green_icon, #rgb_icon, #ndvi_icon', function () {
589 let optionId = $(this).attr('id');
590
591 if ($(this).hasClass('selectedIcon') == false) {
592 $(this).addClass('hoveredIcon');
593 }
594
595 if (optionId == "ci_green_icon") {
596 $('#satelliteTypeName').text('CI Green');
597 }
598 else if (optionId == "ndvi_icon") {
599 $('#satelliteTypeName').text('NDVI');
600 }
601 else if (optionId == "rgb_icon") {
602 $(' #satelliteTypeName').text('RGB');
603 }
604});
605
606$(document).on('mouseleave', '#ci_green_icon, #rgb_icon, #ndvi_icon', function () {
607 let optionId = $(this).attr('id');
608
609 if ($(this).hasClass('selectedIcon') == false) {
610 //$(this).css('color', 'white');
611 $(this).removeClass('hoveredIcon');
612 }
613
614 let selectedFound = false;
615
616 $(".satSelectIcons").each(function (index) {
617 if ($(this).hasClass('selectedIcon') === true) {
618 selectedFound = true;
619
620 let optionId = $(this).attr('id');
621
622 if (optionId == "ci_green_icon") {
623 $('#satelliteTypeName').text('CI Green');
624 }
625 else if (optionId == "ndvi_icon") {
626 $('#satelliteTypeName').text('NDVI');
627 }
628 else if (optionId == "rgb_icon") {
629 $(' #satelliteTypeName').text('RGB');
630 }
631 }
632 });
633
634 if (selectedFound === false) {
635 $('#satelliteTypeName').text('No option selected');
636 }
637
638});
639
640$(document).on('click', '.satSelectIcons', function () {
641 // clear the map of any previous layers;
642 img_clearOverlay();
643
644 let optionId = $(this).attr('id');
645
646 debugger;
647 // remove currently selected or hovered icons
648 $('.satSelectIcons').removeClass('hoveredIcon selectedIcon');
649
650 $(this).addClass('selectedIcon');
651
652 // remove the calender thats currently visible
653 $(".cigreen_cal").datepicker("destroy");
654 $(".misat_cal").datepicker("destroy");
655 $(".rgb_cal").datepicker("destroy");
656
657 // remove children of the wrapper element
658 $('.misat_cal_options_wrapper').empty();
659 $('.cigreen_cal_options_wrapper').empty();
660 $('.rgb_cal_options_wrapper').empty();
661
662 //$('.lyr_lock').remove();
663 debugger;
664
665 if (optionId == "ci_green_icon") {
666 loadMapLayerImgTypeDateDDL(17);
667 }
668 else if (optionId == "ndvi_icon") {
669 //$('.lyr_lock_txt').remove();
670 //$('.lyr_cigreen_view_wrapper').remove();
671
672 loadMapLayerImgTypeDateDDL(2);
673 }
674 else if (optionId == "rgb_icon") {
675 loadMapLayerImgTypeDateDDL(8);
676
677 }
678
679 debugger;
680 layer_MiSAT_Combined_Satellites_Lock_Check();
681
682 debugger;
683})
684
685$(document).on("click", ".nsensor_cal_options", function () {
686 debugger;
687 //clear map of any previous n-sensor layer
688 img_clearOverlay();
689 //refresh calendar
690 $(".n_sensor_cal").datepicker("destroy");
691 if ($(this).val() == "BI") {
692 //load BI dates
693 //display calendar
694 $(".n_sensor_cal").datepicker({
695 beforeShowDay: function (date) {
696 return (im_arr_n_sensor_BI_dates.indexOf(date.toISOString()) > -1) ? [true, "n_sensor_calendar_date_BI"] : [false, ""];
697 },
698 dateFormat: "dd-mm-yy",
699 defaultDate: new Date(im_arr_n_sensor_BI_dates[0]),
700 minDate: new Date(im_arr_n_sensor_BI_dates[im_arr_n_sensor_BI_dates.length - 1]),
701 onSelect: function (data) {
702 $(this).find(".n_sensor_calendar_date_BI").each(function () {
703 //var t = $(this).children(0).text();
704 $(this).children(0).addClass("mportant;");
705 })
706
707 img_displayImageOverLaySubType(data, 1, 6, im_arr_nsensor_overlay);
708
709 },
710 maxDate: '0'
711 });
712 }
713
714 if ($(this).val() == "NAS") {
715 //load NAS dates
716 //display calendar
717 $(".n_sensor_cal").datepicker({
718 beforeShowDay: function (date) {
719 return (im_arr_n_sensor_NAS_dates.indexOf(date.toISOString()) > -1) ? [true, "n_sensor_calendar_date_NAS"] : [false, ""];
720 },
721 dateFormat: "dd-mm-yy",
722 defaultDate: new Date(im_arr_n_sensor_NAS_dates[0]),
723 minDate: new Date(im_arr_n_sensor_NAS_dates[im_arr_n_sensor_NAS_dates.length - 1]),
724 onSelect: function (data) {
725 $(this).find(".n_sensor_calendar_date_NAS").each(function () {
726 // var t = $(this).children(0).text();
727 $(this).children(0).addClass("mportant;");
728 })
729
730 img_displayImageOverLaySubType(data, 1, 4, im_arr_nsensor_overlay);
731 },
732 maxDate: '0'
733 });
734 }
735
736
737 if ($(this).val() == "N") {
738 //load N dates
739 //display calendar
740 $(".n_sensor_cal").datepicker({
741 beforeShowDay: function (date) {
742 return (im_arr_n_sensor_N_dates.indexOf(date.toISOString()) > -1) ? [true, "n_sensor_calendar_date_N"] : [false, ""];
743 },
744 dateFormat: "dd-mm-yy",
745 defaultDate: new Date(im_arr_n_sensor_N_dates[0]),
746 minDate: new Date(im_arr_n_sensor_N_dates[im_arr_n_sensor_N_dates.length - 1]),
747 onSelect: function (data) {
748 debugger;
749 $(this).find(".n_sensor_calendar_date_N").each(function () {
750 // var t = $(this).children(0).text();
751 $(this).children(0).addClass("mportant;");
752 })
753
754 img_displayImageOverLaySubType(data, 1, 5, im_arr_nsensor_overlay);
755 debugger;
756 },
757 maxDate: '0'
758 });
759 }
760
761 if ($('.n_sensor_cal > .layer-calendar-skip-months').length === 0) {
762 $(".n_sensor_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
763 $('.layer-calendar-skip-months:visible').fadeOut(5000);
764 }
765
766})
767
768
769
770im_bImgLayerLoadedTimer = false;
771
772function im_loaderImgLayerData() {
773 if (im_bMapDataLoaded) {
774 removeLoader();
775 clearInterval(im_bImgLayerLoadedTimer);
776 im_bImgLayerLoadedTimer = false;
777 im_bMapDataLoaded = false;
778 }
779 else {
780 im_bImgLayerLoadedTimer = setTimeout(function () { im_loaderImgLayerData() }, 2000);
781 }
782}
783
784function im_loadSubTypeStatus(typeId, date, subTypeId) {
785
786 var subTypeName;
787
788 if (typeId == 1 || typeId == 5) {
789
790 subTypeName = date.split('-')[1].trim();
791 }
792
793 if (typeId == 6) {
794 if (subTypeId == 9) {
795 subTypeName = "EM Difference";
796 }
797 if (subTypeId == 8) {
798 subTypeName = "EM Shallow";
799 }
800 if (subTypeId == 7) {
801 subTypeName = "EM Deep";
802 }
803 }
804
805 loadStatus("Loading " + im_getImgLyrTypeName(typeId, subTypeName) + " Data");
806}
807
808function im_getOverlayByDate(date, typeId, subTypeId) {
809 debugger;
810
811 if (!im_bAjax_loading) {
812
813 im_bAjax_loading = true;
814 im_loadSubTypeStatus(typeId, date, subTypeId);
815
816 if (typeId == 1 || typeId == 5 || typeId == 6) {
817
818 var thisSubType = date.split('-')[1].trim() + "|" + subTypeId;
819 if (typeId != 6) {
820 date = date.split('-')[0].trim();
821 }
822 else {
823 date = "";
824 }
825 }
826
827 im_loaderImgLayerData();
828
829 $.ajax({
830 type: "POST",
831 url: urlPrepend + "/layerdata/imagery/overlay/",
832 data: { tradingId: getTradingId(), farmId: getFarmId(), layerId: typeId, d: date, s: subTypeId, seasonId: $("#customerSeason").find(":selected").val()},
833 }).done(function (data) {
834
835 //hide crop season overlay
836 crp_clearCropPolygons()
837 crp_clear_farm_wide_crops();
838
839 debugger;
840 var t = JSON.parse(data);
841 var strDDL = "";
842
843 if (t.hasOwnProperty("nsensor")) {
844 //get nsensor data
845 if (t.nsensor.length > 0) {
846
847 for (var i = 0; i < t.nsensor.length; i++) {
848 im_arr_nsensor_overlay.push(createOverlayObj(t.nsensor[i], 1));
849 }
850
851 processImagerySubTypeObjectArrays(im_arr_nsensor_overlay, date, 1, thisSubType)
852 }
853 }
854
855 if (t.hasOwnProperty("misat")) {
856 //get misat data - misat
857 if (t.misat.length > 0) {
858 for (var i = 0; i < t.misat.length; i++) {
859 im_arr_misat_overlay.push(createOverlayObj(t.misat[i], 2));
860 }
861 //load overlay onto map
862 processImageryObjectArrays(im_arr_misat_overlay, date, 2);
863 }
864 }
865
866 if (t.hasOwnProperty("rtk")) {
867 //get rtk data
868 if (t.rtk.length > 0) {
869
870 for (var i = 0; i < t.rtk.length; i++) {
871 im_arr_rtk_overlay.push(createOverlayObj(t.rtk[i], 3));
872 }
873 //load overlay onto map
874 processImageryObjectArrays(im_arr_rtk_overlay, date, 3);
875 }
876 }
877
878 if (t.hasOwnProperty("uav")) {
879 //get uav data
880 if (t.uav.length > 0) {
881
882 for (var i = 0; i < t.uav.length; i++) {
883 im_arr_uav_overlay.push(createOverlayObj(t.uav[i], 4));
884 }
885 //load overlay onto map
886 processImageryObjectArrays(im_arr_uav_overlay, date, 4);
887 }
888 }
889
890 if (t.hasOwnProperty("conductivity")) {
891 //get conductivity data
892 if (t.conductivity.length > 0) {
893
894 for (var i = 0; i < t.conductivity.length; i++) {
895 im_arr_conductivity_overlay.push(createOverlayObj(t.conductivity[i], 6));
896 }
897
898 processImagerySubTypeObjectArrays(im_arr_conductivity_overlay, date, 6, thisSubType)
899 }
900 }
901
902
903 if (t.hasOwnProperty("migrass")) {
904 //get Migrass data
905 if (t.migrass.length > 0) {
906 for (var i = 0; i < t.migrass.length; i++) {
907 im_arr_migrass_overlay.push(createOverlayObj(t.migrass[i], 7));
908 }
909 //load overlay onto map
910 processImageryObjectArrays(im_arr_migrass_overlay, date, 7);
911 }
912 }
913
914
915 if (t.hasOwnProperty("rgb")) {
916 //get rgb data
917 if (t.rgb.length > 0) {
918
919 for (var i = 0; i < t.rgb.length; i++) {
920 im_arr_rgb_overlay.push(createOverlayObj(t.rgb[i], 8));
921 }
922 //load overlay onto map
923 processImageryObjectArrays(im_arr_rgb_overlay, date, 8);
924 }
925 }
926
927
928 if (t.hasOwnProperty("yield")) {
929 //get yield data
930 if (t.yield.length > 0) {
931
932 for (var i = 0; i < t.yield.length; i++) {
933 im_arr_yield_overlay.push(createOverlayObj(t.yield[i], 9));
934 }
935 //load overlay onto map
936 processImageryObjectArrays(im_arr_yield_overlay, date, 9);
937 }
938 }
939
940 if (t.hasOwnProperty("cdaximg")) {
941 //get afbi cdax image data
942 if (t.cdaximg.length > 0) {
943
944 for (var i = 0; i < t.cdaximg.length; i++) {
945 im_arr_afbi_cdax_img_overlay.push(createOverlayObj(t.cdaximg[i], 12));
946 }
947 //load overlay onto map
948 processImageryObjectArrays(im_arr_afbi_cdax_img_overlay, date, 12);
949 }
950 }
951
952 if (t.hasOwnProperty("misatFieldView")) {
953 //get misat-fieldView image data
954 if (t.misatFieldView.length > 0) {
955
956 for (var i = 0; i < t.misatFieldView.length; i++) {
957 im_arr_misat_fieldView_img_overlay.push(createOverlayObj(t.misatFieldView[i], 14));
958 }
959 //load overlay onto map
960 processImageryObjectArrays(im_arr_misat_fieldView_img_overlay, date, 14);
961 }
962 }
963
964 if (t.hasOwnProperty("cigreen")) {
965 //get cigreen data
966 if (t.cigreen.length > 0) {
967 for (var i = 0; i < t.cigreen.length; i++) {
968 im_arr_cigreen_overlay.push(createOverlayObj(t.cigreen[i], 17));
969 }
970 //load overlay onto map
971 processImageryObjectArrays(im_arr_cigreen_overlay, date, 17);
972 }
973 }
974
975
976 if (t.hasOwnProperty("cigreenFieldView")) {
977 //get cigreen field view data
978 if (t.cigreenFieldView.length > 0) {
979 for (var i = 0; i < t.cigreenFieldView.length; i++) {
980 im_arr_cigreen_fieldView_img_overlay.push(createOverlayObj(t.cigreenFieldView[i], 19));
981 }
982 //load overlay onto map
983 processImageryObjectArrays(im_arr_cigreen_fieldView_img_overlay, date, 19);
984 }
985 }
986
987 if (t.hasOwnProperty("cvi")) {
988 //get cvi data
989 if (t.cvi.length > 0) {
990 for (var i = 0; i < t.cvi.length; i++) {
991 im_arr_cvi_overlay.push(createOverlayObj(t.cvi[i], 16));
992 }
993 //load overlay onto map
994 processImageryObjectArrays(im_arr_cvi_overlay, date, 16);
995 }
996 }
997
998
999 if (t.hasOwnProperty("cviFieldView")) {
1000 //get cvi field view data
1001 if (t.cviFieldView.length > 0) {
1002 for (var i = 0; i < t.cviFieldView.length; i++) {
1003 im_arr_cvi_fieldView_img_overlay.push(createOverlayObj(t.cviFieldView[i], 18));
1004 }
1005 //load overlay onto map
1006 processImageryObjectArrays(im_arr_cvi_fieldView_img_overlay, date, 18);
1007 }
1008 }
1009
1010
1011 if (t.hasOwnProperty("misatVarietyView")) {
1012 //get misat variety view data
1013 if (t.misatVarietyView.length > 0) {
1014 for (var i = 0; i < t.misatVarietyView.length; i++) {
1015 im_arr_misat_variety_view_img_overlay.push(createOverlayObj(t.misatVarietyView[i], 20));
1016 }
1017 //load overlay onto map
1018 processImageryObjectArrays(im_arr_misat_variety_view_img_overlay, date, 20);
1019 }
1020 }
1021
1022
1023 im_bAjax_loading = false;
1024 im_bMapDataLoaded = true;
1025 });
1026 }
1027 else {
1028 removeLoader();
1029
1030 if (typeId == 2) {
1031 $(".imagery_layer_misat").children().find(".layer-data-types").toggle();
1032 }
1033
1034
1035 }
1036
1037
1038}
1039
1040function processImagerySubTypeObjectArrays(objArr, txtDate, type, subType) {
1041
1042 var latlngbounds = new google.maps.LatLngBounds();
1043
1044 if (type != 6) {
1045 for (var i = 0; i < objArr.length; i++) {
1046
1047 if ((objArr[i].dateperformed.split(' ')[0] == txtDate) && (objArr[i].subtype.replace(/\|/g, '') == subType.replace(/\|/g, ''))) {
1048
1049 for (var j = 0; j < polygonsArray.length; j++) {
1050 if (objArr[i].id == polygonsArray[j].id) {
1051 var overlayBoundary = new google.maps.MVCArray();
1052 for (var k = 0; k < polygonsArray[j].getPath().getLength() ; k++) {
1053 overlayBoundary.push(new google.maps.LatLng(polygonsArray[j].getPath().getAt(k).lat(), polygonsArray[j].getPath().getAt(k).lng()));
1054 //for map bounds
1055 var coords = polygonsArray[j].getPath().getAt(k);
1056 latlngbounds.extend(coords);
1057 }
1058
1059 drawOverlay(overlayBoundary, objArr[i].id, objArr[i].image, type + "|" + subType, objArr[i].legend, objArr[i].dateperformed, objArr[i].fieldName, objArr[i].crop, true);
1060 polygonsArray[j].setMap(null);
1061 }
1062 }
1063 }
1064 }
1065 }
1066 else {
1067 //conductivity
1068 for (var i = 0; i < objArr.length; i++) {
1069
1070 //use matched id to get field coordinates for bounding box overlay
1071 tempFieldId = objArr[i].id;
1072 //loop through field polygons to get points for overlay bounds polygon
1073 for (var j = 0; j < polygonsArray.length; j++) {
1074 if (tempFieldId == polygonsArray[j].id) {
1075 var overlayBoundary = new google.maps.MVCArray();
1076 for (var k = 0; k < polygonsArray[j].getPath().getLength() ; k++) {
1077 overlayBoundary.push(new google.maps.LatLng(polygonsArray[j].getPath().getAt(k).lat(), polygonsArray[j].getPath().getAt(k).lng()));
1078 //for map bounds
1079 var coords = polygonsArray[j].getPath().getAt(k);
1080 // latlngbounds.extend(coords);
1081 }
1082
1083 drawOverlay(overlayBoundary, objArr[i].id, objArr[i].image, type + "|" + subType, objArr[i].legend, objArr[i].dateperformed, objArr[i].fieldName, objArr[i].crop, true);
1084
1085 polygonsArray[j].setMap(null);
1086 }
1087 }
1088
1089 //if (i == objArr.length - 1) {
1090 // // map.fitBounds(latlngbounds);
1091 // displayOverlay(type);
1092 // setTimeout(function () { removeLoader() }, 2000);
1093
1094 //}
1095 }
1096
1097
1098 }
1099
1100
1101
1102 im_bMapDataLoaded = true;
1103
1104 im_bImgLayerLoadedTimer = setTimeout(function () { im_loaderImgLayerData() }, 2000);
1105
1106
1107}
1108
1109function processImageryObjectArrays(objArr, txtDate, type) {
1110 debugger;
1111 for (var i = 0; i < im_polygon_overlay.length; i++) {
1112 im_polygon_overlay[i].overlay.setMap(null);
1113 }
1114 for (var i = 0; i < im_polygon_overlay_temp_customer_overlay.length; i++) {
1115 im_polygon_overlay_temp_customer_overlay[i].setMap(null);
1116 }
1117
1118 im_polygon_overlay = []
1119 im_polygon_overlay_temp_customer_overlay = [];
1120
1121
1122
1123 for (var i = 0; i < objArr.length; i++) {
1124
1125 if (objArr[i].dateperformed.split(' ')[0] == txtDate) {
1126 //use matched id to get field coordinates for bounding box overlay
1127 tempFieldId = objArr[i].id;
1128 //loop through field polygons to get points for overlay bounds polygon
1129 for (var j = 0; j < polygonsArray.length; j++) {
1130 if (tempFieldId == polygonsArray[j].id) {
1131 var overlayBoundary = new google.maps.MVCArray();
1132 for (var k = 0; k < polygonsArray[j].getPath().getLength() ; k++) {
1133 overlayBoundary.push(new google.maps.LatLng(polygonsArray[j].getPath().getAt(k).lat(), polygonsArray[j].getPath().getAt(k).lng()));
1134 //for map bounds
1135 var coords = polygonsArray[j].getPath().getAt(k);
1136 // latlngbounds.extend(coords);
1137 }
1138 drawOverlay(overlayBoundary, tempFieldId, objArr[i].image, type, objArr[i].legend, objArr[i].dateperformed, objArr[i].fieldName, objArr[i].crop, false);
1139 polygonsArray[j].setMap(null);
1140 }
1141 }
1142 }
1143
1144 if (i == objArr.length - 1) {
1145 // map.fitBounds(latlngbounds);
1146 displayOverlay(type);
1147 setTimeout(function () {removeLoader() }, 2000);
1148
1149 }
1150 }
1151
1152 debugger;
1153
1154}
1155
1156function im_clrOverlays() {
1157 for (var i = 0; i < im_polygon_overlay_temp_customer_overlay.length; i++) {
1158 im_polygon_overlay_temp_customer_overlay[i].setMap(null);
1159 }
1160 im_polygon_overlay_temp_customer_overlay = [];
1161
1162 for (var j = 0; j < im_polygon_overlay.length; j++) {
1163 im_polygon_overlay[j].overlay.setMap(null);
1164
1165 }
1166 im_polygon_overlay = [];
1167
1168
1169}
1170
1171function loadLocalMapLayerImgData(id, selectedDate) {
1172
1173 var bHasLocalData = false;
1174 switch (id) {
1175 case 1:
1176 if (im_arr_nsensor_overlay.length > 0) {
1177
1178 //loop through array and see if the selected data exists
1179 for (var i = 0; i < im_arr_nsensor_overlay.length; i++) {
1180 if (im_arr_nsensor_overlay[i].dateperformed.split(' ')[0] == selectedDate.split(' ')[0].trim() && im_arr_nsensor_overlay[i].subtype.split('|')[1] == selectedDate.split('-')[1].split('|')[1]) {
1181 bHasLocalData = true;
1182 i = im_arr_nsensor_overlay.length + 1;
1183 }
1184 }
1185 }
1186 break;
1187 case 2:
1188 if (im_arr_misat_overlay.length > 0) {
1189
1190
1191 //loop through array and see if the selected data exists
1192 for (var i = 0; i < im_arr_misat_overlay.length; i++) {
1193 if (im_arr_misat_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1194 bHasLocalData = true;
1195 i = im_arr_misat_overlay.length;
1196 }
1197 }
1198 }
1199 break;
1200 case 4:
1201 if (im_arr_uav_overlay.length > 0) {
1202
1203
1204 //loop through array and see if the selected data exists
1205 for (var i = 0; i < im_arr_uav_overlay.length; i++) {
1206 if (im_arr_uav_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1207 bHasLocalData = true;
1208 i = im_arr_uav_overlay.length;
1209 }
1210 }
1211 }
1212 break;
1213 case 6:
1214 if (im_arr_conductivity_overlay.length > 0) {
1215
1216
1217 //loop through array and see if the selected data exists
1218 for (var i = 0; i < im_arr_conductivity_overlay.length; i++) {
1219 if (im_arr_conductivity_overlay[i].dateperformed.split(' ')[0] == selectedDate.split(' ')[0].trim() && im_arr_conductivity_overlay[i].subtype.split('|')[1] == selectedDate.split('-')[1].split('|')[1]) {
1220 bHasLocalData = true;
1221 i = im_arr_conductivity_overlay.length + 1;
1222 }
1223 }
1224 }
1225 break;
1226 case 7:
1227 if (im_arr_migrass_overlay.length > 0) {
1228 //loop through array and see if the selected data exists
1229 for (var i = 0; i < im_arr_migrass_overlay.length; i++) {
1230 if (im_arr_migrass_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1231 bHasLocalData = true;
1232 i = im_arr_migrass_overlay.length;
1233 }
1234 }
1235
1236 }
1237 break;
1238 case 8:
1239 if (im_arr_rgb_overlay.length > 0) {
1240 //loop through array and see if the selected data exists
1241 for (var i = 0; i < im_arr_rgb_overlay.length; i++) {
1242 if (im_arr_rgb_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1243 bHasLocalData = true;
1244 i = im_arr_rgb_overlay.length;
1245 }
1246 }
1247
1248 }
1249 break;
1250 case 9:
1251 if (im_arr_yield_overlay.length > 0) {
1252 //loop through array and see if the selected data exists
1253 for (var i = 0; i < im_arr_yield_overlay.length; i++) {
1254 if (im_arr_yield_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1255 bHasLocalData = true;
1256 i = im_arr_yield_overlay.length;
1257 }
1258 }
1259 }
1260 break;
1261 case 14:
1262 if (im_arr_misat_fieldView_img_overlay.length > 0) {
1263
1264
1265 //loop through array and see if the selected data exists
1266 for (var i = 0; i < im_arr_misat_fieldView_img_overlay.length; i++) {
1267 if (im_arr_misat_fieldView_img_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1268 bHasLocalData = true;
1269 i = im_arr_misat_fieldView_img_overlay.length;
1270 }
1271 }
1272 }
1273 break;
1274 case 16:
1275 if (im_arr_cvi_overlay.length > 0) {
1276
1277 //loop through array and see if the selected data exists
1278 for (var i = 0; i < im_arr_cvi_overlay.length; i++) {
1279 if (im_arr_cvi_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1280 bHasLocalData = true;
1281 i = im_arr_cvi_overlay.length;
1282 }
1283 }
1284 }
1285 break;
1286
1287 case 17:
1288 if (im_arr_cigreen_overlay.length > 0) {
1289
1290
1291 //loop through array and see if the selected data exists
1292 for (var i = 0; i < im_arr_cigreen_overlay.length; i++) {
1293 if (im_arr_cigreen_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1294 bHasLocalData = true;
1295 i = im_arr_cigreen_overlay.length;
1296 }
1297 }
1298 }
1299 break;
1300
1301 case 20:
1302 if (im_arr_misat_variety_view_img_overlay.length > 0) {
1303
1304
1305 //loop through array and see if the selected data exists
1306 for (var i = 0; i < im_arr_misat_variety_view_img_overlay.length; i++) {
1307 if (im_arr_misat_variety_view_img_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1308 bHasLocalData = true;
1309 i = im_arr_misat_variety_view_img_overlay.length;
1310 }
1311 }
1312 }
1313 break;
1314
1315
1316
1317
1318 //afbi
1319 case 014:
1320 if (im_arr_afbi_cdax_img_overlay.length > 0) {
1321 //loop through array and see if the selected data exists
1322 for (var i = 0; i < im_arr_afbi_cdax_img_overlay.length; i++) {
1323 if (im_arr_afbi_cdax_img_overlay[i].dateperformed.split(' ')[0] == selectedDate) {
1324 bHasLocalData = true;
1325 i = im_arr_afbi_cdax_img_overlay.length;
1326 }
1327 }
1328 }
1329 break;
1330 }
1331 return bHasLocalData
1332}
1333
1334var im_img_lyr_wrapper_element = "";
1335
1336function displaySelectedCalDate(date, type) {
1337 switch (type) {
1338 case 1:
1339 $(".n-sensor_date_selected").text("Date selected " + date);
1340 break;
1341 case 2:
1342 case 14:
1343 $(".misat_date_selected").text("Date selected " + date);
1344 break;
1345 case 3:
1346 $(".rtk_date_selected").text("Date selected " + date);
1347 break;
1348 case 4:
1349 $(".uav_date_selected").text("Date selected " + date);
1350 break;
1351 case 6:
1352 $(".conductivity_date_selected").text("Date selected " + date);
1353 break;
1354 case 7:
1355 $(".migrass_date_selected").text("Date selected " + date);
1356 break;
1357 case 8:
1358 $(".rgb_date_selected").text("Date selected " + date);
1359 break;
1360 case 9:
1361 $(".yield_date_selected").text("Date selected " + date);
1362 break;
1363 case 16:
1364 case 18:
1365 $(".cvi_date_selected").text("Date selected " + date);
1366 break;
1367 case 17:
1368 case 19:
1369 $(".cigreen_date_selected").text("Date selected " + date);
1370 break;
1371 case 20:
1372 $(".misat_variety_date_selected").text("Date selected " + date);
1373 break;
1374 case 21:
1375 $(".cigreen_variety_date_selected").text("Date selected " + date);
1376 break;
1377 case 014:
1378 $(".afbi_cdax_img_cal_date_selected").text("Date selected " + date);
1379 break;
1380 }
1381}
1382
1383
1384$(document).on("click", "#misatFieldView", function () {
1385
1386 //reload calendar
1387 $(".misat_cal").datepicker("destroy");
1388
1389 resetLayerLock_SwitchBetweenFarmFieldView();
1390
1391 //display loader
1392 $(".misat_data_loader").show();
1393
1394 $(".imagery_layer_misat").find(".layer_item_loader").show();
1395 //get field view data
1396 loadMapLayerImgTypeDateDDL(14);
1397
1398 //user viewing map data?
1399 if ($(".misat_date_selected").text().length > 0) {
1400 //close legend panel.
1401 displayLeftDetailsPanel(false);
1402 //remove any farm wide data
1403 img_clearOverlay();
1404
1405 if (tmp_img_lyr_misat_current_day != "") {
1406 //we have a day so load field view data fo that date.
1407 if (tmp_img_lyr_misat_current_day.length == 1) {
1408 tmp_img_lyr_misat_current_day = "0" + tmp_img_lyr_misat_current_day;
1409 }
1410 if (String(tmp_img_lyr_misat_current_month).length == 1) {
1411 tmp_img_lyr_misat_current_month = "0" + tmp_img_lyr_misat_current_month;
1412 }
1413 var temp_data = tmp_img_lyr_misat_current_day + "-" + tmp_img_lyr_misat_current_month + "-" + tmp_img_lyr_misat_current_yr;
1414
1415 setTimeout(function () {
1416 img_displayImageOverLay(temp_data, 14, im_arr_misat_fieldView_img_overlay);
1417
1418 }, 500);
1419
1420 setTimeout(function () {
1421 displaySelectedCalDate(temp_data, 14);
1422 }, 1500);
1423
1424
1425 }
1426
1427 }
1428
1429 //empty container with legend
1430 $(".misat_cal_options_wrapper").empty();
1431});
1432
1433$(document).on("click", "#misatFarmView", function () {
1434
1435 //display loader
1436 $(".misat_data_loader").show();
1437
1438 $(".imagery_layer_misat").find(".layer_item_loader").show();
1439 //get field view data
1440 loadMapLayerImgTypeDateDDL(2);
1441
1442 resetLayerLock_SwitchBetweenFarmFieldView();
1443
1444 //reload calendar
1445 $(".misat_cal").datepicker("destroy");
1446
1447
1448 //user viewing map data?
1449 if ($(".misat_date_selected").text().length > 0) {
1450
1451 //close legend panel.
1452 displayLeftDetailsPanel(false);
1453 //remove any farm wide data
1454 img_clearOverlay();
1455
1456 if (tmp_img_lyr_misat_current_day != "") {
1457 //we have a day so load field view data fo that date.
1458 if (tmp_img_lyr_misat_current_day.length == 1) {
1459 tmp_img_lyr_misat_current_day = "0" + tmp_img_lyr_misat_current_day;
1460 }
1461 if (String(tmp_img_lyr_misat_current_month).length == 1) {
1462 tmp_img_lyr_misat_current_month = "0" + tmp_img_lyr_misat_current_month;
1463 }
1464 var temp_data = tmp_img_lyr_misat_current_day + "-" + tmp_img_lyr_misat_current_month + "-" + tmp_img_lyr_misat_current_yr;
1465
1466 setTimeout(function () {
1467 img_displayImageOverLay(temp_data, 2, im_arr_misat_overlay);
1468
1469 }, 500);
1470
1471 setTimeout(function () {
1472 displaySelectedCalDate(temp_data, 2);
1473 }, 1500);
1474 }
1475 }
1476
1477
1478 //add loader img to panel then remove.
1479 $(".misat_cal_options_wrapper").empty();
1480
1481});
1482
1483
1484function resetLayerLock_SwitchBetweenFarmFieldView() {
1485 $(".lyr_highlight_locked_item").removeClass("lyr_highlight_locked_item");
1486 $(".lyr_locked_icon").removeClass("icon-noun_Lock_747565 lyr_lock_red").addClass("icon-noun_Unlock_821902");
1487 $(".lyr_lock_txt").empty().html("Lock this layer");
1488 $(".lyr_lock").removeClass("locked");
1489
1490
1491 $(".layerInfo ").each(function () {
1492 if ($(this).hasClass("lyr_locked")) {
1493 $(this).removeClass("lyr_locked")
1494 }
1495 });
1496
1497 $('.lyr_lock').remove();
1498
1499}
1500
1501$(document).on("click", "#cigreenFarmView", function () {
1502 debugger;
1503 gen_setGlobalSubMode(17);
1504 //reload calendar
1505 resetLayerLock_SwitchBetweenFarmFieldView();
1506
1507 //display loader
1508 $(".cigreen_data_loader").show();
1509
1510 $(".imagery_layer_cigreen").find(".layer_item_loader").show();
1511 //get farm view data
1512 loadMapLayerImgTypeDateDDL(17);
1513 debugger;
1514 //user viewing map data?
1515 if ($(".cigreen_date_selected").text().length > 0) {
1516 debugger;
1517 //close legend panel.
1518 displayLeftDetailsPanel(false);
1519 //remove any farm wide data
1520 img_clearOverlay();
1521
1522 if (tmp_img_lyr_cigreen_current_day != "") {
1523 //we have a day so load field view data fo that date.
1524 if (tmp_img_lyr_cigreen_current_day.length == 1) {
1525 tmp_img_lyr_cigreen_current_day = "0" + tmp_img_lyr_cigreen_current_day;
1526 }
1527 if (String(tmp_img_lyr_cigreen_current_month).length == 1) {
1528 tmp_img_lyr_cigreen_current_month = "0" + tmp_img_lyr_cigreen_current_month;
1529 }
1530 var temp_data = tmp_img_lyr_cigreen_current_day + "-" + tmp_img_lyr_cigreen_current_month + "-" + tmp_img_lyr_cigreen_current_yr;
1531 debugger;
1532 setTimeout(function () {
1533 img_displayImageOverLay(temp_data, 17, im_arr_cigreen_overlay);
1534
1535 }, 500);
1536
1537 setTimeout(function () {
1538 displaySelectedCalDate(temp_data, 17);
1539 }, 1500);
1540
1541
1542 }
1543
1544 }
1545
1546 //empty container with legend
1547 $(".cigreen_cal_options_wrapper").empty();
1548});
1549
1550$(document).on("click", "#cigreenFieldView", function () {
1551 debugger;
1552 gen_setGlobalSubMode(19);
1553 //reload calendar
1554 $(".cigreen_cal").datepicker("destroy");
1555
1556 resetLayerLock_SwitchBetweenFarmFieldView();
1557
1558 //display loader
1559 $(".cigreen_data_loader").show();
1560
1561 $(".imagery_layer_cigreen").find(".layer_item_loader").show();
1562 //get field view data
1563 loadMapLayerImgTypeDateDDL(19);
1564
1565 //user viewing map data?
1566 if ($(".cigreen_date_selected").text().length > 0) {
1567 //close legend panel.
1568 displayLeftDetailsPanel(false);
1569 //remove any farm wide data
1570 img_clearOverlay();
1571
1572 if (tmp_img_lyr_cigreen_current_day != "") {
1573 //we have a day so load field view data fo that date.
1574 if (tmp_img_lyr_cigreen_current_day.length == 1) {
1575 tmp_img_lyr_cigreen_current_day = "0" + tmp_img_lyr_cigreen_current_day;
1576 }
1577 if (String(tmp_img_lyr_cigreen_current_month).length == 1) {
1578 tmp_img_lyr_cigreen_current_month = "0" + tmp_img_lyr_cigreen_current_month;
1579 }
1580 var temp_data = tmp_img_lyr_cigreen_current_day + "-" + tmp_img_lyr_cigreen_current_month + "-" + tmp_img_lyr_cigreen_current_yr;
1581
1582 setTimeout(function () {
1583 img_displayImageOverLay(temp_data, 19, im_arr_cigreen_fieldView_img_overlay);
1584
1585 }, 500);
1586
1587 setTimeout(function () {
1588 displaySelectedCalDate(temp_data, 19);
1589 }, 1500);
1590
1591
1592 }
1593
1594 }
1595
1596 //empty container with legend
1597 $(".cigreen_cal_options_wrapper").empty();
1598});
1599
1600$(document).on("click", "#cviFieldView", function () {
1601
1602 //reload calendar
1603 $(".cvi_cal").datepicker("destroy");
1604
1605 //display loader
1606 $(".cvi_data_loader").show();
1607
1608 $(".imagery_layer_cvi").find(".layer_item_loader").show();
1609 //get field view data
1610 loadMapLayerImgTypeDateDDL(18);
1611
1612 //user viewing map data?
1613 if ($(".cvi_date_selected").text().length > 0) {
1614 //close legend panel.
1615 displayLeftDetailsPanel(false);
1616 //remove any farm wide data
1617 img_clearOverlay();
1618
1619 if (tmp_img_lyr_cvi_current_day != "") {
1620 //we have a day so load field view data fo that date.
1621 if (tmp_img_lyr_cvi_current_day.length == 1) {
1622 tmp_img_lyr_cvi_current_day = "0" + tmp_img_lyr_cvi_current_day;
1623 }
1624 if (String(tmp_img_lyr_cvi_current_month).length == 1) {
1625 tmp_img_lyr_cvi_current_month = "0" + tmp_img_lyr_cvi_current_month;
1626 }
1627 var temp_data = tmp_img_lyr_cvi_current_day + "-" + tmp_img_lyr_cvi_current_month + "-" + tmp_img_lyr_cvi_current_yr;
1628
1629 setTimeout(function () {
1630 img_displayImageOverLay(temp_data, 18, im_arr_cvi_fieldView_img_overlay);
1631
1632 }, 500);
1633
1634 setTimeout(function () {
1635 displaySelectedCalDate(temp_data, 18);
1636 }, 1500);
1637
1638
1639 }
1640
1641 }
1642
1643 //empty container with legend
1644 $(".cvi_cal_options_wrapper").empty();
1645});
1646
1647$(document).on("click", "#cviFarmView", function () {
1648
1649 //reload calendar
1650 $(".cvi_cal").datepicker("destroy");
1651
1652 //display loader
1653 $(".cvi_data_loader").show();
1654
1655 $(".imagery_layer_cvi").find(".layer_item_loader").show();
1656 //get field view data
1657 loadMapLayerImgTypeDateDDL(16);
1658
1659 //user viewing map data?
1660 if ($(".cvi_date_selected").text().length > 0) {
1661 //close legend panel.
1662 displayLeftDetailsPanel(false);
1663 //remove any farm wide data
1664 img_clearOverlay();
1665
1666 if (tmp_img_lyr_cvi_current_day != "") {
1667 //we have a day so load field view data fo that date.
1668 if (tmp_img_lyr_cvi_current_day.length == 1) {
1669 tmp_img_lyr_cvi_current_day = "0" + tmp_img_lyr_cvi_current_day;
1670 }
1671 if (String(tmp_img_lyr_cvi_current_month).length == 1) {
1672 tmp_img_lyr_cvi_current_month = "0" + tmp_img_lyr_cvi_current_month;
1673 }
1674 var temp_data = tmp_img_lyr_cvi_current_day + "-" + tmp_img_lyr_cvi_current_month + "-" + tmp_img_lyr_cvi_current_yr;
1675
1676 setTimeout(function () {
1677 img_displayImageOverLay(temp_data, 16, im_arr_cvi_fieldView_img_overlay);
1678
1679 }, 500);
1680
1681 setTimeout(function () {
1682 displaySelectedCalDate(temp_data, 16);
1683 }, 1500);
1684 }
1685 }
1686
1687 //empty container with legend
1688 $(".cvi_cal_options_wrapper").empty();
1689});
1690
1691function img_displayImageVarietyOverlay(date, type, variety, varietyName, arr) {
1692
1693 var newDateFormat = date.replace(/-/g, '/');
1694
1695 loadStatus("Loading " + im_getImgLyrTypeName(type, varietyName) + " Data");
1696 $.ajax({
1697 type: "POST",
1698 url: urlPrepend + "/layerdata/imagery/crop-variety-overlay/",
1699 data: { farmId: getFarmId(), imgType: type, varietyId: variety, d: date, seasonId:$("#customerSeason").find(":selected").val() },
1700 }).done(function (data) {
1701
1702 var t = JSON.parse(data);
1703 if (t.length > 0) {
1704
1705 im_bMapDataLoaded = true;
1706 for (var i = 0; i < t.length; i++) {
1707
1708 tempFieldId = t[i].fieldid;
1709 //loop through field polygons to get points for overlay bounds polygon
1710 for (var j = 0; j < polygonsArray.length; j++) {
1711 if (tempFieldId == polygonsArray[j].id) {
1712 var overlayBoundary = new google.maps.MVCArray();
1713 for (var k = 0; k < polygonsArray[j].getPath().getLength() ; k++) {
1714 overlayBoundary.push(new google.maps.LatLng(polygonsArray[j].getPath().getAt(k).lat(), polygonsArray[j].getPath().getAt(k).lng()));
1715 //for map bounds
1716 var coords = polygonsArray[j].getPath().getAt(k);
1717 // latlngbounds.extend(coords);
1718 }
1719 drawOverlay(overlayBoundary, tempFieldId, t[i].image, type, t[i].legend, null, t[i].fieldName, t[i].crop, false);
1720 polygonsArray[j].setMap(null);
1721 }
1722 }
1723
1724 if (i == t.length - 1) {
1725 // map.fitBounds(latlngbounds);
1726 displayOverlay(type);
1727 setTimeout(function () { removeLoader() }, 2000);
1728 }
1729 }
1730 }
1731 else {
1732 setTimeout(function () { removeLoader() }, 2000);
1733 displayErrMsg(txtLy26);
1734 }
1735 });
1736 ////////failed load messsage
1737}
1738
1739
1740$(document).on("click", ".lyr_img_variety_type", function () {
1741 $("#leftDetailsPanel").hide();
1742 im_clrOverlays();
1743 //display any hidden fields
1744 for (var i = 0; i < polygonsArray.length; i++) {
1745 if (polygonsArray[i].getMap() == null) {
1746 polygonsArray[i].setMap(map);
1747 }
1748 }
1749
1750 //is calendar on display - if so destory.
1751 if ($(".lyr_variety_cal").length > 0) {
1752 $(".lyr_variety_cal").datepicker("destroy").remove();
1753 $(".variety_cal_options_wrapper").remove();
1754 }
1755
1756
1757 //set all elements back.
1758 $(this).parent().find(".lyr_variety_view_cal_wrapper").show();
1759 $(this).parent().find(".lyr_variety_view_cal_wrapper").find(".variety_data_loader").show();
1760
1761
1762 var passedImgType = $(this).val();
1763 var passedVarietyId = $(this).attr("name");
1764 var passedVarietyName = $(this).parent().attr("alt");
1765 var calendarEle = $(this).parent
1766 //ajax call to get date to populate calendar
1767
1768 $.ajax({
1769 type: "POST",
1770 url: urlPrepend + "/layerdata/imagery/type/variety/",
1771 data: { tradingId: getTradingId(), farmId: getFarmId(), layerId: passedImgType, varietyId: passedVarietyId },
1772 }).done(function (data) {
1773 var t = JSON.parse(data);
1774
1775
1776 if (passedImgType == 20) {
1777 //MiSAT Variety View
1778 if (t.misatVarietyView.length > 0) {
1779
1780 //if date of different type has been previously selected, then go to date
1781 if (tmp_img_lyr_variety_current_day != "") {
1782 //we have a day so load field view data fo that date.
1783 if (tmp_img_lyr_variety_current_day.length == 1) {
1784 tmp_img_lyr_variety_current_day = "0" + tmp_img_lyr_variety_current_day;
1785 }
1786 if (String(tmp_img_lyr_variety_current_month).length == 1) {
1787 tmp_img_lyr_variety_current_month = "0" + tmp_img_lyr_variety_current_month;
1788 }
1789 var temp_data = tmp_img_lyr_variety_current_day + "-" + tmp_img_lyr_variety_current_month + "-" + tmp_img_lyr_variety_current_yr;
1790
1791 setTimeout(function () {
1792 img_displayImageVarietyOverlay(temp_data, 20, passedVarietyId, passedVarietyName, im_arr_misat_variety_view_img_overlay);
1793 }, 500);
1794
1795 setTimeout(function () {
1796 displaySelectedCalDate(temp_data, 20);
1797 }, 1500);
1798 }
1799
1800
1801
1802 im_arr_misat_variety_view_img_overlay = [];
1803
1804 var tempArrCount = [];
1805 im_arr_misat_variety_dates = [];
1806 im_arr_misat_variety_dates_NoCloudCover = [];
1807 im_arr_misat_variety_dates_HasCloud = [];
1808 im_arr_misat_variety_dates_PartialCloudCover = [];
1809
1810
1811 for (var i = 0; i < t.misatVarietyView.length; i++) {
1812 tempArrCount.push(t.misatVarietyView[i].dateperformed.split(' ')[0]);
1813
1814 if (t.misatVarietyView[i].cloudcover > 0) {
1815 if (t.misatVarietyView[i].cloudcover < 99) {
1816 im_arr_misat_variety_dates_PartialCloudCover.push(t.misatVarietyView[i].dateperformed.split(' ')[0] + "|" + t.misatVarietyView[i].cloudcover);
1817 }
1818 else {
1819 im_arr_misat_variety_dates_HasCloud.push(t.misatVarietyView[i].dateperformed.split(' ')[0] + "|" + t.misatVarietyView[i].cloudcover);
1820 }
1821 }
1822 else {
1823 im_arr_misat_variety_dates_NoCloudCover.push(t.misatVarietyView[i].dateperformed.split(' ')[0] + "|" + t.misatVarietyView[i].cloudcover);
1824 }
1825 }
1826
1827 var uniqueItems = [];
1828 //strip out dups
1829 $.each(tempArrCount, function (i, el) {
1830 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
1831 });
1832
1833
1834 for (var j = 0; j < uniqueItems.length; j++) {
1835
1836 var d = uniqueItems[j].split('/')[0];
1837 var m = uniqueItems[j].split('/')[1];
1838 var y = uniqueItems[j].split('/')[2];
1839
1840 im_arr_misat_variety_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
1841 }
1842
1843
1844 var setDefaultDate = new Date(im_arr_misat_variety_dates[0]);
1845 if ((tmp_img_lyr_variety_current_month != "") && (tmp_img_lyr_variety_current_yr != "")) {
1846 //user has browsed misat calendar months
1847 setDefaultDate = (new Date(tmp_img_lyr_variety_current_month + '/01/' + tmp_img_lyr_variety_current_yr)).toISOString()
1848 }
1849
1850
1851 //get element
1852
1853 $(".lyr_variety_view_cal_wrapper").each(function () {
1854
1855 if ($(this).attr("rel") == passedVarietyId) {
1856
1857 if ($(this).children().length == 1) {
1858 $(this).empty().html("<div class=\"variety_data_loader\"></div><div class=\"variety_cal_options_wrapper\"></div><div class=\"left_panel_calendar lyr_variety_cal\"></div>");
1859 }
1860 else {
1861 $(".lyr_variety_cal").datepicker("destroy");
1862 $(".lyr_variety_view_cal_wrapper").empty().html("<div class=\"variety_data_loader\"></div>");
1863 }
1864 $(this).show();
1865 }
1866 else {
1867 //making sure all other wrapper are empty.
1868 $(this).empty().hide();
1869 }
1870 });
1871
1872 //display calendar
1873 $(".lyr_variety_cal").datepicker({
1874 beforeShowDay: function (date) {
1875 return (im_arr_misat_variety_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_misat_variety_dates_NoCloudCover, im_arr_misat_variety_dates_HasCloud, im_arr_misat_variety_dates_PartialCloudCover)] : [false, ""];
1876 },
1877 dateFormat: "dd-mm-yy",
1878 defaultDate: new Date(setDefaultDate),
1879 minDate: new Date(im_arr_misat_variety_dates[im_arr_misat_variety_dates.length - 1]),
1880 onSelect: function (data) {
1881
1882 img_displayImageVarietyOverlay(data, 20, passedVarietyId, passedVarietyName, im_arr_misat_variety_view_img_overlay);
1883 displaySelectedCalDate(data, 20);
1884 tmp_img_lyr_variety_current_day = data.split('-')[0];
1885 tmp_img_lyr_variety_current_month = data.split('-')[1];
1886 tmp_img_lyr_variety_current_yr = data.split('-')[2];
1887
1888 },
1889 maxDate: '0'
1890 });
1891 $(".variety_cal_options_wrapper").append("<span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_variety_date_selected\"></p>");
1892
1893 }
1894 else {
1895 displayErrMsg(txtLy26);
1896 $(".lyr_variety_cal").datepicker("destroy");
1897 $(".lyr_variety_view_cal_wrapper").empty().html("<div class=\"variety_data_loader\"></div>");
1898 }
1899
1900
1901 }
1902
1903 if (passedImgType == 21) {
1904 //CIgreen Variety View
1905 if (t.cigreenVarietyView.length > 0) {
1906
1907
1908 //if date of different type has been previously selected, then go to date
1909 if (tmp_img_lyr_variety_current_day != "") {
1910 //we have a day so load field view data fo that date.
1911 if (tmp_img_lyr_variety_current_day.length == 1) {
1912 tmp_img_lyr_variety_current_day = "0" + tmp_img_lyr_variety_current_day;
1913 }
1914 if (String(tmp_img_lyr_variety_current_month).length == 1) {
1915 tmp_img_lyr_variety_current_month = "0" + tmp_img_lyr_variety_current_month;
1916 }
1917 var temp_data = tmp_img_lyr_variety_current_day + "-" + tmp_img_lyr_variety_current_month + "-" + tmp_img_lyr_variety_current_yr;
1918
1919 setTimeout(function () {
1920 img_displayImageVarietyOverlay(temp_data, 21, passedVarietyId, passedVarietyName, im_arr_cigreen_variety_view_img_overlay);
1921 }, 500);
1922
1923 setTimeout(function () {
1924 displaySelectedCalDate(temp_data, 21);
1925 }, 1500);
1926 }
1927
1928
1929 im_arr_cigreen_variety_view_img_overlay = [];
1930
1931 var tempArrCount = [];
1932 im_arr_cigreen_variety_dates = [];
1933 im_arr_cigreen_variety_dates_NoCloudCover = [];
1934 im_arr_cigreen_variety_dates_HasCloud = [];
1935 im_arr_cigreen_variety_dates_PartialCloudCover = [];
1936
1937
1938 for (var i = 0; i < t.cigreenVarietyView.length; i++) {
1939 tempArrCount.push(t.cigreenVarietyView[i].dateperformed.split(' ')[0]);
1940
1941 if (t.cigreenVarietyView[i].cloudcover > 0) {
1942 if (t.cigreenVarietyView[i].cloudcover < 99) {
1943 im_arr_cigreen_variety_dates_PartialCloudCover.push(t.cigreenVarietyView[i].dateperformed.split(' ')[0] + "|" + t.cigreenVarietyView[i].cloudcover);
1944 }
1945 else {
1946 im_arr_cigreen_variety_dates_HasCloud.push(t.cigreenVarietyView[i].dateperformed.split(' ')[0] + "|" + t.cigreenVarietyView[i].cloudcover);
1947 }
1948 }
1949 else {
1950 im_arr_cigreen_variety_dates_NoCloudCover.push(t.cigreenVarietyView[i].dateperformed.split(' ')[0] + "|" + t.cigreenVarietyView[i].cloudcover);
1951 }
1952 }
1953
1954 var uniqueItems = [];
1955 //strip out dups
1956 $.each(tempArrCount, function (i, el) {
1957 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
1958 });
1959
1960
1961 for (var j = 0; j < uniqueItems.length; j++) {
1962
1963 var d = uniqueItems[j].split('/')[0];
1964 var m = uniqueItems[j].split('/')[1];
1965 var y = uniqueItems[j].split('/')[2];
1966
1967 im_arr_cigreen_variety_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
1968 }
1969
1970 im_arr_cigreen_variety_dates.sort(function (a, b) {
1971 return new Date(b.date) - new Date(a.date);
1972 });
1973
1974
1975 var setDefaultDate = new Date(im_arr_cigreen_variety_dates[im_arr_cigreen_variety_dates.length - 1]);
1976 if ((tmp_img_lyr_variety_current_month != "") && (tmp_img_lyr_variety_current_yr != "")) {
1977 //user has browsed misat calendar months
1978 setDefaultDate = (new Date(tmp_img_lyr_variety_current_month + '/01/' + tmp_img_lyr_variety_current_yr)).toISOString()
1979 }
1980
1981
1982 $(".lyr_variety_view_cal_wrapper").each(function () {
1983
1984 if ($(this).attr("rel") == passedVarietyId) {
1985
1986 if ($(this).children().length == 1) {
1987 $(this).empty().html("<div class=\"variety_data_loader\"></div><div class=\"variety_cal_options_wrapper\"></div><div class=\"left_panel_calendar lyr_variety_cal\"></div>");
1988 }
1989 else {
1990 $(".lyr_variety_cal").datepicker("destroy");
1991 $(".lyr_variety_view_cal_wrapper").empty().html("<div class=\"variety_data_loader\"></div>");
1992 }
1993 $(this).show();
1994 }
1995 else {
1996 //making sure all other wrapper are empty.
1997 $(this).empty().hide();
1998 }
1999 });
2000
2001 //display calendar
2002 $(".lyr_variety_cal").datepicker({
2003 beforeShowDay: function (date) {
2004 return (im_arr_cigreen_variety_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_cigreen_variety_dates_NoCloudCover, im_arr_cigreen_variety_dates_HasCloud, im_arr_cigreen_variety_dates_PartialCloudCover)] : [false, ""];
2005 },
2006 dateFormat: "dd-mm-yy",
2007 defaultDate: new Date(setDefaultDate),
2008 minDate: new Date(im_arr_cigreen_variety_dates[0]),
2009 onSelect: function (data) {
2010
2011 img_displayImageVarietyOverlay(data, 21, passedVarietyId, passedVarietyName, im_arr_cigreen_variety_view_img_overlay)
2012 displaySelectedCalDate(data, 21);
2013 tmp_img_lyr_variety_current_day = data.split('-')[0];
2014 tmp_img_lyr_variety_current_month = data.split('-')[1];
2015 tmp_img_lyr_variety_current_yr = data.split('-')[2];
2016 },
2017 maxDate: '0'
2018 });
2019 $(".variety_cal_options_wrapper").append("<span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_variety_date_selected\"></p>");
2020
2021
2022 }
2023 else {
2024 displayErrMsg(txtLy26);
2025 $(".lyr_variety_cal").datepicker("destroy");
2026 $(".lyr_variety_view_cal_wrapper").empty().html("<div class=\"variety_data_loader\"></div>");
2027 }
2028 im_arr_cigreen_variety_View_img_overlay = [];
2029 }
2030
2031
2032
2033
2034 });
2035
2036
2037 //add loader
2038 var passedImgType = $(this).val()
2039
2040});
2041
2042$(document).on("click", ".crp_lyr_field_crp_variety_colour_bar", function () {
2043 im_clrOverlays();
2044 //display any hidden fields
2045 for (var i = 0; i < polygonsArray.length; i++) {
2046 if (polygonsArray[i].getMap() == null) {
2047 polygonsArray[i].setMap(map);
2048 }
2049 }
2050 $("#leftDetailsPanel").hide();
2051 var selectedEle = $(this).attr("rel");
2052
2053 $(".lyr_variety_view_wrapper").each(function () {
2054 if ($(this).attr("rel") == selectedEle) {
2055 if ($(this).is(":visible")) {
2056 $(this).hide();
2057 }
2058 else {
2059 $(this).show();
2060 }
2061 $(this).children().prop("checked", false);
2062 }
2063 else {
2064 $(this).hide();
2065 }
2066 });
2067
2068 //clear any previous variety views
2069 $(".lyr_variety_view_cal_wrapper").each(function () {
2070 $(this).empty().html("<div class=\"variety_data_loader\"></div>");
2071 });
2072});
2073
2074function loadVarietyList() {
2075
2076 //reset temp date values
2077 tmp_img_lyr_variety_current_day = "";
2078 tmp_img_lyr_variety_current_month = "";
2079 tmp_img_lyr_variety_current_yr = "";
2080
2081
2082 $.ajax({
2083 type: "POST",
2084 url: urlPrepend + "/layerdata/imagery/crop-variety/",
2085 data: { tradingId: getTradingId(), farmId: getFarmId() },
2086 }).done(function (data) {
2087 var t = JSON.parse(data);
2088 str = "<div class=\"crp_lyr_varieties_title_wrapper\">";
2089 if (t.length > 0) {
2090 for (var i = 0; i < t.length; i++) {
2091 if (t[i].crpVarName != "") {
2092 str += "<span rel=\"" + t[i].id + "\" class=\"crp_lyr_field_crp_variety_colour_bar\" style=\"cursor:pointer;margin-top: 2px;height:13px;width:44px;background-color:" + t[i].crpVarColor + "\" title=\"Click here for viewing options.\"></span><span class=\"crp_field_crp_variety_colour\">" + t[i].crpVarName + "<i class=\"crp_dislaying_variety glyphicon glyphicon-eye-open\" style=\"display:none\"></i></span><div rel=\"" + t[i].id + "\" style=\"border:1px solid " + t[i].crpVarColor + ";\"";
2093 str += "class=\"lyr_variety_view_wrapper\" alt=\"" + t[i].crpVarName + "\"><input class=\"lyr_img_variety_type\" name=\"" + t[i].id + "\" type=\"radio\" value=\"20\" id=\"MiSat" + t[i].id + "\" /><label for=\"MiSat" + t[i].id + "\">MiSat</label><br/><input class=\"lyr_img_variety_type\" name=\"" + t[i].id + "\" type=\"radio\" value=\"21\" id=\"CIgreen" + t[i].id + "\" /><label for=\"CIgreen" + t[i].id + "\">CIgreen</label><div class=\"lyr_variety_view_cal_wrapper\" rel=\"" + t[i].id + "\"><div class=\"variety_data_loader\"></div></div></div>";
2094 }
2095 }
2096
2097 str += "<span style=\"clear:left\"></span></div>"
2098
2099 if ($("#leftPanelVarietyList").length == 0) {
2100 $(".layerInfo").each(function () {
2101
2102 if ($(this).attr("rel") == 20) {
2103 $(this).html("<div id=\"leftPanelVarietyList\"></div>");
2104 }
2105 });
2106 }
2107
2108 $("#leftPanelVarietyList").empty().html(str).show();
2109 $("#leftPanelVarietyList").parent().show();
2110 }
2111 else {
2112 displayErrMsg(txtLy25);
2113 $(".imagery_layer_variety_view").removeClass("layer_item_selected");
2114
2115 $(".lyr_img_variety_type").each(function () {
2116 $(this).prop("checked", false);
2117 });
2118
2119 }
2120
2121 $(".layer_item_loader").hide();
2122
2123 });
2124}
2125
2126$(document).on("click", ".ui-datepicker-header > .ui-datepicker-prev", function (event, fireEv) {
2127 if ($('.ui-datepicker-prev:visible').parent().parent().parent().hasClass('left_panel_calendar') === false) { // if the event we triggered is not part of the left_panel layers;
2128 return;
2129 }
2130
2131 var currentDatePicker = $('.ui-datepicker-prev:visible').parent().parent().parent();
2132 var dpClasses = currentDatePicker.attr("class").split(/\s+/);
2133 if (dpClasses[1].includes('cal') === false) { // if the event we triggered passed the first check but shouldnt be allowed to check for empty months.
2134 return;
2135 }
2136
2137 if (fireEv === undefined) {
2138 fireEv = { fire: true, anyActiveDays: false }
2139 }
2140 if (fireEv.fire === true) {
2141 if ($('.ui-datepicker-prev:visible').hasClass('ui-state-disabled')) {
2142 fireEv.anyActiveDays = true;
2143 fireEv.fire = false;
2144 } else {
2145 let firstClassDatePickerName = dpClasses[1];
2146 $('.' + firstClassDatePickerName + ' > .ui-datepicker-inline > table > tbody > tr > td').each(function (index, value) { // if active days are found, this should stop the recursion;
2147 if($(value).hasClass("ui-datepicker-unselectable") === false && $(value).hasClass("ui-state-disabled") === false){
2148 fireEv.fire = false;
2149 fireEv.anyActiveDays = true;
2150 return false;
2151 }
2152 });
2153
2154 if (fireEv.anyActiveDays == false) { // if no active days for this month are found, enter function again;
2155 $('.ui-datepicker-prev:visible').trigger('click', { fire: true, anyActiveDays: false })
2156 }
2157 }
2158 }
2159});
2160
2161
2162/// <summary>Clicking /next/ button on the calendar, this function allows it to skip the empty months</summary>
2163$(document).on("click", ".ui-datepicker-header > .ui-datepicker-next", function (event, fireEv) {
2164 if ($('.ui-datepicker-next:visible').parent().parent().parent().hasClass('left_panel_calendar') === false) { // if the event we triggered is not part of the left_panel layers;
2165 return;
2166 }
2167
2168 var currentDatePicker = $('.ui-datepicker-next:visible').parent().parent().parent();
2169 var dpClasses = currentDatePicker.attr("class").split(/\s+/);
2170 if(dpClasses[1].includes('cal') === false){ // if the event we triggered passed the first check but shouldnt be allowed to check for empty months.
2171 return;
2172 }
2173
2174 if (fireEv === undefined) {
2175 fireEv = { fire: true, anyActiveDays: false }
2176 }
2177 if (fireEv.fire === true) {
2178 if ($('.ui-datepicker-next:visible').hasClass('ui-state-disabled')) {
2179 let firstClassDatePickerName = dpClasses[1];
2180 $('.' + firstClassDatePickerName + ' > .ui-datepicker-inline > table > tbody > tr > td').each(function (index, value) { // if active days are found, this should stop the recursion;
2181 if ($(value).hasClass("ui-datepicker-unselectable") === false && $(value).hasClass("ui-state-disabled") === false) {
2182 fireEv.fire = false;
2183 fireEv.anyActiveDays = true;
2184 return false;
2185 }
2186 });
2187
2188 if (fireEv.anyActiveDays === false) {
2189 if ($('.layer-calendar-no-more-data:visible').length === 0) {
2190 currentDatePicker.append("<p class='layer-calendar-no-more-data'>There is no more data to be shown</p>")
2191 $('.layer-calendar-no-more-data:visible').fadeOut(3000);
2192 }
2193
2194 $('.ui-datepicker-prev:visible').trigger('click', { fire: true, anyActiveDays: false })
2195 }
2196 } else {
2197 let firstClassDatePickerName = dpClasses[1];
2198 $('.' + firstClassDatePickerName + ' > .ui-datepicker-inline > table > tbody > tr > td').each(function (index, value) { // if active days are found, this should stop the recursion;
2199 if ($(value).hasClass("ui-datepicker-unselectable") === false && $(value).hasClass("ui-state-disabled") === false) {
2200 fireEv.fire = false;
2201 fireEv.anyActiveDays = true;
2202 return false;
2203 }
2204 });
2205
2206 if (fireEv.anyActiveDays == false) { // if no active days for this month are found, enter function again;
2207 $('.ui-datepicker-next:visible').trigger('click', { fire: true, anyActiveDays: false })
2208 }
2209 }
2210 }
2211});
2212
2213function loadMapLayerImgTypeDateDDL(id) {
2214 img_clearOverlay();
2215
2216 if (!im_bImgTypeDatesAjax_loading) {
2217
2218 im_bImgTypeDatesAjax_loading = true;
2219 debugger;
2220 $.ajax({
2221 type: "POST",
2222 url: urlPrepend + "/layerdata/imagery/type/",
2223 data: { tradingId: getTradingId(), farmId: getFarmId(), layerId: id },
2224 }).done(function (data) {
2225
2226 $(".layer_item_loader").hide();
2227 var t = JSON.parse(data);
2228
2229 if (id == 1) {
2230 debugger;
2231 //n-sensor
2232 im_arr_n_sensor_NAS_dates = [];
2233 im_arr_n_sensor_BI_dates = [];
2234 im_arr_n_sensor_N_dates = [];
2235
2236 var tempArrCount = [];
2237 for (var i = 0; i < t.nsensor.length; i++) {
2238 tempArrCount.push(t.nsensor[i].subtype != "" ? t.nsensor[i].dateperformed.split(' ')[0] + " - " + t.nsensor[i].subtype : t.nsensor[i].dateperformed.split(' ')[0]);
2239 }
2240
2241 var uniqueItems = [];
2242 //strip out dups
2243 $.each(tempArrCount, function (i, el) {
2244 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2245 });
2246
2247 for (var j = 0; j < uniqueItems.length; j++) {
2248 var d = uniqueItems[j].split('|')[0].split(' - ')[0].split('/')[0];
2249 var m = uniqueItems[j].split('|')[0].split(' - ')[0].split('/')[1];
2250 var y = uniqueItems[j].split('|')[0].split(' - ')[0].split('/')[2];
2251
2252 if((uniqueItems[j].split('|')[0].split(' - ')[1] == "NAS")){
2253 im_arr_n_sensor_NAS_dates.push((new Date(m + '/' + d + '/' + y)).toISOString())
2254 } else if((uniqueItems[j].split('|')[0].split(' - ')[1] == "BI")) {
2255 im_arr_n_sensor_BI_dates.push((new Date(m + '/' + d + '/' + y)).toISOString())
2256 } else {
2257 im_arr_n_sensor_N_dates.push((new Date(m + '/' + d + '/' + y)).toISOString())
2258 }
2259 //(uniqueItems[j].split('|')[0].split(' - ')[1] == "NAS" ? im_arr_n_sensor_NAS_dates.push((new Date(m + '/' + d + '/' + y)).toISOString()) : (uniqueItems[j].split('|')[0].split(' - ')[1] == "BI" ? im_arr_n_sensor_BI_dates.push((new Date(m + '/' + d + '/' + y)).toISOString()) : im_arr_n_sensor_N_dates.push((new Date(m + '/' + d + '/' + y)).toISOString())))
2260 }
2261
2262 // if there is no date in either of the date arrays, a default one(todays date) will be added in order to set min date of the calendar.
2263 if (im_arr_n_sensor_NAS_dates.length === 0) {
2264 let dateNow = Date.now();
2265 im_arr_n_sensor_NAS_dates.push(new Date(dateNow).toISOString());
2266 }
2267 if (im_arr_n_sensor_BI_dates.length === 0) {
2268 let dateNow = Date.now();
2269 im_arr_n_sensor_BI_dates.push(new Date(dateNow).toISOString());
2270 }
2271 if (im_arr_n_sensor_N_dates.length === 0) {
2272 let dateNow = Date.now();
2273 im_arr_n_sensor_N_dates.push(new Date(dateNow).toISOString());
2274 }
2275
2276 $(".layerInfo").each(function () {
2277 if ($(this).attr("rel") == id) {
2278 $(this).show();
2279 if ($(this).children().length == 0) {
2280 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"nsensor_cal_options_wrapper\"></div><div class=\"left_panel_calendar n_sensor_cal\"></div></div>");
2281 }
2282 $(this).children().show();
2283 }
2284 });
2285
2286 //display calendar
2287 $(".n_sensor_cal").datepicker({
2288 beforeShowDay: function (date) {
2289 return (im_arr_n_sensor_BI_dates.indexOf(date.toISOString()) > -1) ? [true, "n_sensor_calendar_date_BI"] : [false, ""];
2290 },
2291 dateFormat: "dd-mm-yy",
2292 defaultDate: new Date(im_arr_n_sensor_BI_dates[0]),
2293 minDate: new Date(im_arr_n_sensor_BI_dates[im_arr_n_sensor_BI_dates.length - 1]),
2294 onSelect: function (data) {
2295 img_displayImageOverLaySubType(data, 1, 6, im_arr_nsensor_overlay);
2296 displaySelectedCalDate(data, 1);
2297 },
2298 maxDate: '0'
2299 });
2300
2301
2302 //insert calendar options
2303 $(".nsensor_cal_options_wrapper").append("<span class=\"n-sensor_calendar_radio_but_BI\" title=\"View N-Sensor BI Calendar.\"></span><input type=\"radio\" name=\"nsensor_cal_options\" class=\"nsensor_cal_options\" value=\"BI\" id=\"nsensor_cal_options_BI\" checked=\"checked\" /><label for=\"nsensor_cal_options_BI\">BI</label><br/><span class=\"n-sensor_calendar_radio_but_NAS\" title=\"View N-Sensor NAS Calendar.\"></span><input type=\"radio\" name=\"nsensor_cal_options\" id=\"nsensor_cal_options_NAS\" class=\"nsensor_cal_options\" value=\"NAS\"/><label for=\"nsensor_cal_options_NAS\">NAS</label><br/><span class=\"n-sensor_calendar_radio_but_N\" title=\"View N-Sensor N Calendar.\"></span><input type=\"radio\" name=\"nsensor_cal_options\" class=\"nsensor_cal_options\" value=\"N\" id=\"nsensor_cal_options_N\" /><label for=\"nsensor_cal_options_N\">N</label><p class=\"n-sensor_date_selected\"></p>");
2304
2305 if ($('.n_sensor_cal > .layer-calendar-skip-months').length === 0) {
2306 $(".n_sensor_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
2307 $('.layer-calendar-skip-months:visible').fadeOut(5000);
2308 }
2309 }
2310
2311 if (id == 2) {
2312 //fvat -- misat
2313 if ($(".misat_data_loader").is(":visible")) {
2314 $(".misat_data_loader").hide();
2315 }
2316 debugger;
2317
2318 im_arr_misat_overlay = [];
2319
2320 var tempArrCount = [];
2321 im_arr_fvat_dates = [];
2322 im_arr_fvat_dates_NoCloudCover = [];
2323 im_arr_fvat_dates_HasCloud = [];
2324 im_arr_fvat_dates_PartialCloudCover = [];
2325
2326 for (var i = 0; i < t.misat.length; i++) {
2327 tempArrCount.push(t.misat[i].dateperformed.split(' ')[0]);
2328
2329 if (t.misat[i].cloudcover > 0) {
2330 if (t.misat[i].cloudcover < 99) {
2331 im_arr_fvat_dates_PartialCloudCover.push(t.misat[i].dateperformed.split(' ')[0] + "|" + t.misat[i].cloudcover);
2332 }
2333 else {
2334 im_arr_fvat_dates_HasCloud.push(t.misat[i].dateperformed.split(' ')[0] + "|" + t.misat[i].cloudcover);
2335 }
2336 }
2337 else {
2338 im_arr_fvat_dates_NoCloudCover.push(t.misat[i].dateperformed.split(' ')[0] + "|" + t.misat[i].cloudcover);
2339 }
2340 }
2341
2342 debugger;
2343
2344 var uniqueItems = [];
2345 //strip out dups
2346 $.each(tempArrCount, function (i, el) {
2347 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2348 });
2349
2350
2351 for (var j = 0; j < uniqueItems.length; j++) {
2352
2353 var d = uniqueItems[j].split('/')[0];
2354 var m = uniqueItems[j].split('/')[1];
2355 var y = uniqueItems[j].split('/')[2];
2356
2357 im_arr_fvat_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
2358
2359 }
2360 debugger;
2361
2362 $(".layerInfo").each(function () {
2363
2364 if ($(this).attr("rel") == id) {
2365 debugger;
2366
2367 $(this).show();
2368 if ($(this).children().length == 0) {
2369 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"misat_data_loader\"></div><div class=\"misat_cal_options_wrapper\"></div><div class=\"left_panel_calendar misat_cal\"></div></div>");
2370 }
2371 $(this).children().show();
2372 }
2373 });
2374
2375 var setDefaultDate = new Date(im_arr_fvat_dates[0]);
2376 debugger;
2377
2378 if ((tmp_img_lyr_misat_current_month != "") && (tmp_img_lyr_misat_current_yr != "")) {
2379 //user has browsed misat calendar months
2380 setDefaultDate = (new Date(tmp_img_lyr_misat_current_month + '/01/' + tmp_img_lyr_misat_current_yr)).toISOString();
2381 }
2382 debugger;
2383
2384 //display calendar
2385 $(".misat_cal").datepicker({
2386 beforeShowDay: function (date) {
2387 return (im_arr_fvat_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_fvat_dates_NoCloudCover, im_arr_fvat_dates_HasCloud, im_arr_fvat_dates_PartialCloudCover)] : [false, ""];
2388 },
2389 dateFormat: "dd-mm-yy",
2390 defaultDate: new Date(setDefaultDate),
2391 minDate: new Date(im_arr_fvat_dates[im_arr_fvat_dates.length - 1]),
2392 onSelect: function (data) {
2393 img_displayImageOverLay(data, 2, im_arr_misat_overlay);
2394 displaySelectedCalDate(data, 2);
2395 tmp_img_lyr_misat_current_day = data.split('-')[0];
2396 tmp_img_lyr_misat_current_month = data.split('-')[1];
2397 tmp_img_lyr_misat_current_yr = data.split('-')[2];
2398 },
2399 maxDate: '0',
2400 onChangeMonthYear:function (year, month) {
2401 tmp_img_lyr_misat_current_month = month;
2402 tmp_img_lyr_misat_current_yr = year;
2403 }
2404 });
2405 debugger;
2406
2407 //insert calendar options
2408 //we need to find out if this las been locked from previous actions.
2409 var checkIsLayerLocked = false;
2410 $(".layerInfo").each(function () {
2411
2412 if ($(this).attr("rel") == id && $(this).hasClass("lyr_locked")) {
2413 checkIsLayerLocked = true
2414 }
2415 });
2416 debugger;
2417
2418 if (!checkIsLayerLocked) {
2419 if ($('.imagery_layer_cigreen').find('.lyr_lock').length === 0) {
2420 $('.imagery_layer_cigreen ').append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div></div>");
2421 }
2422 $(".misat_cal_options_wrapper").append("<div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFarmView\">Farm View</label><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" /><label for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
2423 }
2424 else {
2425 if ($('.imagery_layer_cigreen').find('.lyr_lock').length === 0) {
2426 $('.imagery_layer_cigreen ').append("<div class=\"lyr_lock\"><div class=\"glyphicon lyr_locked_icon icon-noun_Lock_747565 lyr_lock_red\"></div></div>");
2427 }
2428 $(".misat_cal_options_wrapper").append("<div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFarmView\">Farm View</label><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" /><label for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
2429 }
2430 //before lock button changes
2431 //if (!checkIsLayerLocked) {
2432 // $(".misat_cal_options_wrapper").append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div><div class=\"lyr_lock_txt\">Lock this layer</div></div><div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFarmView\">Farm View</label><br/><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" /><label for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
2433 //}
2434 //else {
2435 // $(".misat_cal_options_wrapper").append("<div class=\"lyr_lock\"><div class=\"glyphicon lyr_locked_icon icon-noun_Lock_747565 lyr_lock_red\"></div><div class=\"lyr_lock_txt\">Layer is locked!</div></div><div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFarmView\">Farm View</label><br/><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" /><label for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
2436 //}
2437
2438 if ($('.misat_cal > .layer-calendar-skip-months').length === 0) {
2439 $(".misat_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
2440 $('.layer-calendar-skip-months:visible').fadeOut(5000);
2441 }
2442 }
2443
2444 // old working copy of misat
2445 //if (id == 2) {
2446 // //fvat -- misat
2447 // if ($(".misat_data_loader").is(":visible")) {
2448 // $(".misat_data_loader").hide();
2449 // }
2450 // debugger;
2451
2452 // im_arr_misat_overlay = [];
2453
2454 // var tempArrCount = [];
2455 // im_arr_fvat_dates = [];
2456 // im_arr_fvat_dates_NoCloudCover = [];
2457 // im_arr_fvat_dates_HasCloud = [];
2458 // im_arr_fvat_dates_PartialCloudCover = [];
2459
2460 // for (var i = 0; i < t.misat.length; i++) {
2461 // tempArrCount.push(t.misat[i].dateperformed.split(' ')[0]);
2462
2463 // if (t.misat[i].cloudcover > 0) {
2464 // if (t.misat[i].cloudcover < 99) {
2465 // im_arr_fvat_dates_PartialCloudCover.push(t.misat[i].dateperformed.split(' ')[0] + "|" + t.misat[i].cloudcover);
2466 // }
2467 // else {
2468 // im_arr_fvat_dates_HasCloud.push(t.misat[i].dateperformed.split(' ')[0] + "|" + t.misat[i].cloudcover);
2469 // }
2470 // }
2471 // else {
2472 // im_arr_fvat_dates_NoCloudCover.push(t.misat[i].dateperformed.split(' ')[0] + "|" + t.misat[i].cloudcover);
2473 // }
2474 // }
2475
2476
2477 // var uniqueItems = [];
2478 // //strip out dups
2479 // $.each(tempArrCount, function (i, el) {
2480 // if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2481 // });
2482
2483
2484 // for (var j = 0; j < uniqueItems.length; j++) {
2485
2486 // var d = uniqueItems[j].split('/')[0];
2487 // var m = uniqueItems[j].split('/')[1];
2488 // var y = uniqueItems[j].split('/')[2];
2489
2490 // im_arr_fvat_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
2491
2492 // }
2493 // $(".layerInfo").each(function () {
2494
2495 // if ($(this).attr("rel") == id) {
2496 // $(this).show();
2497 // if ($(this).children().length == 0) {
2498 // $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"misat_data_loader\"></div><div class=\"misat_cal_options_wrapper\"></div><div class=\"left_panel_calendar misat_cal\"></div></div>");
2499 // }
2500 // $(this).children().show();
2501 // }
2502 // });
2503
2504 // var setDefaultDate = new Date(im_arr_fvat_dates[0]);
2505
2506 // if ((tmp_img_lyr_misat_current_month != "") && (tmp_img_lyr_misat_current_yr != "")) {
2507 // //user has browsed misat calendar months
2508 // setDefaultDate = (new Date(tmp_img_lyr_misat_current_month + '/01/' + tmp_img_lyr_misat_current_yr)).toISOString();
2509 // }
2510
2511 // //display calendar
2512 // $(".misat_cal").datepicker({
2513 // beforeShowDay: function (date) {
2514 // return (im_arr_fvat_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_fvat_dates_NoCloudCover, im_arr_fvat_dates_HasCloud, im_arr_fvat_dates_PartialCloudCover)] : [false, ""];
2515 // },
2516 // dateFormat: "dd-mm-yy",
2517 // defaultDate: new Date(setDefaultDate),
2518 // minDate: new Date(im_arr_fvat_dates[im_arr_fvat_dates.length - 1]),
2519 // onSelect: function (data) {
2520 // img_displayImageOverLay(data, 2, im_arr_misat_overlay);
2521 // displaySelectedCalDate(data, 2);
2522 // tmp_img_lyr_misat_current_day = data.split('-')[0];
2523 // tmp_img_lyr_misat_current_month = data.split('-')[1];
2524 // tmp_img_lyr_misat_current_yr = data.split('-')[2];
2525 // },
2526 // maxDate: '0',
2527 // onChangeMonthYear:function (year, month) {
2528 // tmp_img_lyr_misat_current_month = month;
2529 // tmp_img_lyr_misat_current_yr = year;
2530 // }
2531 // });
2532
2533 // //insert calendar options
2534 // //we need to find out if this las been locked from previous actions.
2535 // var checkIsLayerLocked = false;
2536 // $(".layerInfo").each(function () {
2537
2538 // if ($(this).attr("rel") == id && $(this).hasClass("lyr_locked")) {
2539 // checkIsLayerLocked = true
2540 // }
2541 // });
2542
2543 // if (!checkIsLayerLocked) {
2544 // $(".misat_cal_options_wrapper").append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div><div class=\"lyr_lock_txt\">Lock this layer</div></div><div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFarmView\">Farm View</label><br/><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" /><label for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
2545 // }
2546 // else {
2547 // $(".misat_cal_options_wrapper").append("<div class=\"lyr_lock\"><div class=\"glyphicon lyr_locked_icon icon-noun_Lock_747565 lyr_lock_red\"></div><div class=\"lyr_lock_txt\">Layer is locked!</div></div><div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFarmView\">Farm View</label><br/><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" /><label for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
2548 // }
2549
2550 // if ($('.misat_cal > .layer-calendar-skip-months').length === 0) {
2551 // $(".misat_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
2552 // $('.layer-calendar-skip-months:visible').fadeOut(5000);
2553 // }
2554 //}
2555
2556 if (id == 3) {
2557 //rtk
2558 im_arr_rtk_overlay = [];
2559
2560 var tempArrCount = [];
2561 var tempArrRtkdate = [];
2562 for (var i = 0; i < t.rtk.length; i++) {
2563 tempArrCount.push(t.rtk[i].dateperformed.split(' ')[0]);
2564 }
2565
2566 var uniqueItems = [];
2567 //strip out dups
2568 $.each(tempArrCount, function (i, el) {
2569 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2570 });
2571
2572 for (var j = 0; j < uniqueItems.length; j++) {
2573
2574 var d = uniqueItems[j].split('/')[0];
2575 var m = uniqueItems[j].split('/')[1];
2576 var y = uniqueItems[j].split('/')[2];
2577
2578 tempArrRtkdate.push((new Date(m + '/' + d + '/' + y)).toISOString());
2579
2580 }
2581 $(".layerInfo").each(function () {
2582 if ($(this).attr("rel") == id) {
2583 $(this).show();
2584 if ($(this).children().length == 0) {
2585 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"rtk_cal_options_wrapper\"></div><div class=\"left_panel_calendar rtk_cal\"></div></div>");
2586 }
2587 $(this).children().show();
2588 }
2589 });
2590
2591
2592 //display calendar
2593 $(".rtk_cal").datepicker({
2594 beforeShowDay: function (date) {
2595 return (tempArrRtkdate.indexOf(date.toISOString()) > -1) ? [true, "conductivity_calendar_date_Diff"] : [false, ""];
2596 },
2597 dateFormat: "dd-mm-yy",
2598 defaultDate: new Date(tempArrRtkdate[0]),
2599 minDate: new Date(tempArrRtkdate[tempArrRtkdate.length - 1]),
2600 onSelect: function (data) {
2601 img_displayImageOverLay(data, 3, im_arr_rtk_overlay);
2602 displaySelectedCalDate(data, 3);
2603 },
2604 maxDate: '0'
2605 });
2606
2607
2608 //insert calendar options
2609 $(".rtk_cal_options_wrapper").append("<p class=\"rtk_date_selected\"></p>");
2610
2611 if ($('.rtk_cal > .layer-calendar-skip-months').length === 0) {
2612 $(".rtk_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
2613 $('.layer-calendar-skip-months:visible').fadeOut(5000);
2614 }
2615 }
2616
2617 if (id == 4) {
2618 //uav
2619 im_arr_uav_overlay = [];
2620
2621 var tempArrCount = [];
2622 var tempArrUavdate = [];
2623 for (var i = 0; i < t.uav.length; i++) {
2624 tempArrCount.push(t.uav[i].dateperformed.split(' ')[0]);
2625 }
2626
2627 var uniqueItems = [];
2628 //strip out dups
2629 $.each(tempArrCount, function (i, el) {
2630 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2631 });
2632
2633 for (var j = 0; j < uniqueItems.length; j++) {
2634
2635 var d = uniqueItems[j].split('/')[0];
2636 var m = uniqueItems[j].split('/')[1];
2637 var y = uniqueItems[j].split('/')[2];
2638
2639 tempArrUavdate.push((new Date(m + '/' + d + '/' + y)).toISOString());
2640
2641 }
2642 $(".layerInfo").each(function () {
2643 if ($(this).attr("rel") == id) {
2644 $(this).show();
2645 if ($(this).children().length == 0) {
2646 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"uav_cal_options_wrapper\"></div><div class=\"left_panel_calendar uav_cal\"></div></div>");
2647 }
2648 $(this).children().show();
2649 }
2650 });
2651
2652 //display calendar
2653 $(".uav_cal").datepicker({
2654 beforeShowDay: function (date) {
2655 return (tempArrUavdate.indexOf(date.toISOString()) > -1) ? [true, ""] : [false, ""];
2656 },
2657 dateFormat: "dd-mm-yy",
2658 defaultDate: new Date(tempArrUavdate[0]),
2659 minDate: new Date(tempArrUavdate[tempArrUavdate.length - 1]),
2660 onSelect: function (data) {
2661 img_displayImageOverLay(data, 4, im_arr_uav_overlay);
2662 displaySelectedCalDate(data, 4);
2663 },
2664 maxDate: '0'
2665 });
2666
2667
2668 //insert calendar options
2669 $(".uav_cal_options_wrapper").append("<p class=\"uav_date_selected\"></p>");
2670
2671 if ($('.uav_cal > .layer-calendar-skip-months').length === 0) {
2672 $(".uav_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
2673 $('.layer-calendar-skip-months:visible').fadeOut(5000);
2674 }
2675
2676 }
2677
2678 if (id == 6) {
2679 //conductivity
2680 im_arr_conductivity_overlay = [];
2681
2682
2683 im_arr_conductivity_Diff_dates = [];
2684 im_arr_conductivity_Shallow_dates = [];
2685 im_arr_conductivity_Deep_dates = [];
2686
2687
2688 var tempArrCount = [];
2689 for (var i = 0; i < t.conductivity.length; i++) {
2690 tempArrCount.push(t.conductivity[i].dateperformed);
2691 }
2692
2693 var uniqueItems = [];
2694 //strip out dups
2695 $.each(tempArrCount, function (i, el) {
2696 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2697 });
2698
2699
2700 var strConductivityTxt = " Conductivity data from " + uniqueItems[uniqueItems.length - 1] + " to " + uniqueItems[0];
2701
2702 $(".layerInfo").each(function () {
2703
2704 if ($(this).attr("rel") == id) {
2705 $(this).show();
2706 $(this).empty().html("<div id=\"leftPanelDatePickerWrapper\"><input type=\"radio\" name=\"conductivity_cal_options\" class=\"conductivity_cal_options\" value=\"Shall\" id=\"conductivity_cal_options_Shall\"/><label for=\"conductivity_cal_options_Shall\">EM Shallow</label><span class=\"conductivity_calendar_radio_but_Shall\" title=\"View Conductivity EM Shallow Calendar.\"></span><br/><input type=\"radio\" name=\"conductivity_cal_options\" id=\"conductivity_cal_options_Deep\" class=\"conductivity_cal_options\" value=\"Deep\" /><label for=\"conductivity_cal_options_Deep\">EM Deep</label><span class=\"conductivity_calendar_radio_but_Deep\" title=\"View Conductivity EM Deep Calendar.\"></span><br/><input type=\"radio\" name=\"conductivity_cal_options\" id=\"conductivity_cal_options_Diff\" class=\"conductivity_cal_options\" value=\"DIFF\" /><label for=\"conductivity_cal_options_Diff\">EM Difference</label><span class=\"conductivity_calendar_radio_but_Diff\" title=\"View Conductivity EM Difference Calendar.\"></span><p class=\"conductivity_date_selected\"><span class=\"conductivity_subtype\"></span>" + strConductivityTxt + "</p>");
2707 $(this).children().show();
2708 }
2709 });
2710
2711
2712
2713 }
2714
2715 if (id == 7) {
2716 debugger;
2717 //migrass
2718 im_arr_migrass_overlay = [];
2719
2720 var tempArrCount = [];
2721 im_arr_ndmi_dates = [];
2722 im_arr_ndmi_dates_NoCloudCover = [];
2723 im_arr_ndmi_dates_HasCloud = [];
2724 im_arr_ndmi_dates_PartialCloudCover = [];
2725
2726
2727 for (var i = 0; i < t.migrass.length; i++) {
2728 tempArrCount.push(t.migrass[i].dateperformed.split(' ')[0]);
2729
2730 if (t.migrass[i].cloudcover > 0) {
2731 if (t.migrass[i].cloudcover < 99) {
2732 im_arr_ndmi_dates_PartialCloudCover.push(t.migrass[i].dateperformed.split(' ')[0] + "|" + t.migrass[i].cloudcover);
2733 }
2734 else {
2735 im_arr_ndmi_dates_HasCloud.push(t.migrass[i].dateperformed.split(' ')[0] + "|" + t.migrass[i].cloudcover);
2736 }
2737 }
2738 else {
2739 im_arr_ndmi_dates_NoCloudCover.push(t.migrass[i].dateperformed.split(' ')[0] + "|" + t.migrass[i].cloudcover);
2740 }
2741 }
2742
2743 var uniqueItems = [];
2744 //strip out dups
2745 $.each(tempArrCount, function (i, el) {
2746 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2747 });
2748
2749
2750 for (var j = 0; j < uniqueItems.length; j++) {
2751
2752 var d = uniqueItems[j].split('/')[0];
2753 var m = uniqueItems[j].split('/')[1];
2754 var y = uniqueItems[j].split('/')[2];
2755 im_arr_ndmi_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
2756
2757 }
2758 $(".layerInfo").each(function () {
2759
2760 if ($(this).attr("rel") == id) {
2761 $(this).show();
2762 if ($(this).children().length == 0) {
2763 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"migrass_cal_options_wrapper\"></div><div class=\"left_panel_calendar migrass_cal\"></div></div>");
2764 }
2765 $(this).children().show();
2766 }
2767 });
2768
2769 //display calendar
2770 $(".migrass_cal").datepicker({
2771 beforeShowDay: function (date) {
2772 return (im_arr_ndmi_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_ndmi_dates_NoCloudCover, im_arr_ndmi_dates_HasCloud, im_arr_ndmi_dates_PartialCloudCover)] : [false, ""];
2773 },
2774 dateFormat: "dd-mm-yy",
2775 defaultDate: new Date(im_arr_ndmi_dates[0]),
2776 minDate: new Date(im_arr_ndmi_dates[im_arr_ndmi_dates.length - 1]),
2777 onSelect: function (data) {
2778 img_displayImageOverLay(data, 7, im_arr_migrass_overlay);
2779 displaySelectedCalDate(data, 7);
2780 },
2781 maxDate: '0'
2782 });
2783
2784
2785 //insert calendar options
2786 $(".migrass_cal_options_wrapper").append("<span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"migrass_date_selected\"></p>");
2787
2788 if ($('.migrass_cal > .layer-calendar-skip-months').length === 0) {
2789 $(".migrass_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
2790 $('.layer-calendar-skip-months:visible').fadeOut(5000);
2791 }
2792 }
2793
2794 if (id == 8) {
2795 debugger;
2796 //rgb
2797 im_arr_rgb_overlay = [];
2798
2799 var tempArrCount = [];
2800 im_arr_rgb_dates = [];
2801 im_arr_rgb_dates_NoCloudCover = [];
2802 im_arr_rgb_dates_HasCloud = [];
2803 im_arr_rgb_dates_PartialCloudCover = [];
2804
2805 for (var i = 0; i < t.rgb.length; i++) {
2806 tempArrCount.push(t.rgb[i].dateperformed.split(' ')[0]);
2807
2808 if (t.rgb[i].cloudcover > 0) {
2809 if (t.rgb[i].cloudcover < 99) {
2810 im_arr_rgb_dates_PartialCloudCover.push(t.rgb[i].dateperformed.split(' ')[0] + "|" + t.rgb[i].cloudcover);
2811 }
2812 else {
2813 im_arr_rgb_dates_HasCloud.push(t.rgb[i].dateperformed.split(' ')[0] + "|" + t.rgb[i].cloudcover);
2814 }
2815
2816
2817 }
2818 else {
2819 im_arr_rgb_dates_NoCloudCover.push(t.rgb[i].dateperformed.split(' ')[0] + "|" + t.rgb[i].cloudcover);
2820 }
2821 }
2822
2823 debugger;
2824 var uniqueItems = [];
2825 //strip out dups
2826 $.each(tempArrCount, function (i, el) {
2827 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2828 });
2829
2830
2831 for (var j = 0; j < uniqueItems.length; j++) {
2832
2833 var d = uniqueItems[j].split('/')[0];
2834 var m = uniqueItems[j].split('/')[1];
2835 var y = uniqueItems[j].split('/')[2];
2836
2837 im_arr_rgb_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
2838
2839 }
2840 debugger;
2841 $(".layerInfo").each(function () {
2842 debugger;
2843 if ($(this).attr("rel") == id) {
2844 $(this).show();
2845 if ($(this).children().length == 0) {
2846 // use only if layer is closed and opened again - TT
2847 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"rgb_cal_options_wrapper\"></div><div class=\"left_panel_calendar rgb_cal\"></div></div>");
2848 }
2849 $(this).children().show();
2850 }
2851 });
2852
2853 debugger;
2854
2855 //display calendar
2856 $(".rgb_cal").datepicker({
2857 beforeShowDay: function (date) {
2858 return (im_arr_rgb_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_rgb_dates_NoCloudCover, im_arr_rgb_dates_HasCloud, im_arr_rgb_dates_PartialCloudCover)] : [false, ""];
2859 },
2860 dateFormat: "dd-mm-yy",
2861 defaultDate: new Date(im_arr_rgb_dates[0]),
2862 minDate: new Date(im_arr_rgb_dates[im_arr_rgb_dates.length - 1]),
2863 onSelect: function (data) {
2864 img_displayImageOverLay(data, 8, im_arr_rgb_overlay);
2865 displaySelectedCalDate(data, 8);
2866 },
2867 maxDate: '0'
2868 });
2869
2870 debugger;
2871 //insert calendar options
2872 $(".rgb_cal_options_wrapper").append("<span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"rgb_date_selected\"></p>");
2873
2874 if ($('.rgb_cal > .layer-calendar-skip-months').length === 0) {
2875 $(".rgb_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
2876 $('.layer-calendar-skip-months:visible').fadeOut(5000);
2877 }
2878 }
2879
2880 if (id == 9) {
2881 //yield
2882 im_arr_yield_overlay = [];
2883
2884 var tempArrCount = [];
2885 var tempArrYielddate = [];
2886 for (var i = 0; i < t.yield.length; i++) {
2887 tempArrCount.push(t.yield[i].dateperformed.split(' ')[0]);
2888 }
2889
2890 var uniqueItems = [];
2891 //strip out dups
2892 $.each(tempArrCount, function (i, el) {
2893 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2894 });
2895
2896 for (var j = 0; j < uniqueItems.length; j++) {
2897
2898 var d = uniqueItems[j].split('/')[0];
2899 var m = uniqueItems[j].split('/')[1];
2900 var y = uniqueItems[j].split('/')[2];
2901
2902 tempArrYielddate.push((new Date(m + '/' + d + '/' + y)).toISOString());
2903
2904 }
2905 $(".layerInfo").each(function () {
2906 if ($(this).attr("rel") == id) {
2907 $(this).show();
2908 if ($(this).children().length == 0) {
2909 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"yield_cal_options_wrapper\"></div><div class=\"left_panel_calendar yield_cal\"></div></div>");
2910 }
2911 $(this).children().show();
2912 }
2913 });
2914
2915
2916 //display calendar
2917 $(".yield_cal").datepicker({
2918 beforeShowDay: function (date) {
2919 return (tempArrYielddate.indexOf(date.toISOString()) > -1) ? [true, "conductivity_calendar_date_Diff"] : [false, ""];
2920 },
2921 dateFormat: "dd-mm-yy",
2922 defaultDate: new Date(tempArrYielddate[0]),
2923 minDate: new Date(tempArrYielddate[tempArrYielddate.length-1]),
2924 onSelect: function (data) {
2925 img_displayImageOverLay(data, 9, im_arr_yield_overlay);
2926 displaySelectedCalDate(data, 9);
2927 },
2928 maxDate: '0'
2929 });
2930
2931
2932 //insert calendar options
2933 $(".yield_cal_options_wrapper").append("<p class=\"yield_date_selected\"></p>");
2934
2935 if ($('.yield_cal > .layer-calendar-skip-months').length === 0) {
2936 $(".yield_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
2937 $('.layer-calendar-skip-months:visible').fadeOut(5000);
2938 }
2939
2940 }
2941
2942 if (id == 12) {
2943 //c-dax image
2944 im_arr_afbi_cdax_img_overlay = [];
2945
2946 var tempArrCount = [];
2947 var tempArrCdaxImgdate = [];
2948
2949
2950 for (var i = 0; i < t.cdaximg.length; i++) {
2951 tempArrCount.push(t.cdaximg[i].dateperformed);
2952 }
2953
2954 var uniqueItems = [];
2955 //strip out dups
2956 $.each(tempArrCount, function (i, el) {
2957 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
2958 });
2959
2960 for (var j = 0; j < uniqueItems.length; j++) {
2961
2962 var d = uniqueItems[j].split('/')[0];
2963 var m = uniqueItems[j].split('/')[1];
2964 var y = uniqueItems[j].split('/')[2];
2965
2966 tempArrCdaxImgdate.push((new Date(m + '/' + d + '/' + y)).toISOString());
2967
2968 }
2969
2970
2971 var thisLayerId = $(".layer_item_cdax_pasture_img").attr("id");
2972
2973 $(".layerInfo").each(function () {
2974 if ($(this).attr("rel") == thisLayerId) {
2975 $(this).show();
2976 if ($(this).children().length == 0) {
2977 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"afbi_cdax_img_cal_options_wrapper\"></div><div class=\"left_panel_calendar afbi_cdax_img_cal\"></div></div>");
2978 }
2979 $(this).children().show();
2980 }
2981 });
2982
2983
2984 //display calendar
2985 $(".afbi_cdax_img_cal").datepicker({
2986 beforeShowDay: function (date) {
2987 return (tempArrCdaxImgdate.indexOf(date.toISOString()) > -1) ? [true, "afbi_cdax_img_calendar"] : [false, ""];
2988 },
2989 dateFormat: "dd-mm-yy",
2990 defaultDate: new Date(tempArrCdaxImgdate[0]),
2991 minDate: new Date(tempArrCdaxImgdate[tempArrCdaxImgdate.length - 1]),
2992 onSelect: function (data) {
2993 img_displayImageOverLay(data, 014, im_arr_afbi_cdax_img_overlay);
2994 displaySelectedCalDate(data, 014);
2995 },
2996 maxDate: '0'
2997 });
2998
2999 //insert calendar options
3000 $(".afbi_cdax_img_cal_options_wrapper").append("<p class=\"afbi_cdax_img_cal_date_selected\"></p>");
3001
3002 if ($('.afbi_cdax_img_cal > .layer-calendar-skip-months').length === 0) {
3003 $(".afbi_cdax_img_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
3004 $('.layer-calendar-skip-months:visible').fadeOut(5000);
3005 }
3006
3007 }
3008
3009 if (id == 14) {
3010
3011 $(".misat_data_loader").hide();
3012
3013 //fvat -- misat field View
3014 im_arr_misat_fieldView_img_overlay = [];
3015
3016 var tempArrCount = [];
3017 im_arr_fvat_dates = [];
3018 im_arr_fvat_dates_NoCloudCover = [];
3019 im_arr_fvat_dates_HasCloud = [];
3020 im_arr_fvat_dates_PartialCloudCover = [];
3021
3022 for (var i = 0; i < t.misatFieldView.length; i++) {
3023 tempArrCount.push(t.misatFieldView[i].dateperformed.split(' ')[0]);
3024
3025 if (t.misatFieldView[i].cloudcover > 0) {
3026 if (t.misatFieldView[i].cloudcover < 99) {
3027 im_arr_fvat_dates_PartialCloudCover.push(t.misatFieldView[i].dateperformed.split(' ')[0] + "|" + t.misatFieldView[i].cloudcover);
3028 }
3029 else {
3030 im_arr_fvat_dates_HasCloud.push(t.misatFieldView[i].dateperformed.split(' ')[0] + "|" + t.misatFieldView[i].cloudcover);
3031 }
3032 }
3033 else {
3034 im_arr_fvat_dates_NoCloudCover.push(t.misatFieldView[i].dateperformed.split(' ')[0] + "|" + t.misatFieldView[i].cloudcover);
3035 }
3036 }
3037
3038
3039 var uniqueItems = [];
3040 //strip out dups
3041 $.each(tempArrCount, function (i, el) {
3042 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
3043 });
3044
3045
3046 for (var j = 0; j < uniqueItems.length; j++) {
3047
3048 var d = uniqueItems[j].split('/')[0];
3049 var m = uniqueItems[j].split('/')[1];
3050 var y = uniqueItems[j].split('/')[2];
3051
3052 im_arr_fvat_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
3053
3054 }
3055 $(".layerInfo").each(function () {
3056
3057 if ($(this).attr("rel") == 2) {
3058 $(this).show();
3059 if ($(this).children().length == 0) {
3060 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"misat_data_loader\"></div><div class=\"misat_cal_options_wrapper\"></div><div class=\"left_panel_calendar misat_cal\"></div></div>");
3061 }
3062 $(this).children().show();
3063 }
3064 });
3065
3066 var setDefaultDate = new Date(im_arr_fvat_dates[0]);
3067 if ((tmp_img_lyr_misat_current_month != "") && (tmp_img_lyr_misat_current_yr != "")) {
3068 //user has browsed misat calendar months
3069 setDefaultDate = (new Date(tmp_img_lyr_misat_current_month + '/01/' + tmp_img_lyr_misat_current_yr)).toISOString()
3070 }
3071
3072
3073 //display calendar
3074 $(".misat_cal").datepicker({
3075 beforeShowDay: function (date) {
3076 return (im_arr_fvat_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_fvat_dates_NoCloudCover, im_arr_fvat_dates_HasCloud, im_arr_fvat_dates_PartialCloudCover)] : [false, ""];
3077 },
3078 dateFormat: "dd-mm-yy",
3079 defaultDate: new Date(setDefaultDate),
3080 minDate: new Date(im_arr_fvat_dates[im_arr_fvat_dates.length - 1]),
3081 onSelect: function (data) {
3082 img_displayImageOverLay(data, 14, im_arr_misat_fieldView_img_overlay);
3083 displaySelectedCalDate(data, 14);
3084 },
3085 maxDate: '0'
3086 });
3087
3088
3089 //we need to find out if this las been locked from previous actions.
3090 var checkIsLayerLocked = false;
3091 $(".layerInfo").each(function () {
3092
3093 if ($(this).attr("rel") == id && $(this).hasClass("lyr_locked")) {
3094 checkIsLayerLocked = true
3095 }
3096 });
3097
3098 if (!checkIsLayerLocked) {
3099 //insert calendar options
3100 if ($('.imagery_layer_cigreen').find('.lyr_lock').length === 0) {
3101 $('.imagery_layer_cigreen ').append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div></div>");
3102 }
3103 $(".misat_cal_options_wrapper").append("<div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" /><label for=\"misatFarmView\">Farm View</label><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
3104
3105 }
3106 else {
3107 if ($('.imagery_layer_cigreen').find('.lyr_lock').length === 0) {
3108 $('.imagery_layer_cigreen ').append("<div class=\"lyr_lock\"><div class=\"glyphicon lyr_locked_icon icon-noun_Lock_747565 lyr_lock_red\"></div></div>");
3109 }
3110 $(".misat_cal_options_wrapper").append("<div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFarmView\">Farm View</label><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" /><label for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
3111 }
3112
3113 // before lock button changes
3114 //if (!checkIsLayerLocked) {
3115 // //insert calendar options
3116 // $(".misat_cal_options_wrapper").append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div><div class=\"lyr_lock_txt\">Lock this layer</div></div><div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" /><label for=\"misatFarmView\">Farm View</label><br/><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
3117
3118 //}
3119 //else {
3120 // $(".misat_cal_options_wrapper").append("<div class=\"lyr_lock\"><div class=\"glyphicon lyr_locked_icon icon-noun_Lock_747565 lyr_lock_red\"></div><div class=\"lyr_lock_txt\">Layer is locked!</div></div><div class=\"lyr_misat_view_wrapper\"><input name=\"misatView\" type=\"radio\" id=\"misatFarmView\" checked /><label class=\"lyr_misat_selected\" for=\"misatFarmView\">Farm View</label><br/><input type=\"radio\" name=\"misatView\" id=\"misatFieldView\" /><label for=\"misatFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"misat_date_selected\"></p>");
3121 //}
3122
3123 if ($('.misat_cal > .layer-calendar-skip-months').length === 0) {
3124 $(".misat_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
3125 $('.layer-calendar-skip-months:visible').fadeOut(5000);
3126 }
3127
3128 }
3129
3130 if (id == 16) {
3131 //cvi
3132 if ($(".cvi_data_loader").is(":visible")) {
3133 $(".cvi_data_loader").hide();
3134 }
3135
3136 im_arr_cvi_overlay = [];
3137 var tempArrCount = [];
3138 im_arr_cvi_dates = [];
3139 im_arr_cvi_dates_NoCloudCover = [];
3140 im_arr_cvi_dates_HasCloud = [];
3141 im_arr_cvin_dates_PartialCloudCover = [];
3142
3143 for (var i = 0; i < t.cvi.length; i++) {
3144 tempArrCount.push(t.cvi[i].dateperformed.split(' ')[0]);
3145
3146 if (t.cvi[i].cloudcover > 0) {
3147 if (t.cvi[i].cloudcover < 99) {
3148 im_arr_cvin_dates_PartialCloudCover.push(t.cvi[i].dateperformed.split(' ')[0] + "|" + t.cvi[i].cloudcover);
3149 }
3150 else {
3151 im_arr_cvi_dates_HasCloud.push(t.cvi[i].dateperformed.split(' ')[0] + "|" + t.cvi[i].cloudcover);
3152 }
3153 }
3154 else {
3155 im_arr_cvi_dates_NoCloudCover.push(t.cvi[i].dateperformed.split(' ')[0] + "|" + t.cvi[i].cloudcover);
3156 }
3157 }
3158
3159 var uniqueItems = [];
3160 //strip out dups
3161 $.each(tempArrCount, function (i, el) {
3162 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
3163 });
3164
3165
3166 for (var j = 0; j < uniqueItems.length; j++) {
3167
3168 var d = uniqueItems[j].split('/')[0];
3169 var m = uniqueItems[j].split('/')[1];
3170 var y = uniqueItems[j].split('/')[2];
3171
3172 im_arr_cvi_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
3173
3174 }
3175
3176 $(".layerInfo").each(function () {
3177
3178 if ($(this).attr("rel") == id) {
3179 $(this).show();
3180 if ($(this).children().length == 0) {
3181 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"cvi_data_loader\"></div><div class=\"cvi_cal_options_wrapper\"></div><div class=\"left_panel_calendar cvi_cal\"></div></div></div>");
3182
3183
3184 }
3185 $(this).children().show();
3186 }
3187 });
3188
3189
3190 var setDefaultDate = new Date(im_arr_cvi_dates[0]);
3191
3192 if ((tmp_img_lyr_cvi_current_month != "") && (tmp_img_lyr_cvi_current_yr != "")) {
3193 //user has browsed cigreen calendar months
3194 setDefaultDate = (new Date(tmp_img_lyr_cvi_current_month + '/01/' + tmp_img_lyr_cvi_current_yr)).toISOString();
3195 }
3196
3197 //display calendar
3198 $(".cvi_cal").datepicker({
3199 beforeShowDay: function (date) {
3200 return (im_arr_cvi_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_cvi_dates_NoCloudCover, im_arr_cvi_dates_HasCloud, im_arr_cvi_dates_PartialCloudCover)] : [false, ""];
3201 },
3202 dateFormat: "dd-mm-yy",
3203 defaultDate: new Date(setDefaultDate),
3204 minDate: new Date(im_arr_cvi_dates[im_arr_cvi_dates.length - 1]),
3205 onSelect: function (data) {
3206 img_displayImageOverLay(data, 16, im_arr_cvi_overlay);
3207 displaySelectedCalDate(data, 16);
3208 tmp_img_lyr_cvi_current_day = data.split('-')[0];
3209 tmp_img_lyr_cvi_current_month = data.split('-')[1];
3210 tmp_img_lyr_cvi_current_yr = data.split('-')[2];
3211 },
3212 maxDate: '0',
3213 onChangeMonthYear: function (year, month) {
3214 tmp_img_lyr_cvi_current_month = month;
3215 tmp_img_lyr_cvi_current_yr = year;
3216 }
3217 });
3218
3219 $(".cvi_cal_options_wrapper").append("<div class=\"lyr_cvi_view_wrapper\"><input name=\"cviView\" type=\"radio\" id=\"cviFarmView\" checked /><label for=\"cviFarmView\">Farm View</label><br/><input type=\"radio\" name=\"cviView\" id=\"cviFieldView\" /><label class=\"lyr_cvi_selected\" for=\"cviFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cvi_date_selected\"></p>");
3220
3221
3222 if ($('.cvi_cal > .layer-calendar-skip-months').length === 0) {
3223 $(".cvi_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
3224 $('.layer-calendar-skip-months:visible').fadeOut(5000);
3225 }
3226 }
3227
3228 //if (id == 17) {
3229 // //cigreen
3230 // if ($(".cigreen_data_loader").is(":visible")) {
3231 // $(".cigreen_data_loader").hide();
3232 // }
3233 // debugger;
3234 // im_arr_cigreen_overlay = [];
3235 // var tempArrCount = [];
3236 // im_arr_cigreen_dates = [];
3237 // im_arr_cigreen_dates_NoCloudCover = [];
3238 // im_arr_cigreen_dates_HasCloud = [];
3239 // im_arr_cigreen_dates_PartialCloudCover = [];
3240
3241 // for (var i = 0; i < t.cigreen.length; i++) {
3242 // tempArrCount.push(t.cigreen[i].dateperformed.split(' ')[0]);
3243
3244 // if (t.cigreen[i].cloudcover > 0) {
3245 // if (t.cigreen[i].cloudcover < 99) {
3246 // im_arr_cigreen_dates_PartialCloudCover.push(t.cigreen[i].dateperformed.split(' ')[0] + "|" + t.cigreen[i].cloudcover);
3247 // }
3248 // else {
3249 // im_arr_cigreen_dates_HasCloud.push(t.cigreen[i].dateperformed.split(' ')[0] + "|" + t.cigreen[i].cloudcover);
3250 // }
3251 // }
3252 // else {
3253 // im_arr_cigreen_dates_NoCloudCover.push(t.cigreen[i].dateperformed.split(' ')[0] + "|" + t.cigreen[i].cloudcover);
3254 // }
3255 // }
3256
3257 // var uniqueItems = [];
3258 // //strip out dups
3259 // $.each(tempArrCount, function (i, el) {
3260 // if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
3261 // });
3262 // debugger;
3263
3264 // for (var j = 0; j < uniqueItems.length; j++) {
3265
3266 // var d = uniqueItems[j].split('/')[0];
3267 // var m = uniqueItems[j].split('/')[1];
3268 // var y = uniqueItems[j].split('/')[2];
3269
3270 // im_arr_cigreen_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
3271
3272 // }
3273 // debugger;
3274
3275 // $(".layerInfo").each(function () {
3276
3277 // if ($(this).attr("rel") == id) {
3278 // $(this).show();
3279 // if ($(this).children().length == 0) {
3280 // $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"cigreen_data_loader\"></div><div class=\"cigreen_cal_options_wrapper\"></div><div class=\"left_panel_calendar cigreen_cal\"></div></div></div>");
3281
3282
3283 // }
3284 // $(this).children().show();
3285 // }
3286 // });
3287 // debugger;
3288
3289 // var setDefaultDate = new Date(im_arr_cigreen_dates[0]);
3290
3291 // if ((tmp_img_lyr_cigreen_current_month != "") && (tmp_img_lyr_cigreen_current_yr != "")) {
3292 // //user has browsed cigreen calendar months
3293 // setDefaultDate = (new Date(tmp_img_lyr_cigreen_current_month + '/01/' + tmp_img_lyr_cigreen_current_yr)).toISOString();
3294 // }
3295 // debugger;
3296
3297 // //display calendar
3298 // $(".cigreen_cal").datepicker({
3299 // beforeShowDay: function (date) {
3300 // return (im_arr_cigreen_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_cigreen_dates_NoCloudCover, im_arr_cigreen_dates_HasCloud, im_arr_cigreen_dates_PartialCloudCover)] : [false, ""];
3301 // },
3302 // dateFormat: "dd-mm-yy",
3303 // defaultDate: new Date(setDefaultDate),
3304 // minDate: new Date(im_arr_cigreen_dates[im_arr_cigreen_dates.length - 1]),
3305 // onSelect: function (data) {
3306 // debugger;
3307 // img_displayImageOverLay(data, 17, im_arr_cigreen_overlay);
3308 // displaySelectedCalDate(data, 17);
3309 // tmp_img_lyr_cigreen_current_day = data.split('-')[0];
3310 // tmp_img_lyr_cigreen_current_month = data.split('-')[1];
3311 // tmp_img_lyr_cigreen_current_yr = data.split('-')[2];
3312
3313 // },
3314 // maxDate: '0',
3315 // onChangeMonthYear: function (year, month) {
3316 // tmp_img_lyr_cigreen_current_month = month;
3317 // tmp_img_lyr_cigreen_current_yr = year;
3318 // }
3319 // });
3320 // debugger;
3321
3322
3323 // //we need to find out if this las been locked from previous actions.
3324 // var checkIsLayerLocked = false;
3325 // $(".layerInfo").each(function () {
3326 // if ($(this).attr("rel") == id && $(this).hasClass("lyr_locked")) {
3327 // checkIsLayerLocked = true
3328 // }
3329 // });
3330 // debugger;
3331
3332 // let ndviDiv = "<div id=\"leftPanelDatePickerWrapper\"><div class=\"misat_data_loader\"></div><div class=\"misat_cal_options_wrapper\"></div><div class=\"left_panel_calendar misat_cal\"></div></div>";
3333
3334
3335 // let satelliteTypesElement = "<div class=\"satelliteTypesIcons\" id=\"satelliteTypes\"><i class=\"fas fa-seedling satSelectIcons\" id=\"ci_green_icon\"></i><i class=\"fab fa-typo3 satSelectIcons\" id=\"rgb_icon\"></i><i class=\"fas fa-seedling satSelectIcons\" id=\"ndvi_icon\"></i><p>RGB</p></div>";
3336
3337 // if (!checkIsLayerLocked) {
3338 // $(".cigreen_cal_options_wrapper").append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div><div class=\"lyr_lock_txt\">Lock this layer</div></div><div class=\"lyr_cigreen_view_wrapper\"><input name=\"cigreenView\" type=\"radio\" id=\"cigreenFarmView\" checked /><label for=\"cigreenFarmView\">Farm View</label><br/><input type=\"radio\" name=\"cigreenView\" id=\"cigreenFieldView\" /><label class=\"lyr_cigreen_selected\" for=\"cigreenFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_date_selected\"></p>");
3339 // }
3340 // else {
3341 // $(".cigreen_cal_options_wrapper").append(satelliteTypesElement + "<div class=\"lyr_lock\"><div class=\"glyphicon lyr_locked_icon icon-noun_Lock_747565 lyr_lock_red\"></div><div class=\"lyr_lock_txt\">Layer is locked!</div></div><div class=\"lyr_cigreen_view_wrapper\"><input name=\"cigreenView\" type=\"radio\" id=\"cigreenFarmView\" checked /><label for=\"cigreenFarmView\">Farm View</label><br/><input type=\"radio\" name=\"cigreenView\" id=\"cigreenFieldView\" /><label class=\"lyr_cigreen_selected\" for=\"cigreenFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_date_selected\"></p>");
3342 // }
3343
3344 // if ($('.cigreen_cal > .layer-calendar-skip-months').length === 0) {
3345 // $(".cigreen_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
3346 // $('.layer-calendar-skip-months:visible').fadeOut(5000);
3347 // }
3348
3349 // debugger;
3350
3351 //}
3352
3353 if (id == 17) {
3354 //cigreen
3355 if ($(".cigreen_data_loader").is(":visible")) {
3356 $(".cigreen_data_loader").hide();
3357 }
3358 debugger;
3359 im_arr_cigreen_overlay = [];
3360 var tempArrCount = [];
3361 im_arr_cigreen_dates = [];
3362 im_arr_cigreen_dates_NoCloudCover = [];
3363 im_arr_cigreen_dates_HasCloud = [];
3364 im_arr_cigreen_dates_PartialCloudCover = [];
3365
3366 for (var i = 0; i < t.cigreen.length; i++) {
3367 tempArrCount.push(t.cigreen[i].dateperformed.split(' ')[0]);
3368
3369 if (t.cigreen[i].cloudcover > 0) {
3370 if (t.cigreen[i].cloudcover < 99) {
3371 im_arr_cigreen_dates_PartialCloudCover.push(t.cigreen[i].dateperformed.split(' ')[0] + "|" + t.cigreen[i].cloudcover);
3372 }
3373 else {
3374 im_arr_cigreen_dates_HasCloud.push(t.cigreen[i].dateperformed.split(' ')[0] + "|" + t.cigreen[i].cloudcover);
3375 }
3376 }
3377 else {
3378 im_arr_cigreen_dates_NoCloudCover.push(t.cigreen[i].dateperformed.split(' ')[0] + "|" + t.cigreen[i].cloudcover);
3379 }
3380 }
3381
3382 var uniqueItems = [];
3383 //strip out dups
3384 $.each(tempArrCount, function (i, el) {
3385 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
3386 });
3387 debugger;
3388
3389 for (var j = 0; j < uniqueItems.length; j++) {
3390
3391 var d = uniqueItems[j].split('/')[0];
3392 var m = uniqueItems[j].split('/')[1];
3393 var y = uniqueItems[j].split('/')[2];
3394
3395 im_arr_cigreen_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
3396
3397 }
3398 debugger;
3399
3400 $(".layerInfo").each(function () {
3401 debugger;
3402 if ($(this).attr("rel") == id) {
3403 $(this).show();
3404 if ($(this).children().length == 0) {
3405 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"cigreen_data_loader\"></div><div class=\"cigreen_cal_options_wrapper\"></div><div class=\"left_panel_calendar cigreen_cal\"></div></div></div>");
3406
3407
3408 }
3409 $(this).children().show();
3410 }
3411 });
3412 debugger;
3413
3414 var setDefaultDate = new Date(im_arr_cigreen_dates[0]);
3415
3416 if ((tmp_img_lyr_cigreen_current_month != "") && (tmp_img_lyr_cigreen_current_yr != "")) {
3417 //user has browsed cigreen calendar months
3418 setDefaultDate = (new Date(tmp_img_lyr_cigreen_current_month + '/01/' + tmp_img_lyr_cigreen_current_yr)).toISOString();
3419 }
3420 debugger;
3421
3422 //display calendar
3423 $(".cigreen_cal").datepicker({
3424 beforeShowDay: function (date) {
3425 return (im_arr_cigreen_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_cigreen_dates_NoCloudCover, im_arr_cigreen_dates_HasCloud, im_arr_cigreen_dates_PartialCloudCover)] : [false, ""];
3426 },
3427 dateFormat: "dd-mm-yy",
3428 defaultDate: new Date(setDefaultDate),
3429 minDate: new Date(im_arr_cigreen_dates[im_arr_cigreen_dates.length - 1]),
3430 onSelect: function (data) {
3431 debugger;
3432 img_displayImageOverLay(data, 17, im_arr_cigreen_overlay);
3433 displaySelectedCalDate(data, 17);
3434 tmp_img_lyr_cigreen_current_day = data.split('-')[0];
3435 tmp_img_lyr_cigreen_current_month = data.split('-')[1];
3436 tmp_img_lyr_cigreen_current_yr = data.split('-')[2];
3437 },
3438 maxDate: '0',
3439 onChangeMonthYear: function (year, month) {
3440 tmp_img_lyr_cigreen_current_month = month;
3441 tmp_img_lyr_cigreen_current_yr = year;
3442 }
3443 });
3444 debugger;
3445
3446
3447 //we need to find out if this las been locked from previous actions.
3448 var checkIsLayerLocked = false;
3449 $(".layerInfo").each(function () {
3450 if ($(this).attr("rel") == id && $(this).hasClass("lyr_locked")) {
3451 checkIsLayerLocked = true
3452 }
3453 });
3454 debugger;
3455
3456 if ($(".cigreen_cal_options_wrapper").length > 0) {
3457 $(".cigreen_cal_options_wrapper").empty()
3458 }
3459
3460 if ($(".rgb_cal_options_wrapper").length > 0) {
3461 $(".rgb_cal_options_wrapper").empty();
3462 $('.rgb_cal').datepicker("destroy");
3463 $(".imagery_layer_rgb").find(".layer_item_loader").hide();
3464 }
3465
3466 if ($(".misat_cal_options_wrapper").length > 0) {
3467 $(".misat_cal_options_wrapper").empty();
3468 $('.misat_cal').datepicker("destroy");
3469 }
3470
3471 $('#ci_green_icon').addClass('selectedIcon');
3472
3473 $('#satelliteTypeName').text('CI Green');
3474
3475 if (!checkIsLayerLocked) {
3476 if ($('.imagery_layer_cigreen').find('.lyr_lock').length === 0) {
3477 $('.imagery_layer_cigreen ').append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div></div>");
3478 //$('.imagery_layer_cigreen ').append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div><div class=\"lyr_lock_txt\">Lock this layer</div></div>");
3479 }
3480 $(".cigreen_cal_options_wrapper").append("<div class=\"lyr_cigreen_view_wrapper\"><input name=\"cigreenView\" type=\"radio\" id=\"cigreenFarmView\" checked /><label for=\"cigreenFarmView\">Farm View</label><input type=\"radio\" name=\"cigreenView\" id=\"cigreenFieldView\" /><label class=\"lyr_cigreen_selected\" for=\"cigreenFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_date_selected\"></p>");
3481 }
3482 else {
3483 if ($('.imagery_layer_cigreen').find('.lyr_lock').length === 0) {
3484 $('.imagery_layer_cigreen ').append("<div class=\"lyr_lock\"><div class=\"glyphicon lyr_locked_icon icon-noun_Lock_747565 lyr_lock_red\"></div></div>")
3485 }
3486 $(".cigreen_cal_options_wrapper").append("<div class=\"lyr_cigreen_view_wrapper\"><input name=\"cigreenView\" type=\"radio\" id=\"cigreenFarmView\" checked /><label for=\"cigreenFarmView\">Farm View</label><input type=\"radio\" name=\"cigreenView\" id=\"cigreenFieldView\" /><label class=\"lyr_cigreen_selected\" for=\"cigreenFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_date_selected\"></p>");
3487 }
3488
3489 if ($('.cigreen_cal > .layer-calendar-skip-months').length === 0) {
3490 $(".cigreen_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
3491 $('.layer-calendar-skip-months:visible').fadeOut(5000);
3492 }
3493
3494 debugger;
3495
3496 }
3497
3498 if (id == 18) {
3499 //cvi
3500 if ($(".cvi_data_loader").is(":visible")) {
3501 $(".cvi_data_loader").hide();
3502 }
3503
3504 im_arr_cvi_overlay = [];
3505 var tempArrCount = [];
3506 im_arr_cvi_dates = [];
3507 im_arr_cvi_dates_NoCloudCover = [];
3508 im_arr_cvi_dates_HasCloud = [];
3509 im_arr_cvin_dates_PartialCloudCover = [];
3510
3511 for (var i = 0; i < t.cviFieldView.length; i++) {
3512 tempArrCount.push(t.cviFieldView[i].dateperformed.split(' ')[0]);
3513
3514 if (t.cviFieldView[i].cloudcover > 0) {
3515 if (t.cviFieldView[i].cloudcover < 99) {
3516 im_arr_cvin_dates_PartialCloudCover.push(t.cviFieldView[i].dateperformed.split(' ')[0] + "|" + t.cviFieldView[i].cloudcover);
3517 }
3518 else {
3519 im_arr_cvi_dates_HasCloud.push(t.cviFieldView[i].dateperformed.split(' ')[0] + "|" + t.cviFieldView[i].cloudcover);
3520 }
3521 }
3522 else {
3523 im_arr_cvi_dates_NoCloudCover.push(t.cviFieldView[i].dateperformed.split(' ')[0] + "|" + t.cviFieldView[i].cloudcover);
3524 }
3525 }
3526
3527 var uniqueItems = [];
3528 //strip out dups
3529 $.each(tempArrCount, function (i, el) {
3530 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
3531 });
3532
3533
3534 for (var j = 0; j < uniqueItems.length; j++) {
3535
3536 var d = uniqueItems[j].split('/')[0];
3537 var m = uniqueItems[j].split('/')[1];
3538 var y = uniqueItems[j].split('/')[2];
3539
3540 im_arr_cvi_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
3541
3542 }
3543
3544 $(".layerInfo").each(function () {
3545
3546 if ($(this).attr("rel") == id) {
3547 $(this).show();
3548 if ($(this).children().length == 0) {
3549 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div id=\"leftPanelDatePickerWrapper\"><div class=\"cvi_data_loader\"></div><div class=\"cvi_cal_options_wrapper\"></div><div class=\"left_panel_calendar cvi_cal\"></div></div></div>");
3550
3551
3552 }
3553 $(this).children().show();
3554 }
3555 });
3556
3557
3558 var setDefaultDate = new Date(im_arr_cvi_dates[0]);
3559
3560 if ((tmp_img_lyr_cvi_current_month != "") && (tmp_img_lyr_cvi_current_yr != "")) {
3561 //user has browsed cigreen calendar months
3562 setDefaultDate = (new Date(tmp_img_lyr_cvi_current_month + '/01/' + tmp_img_lyr_cvi_current_yr)).toISOString();
3563 }
3564
3565 //display calendar
3566 $(".cvi_cal").datepicker({
3567 beforeShowDay: function (date) {
3568 return (im_arr_cvi_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_cvi_dates_NoCloudCover, im_arr_cvi_dates_HasCloud, im_arr_cvi_dates_PartialCloudCover)] : [false, ""];
3569 },
3570 dateFormat: "dd-mm-yy",
3571 defaultDate: new Date(setDefaultDate),
3572 minDate: new Date(im_arr_cvi_dates[im_arr_cvi_dates.length - 1]),
3573 onSelect: function (data) {
3574 img_displayImageOverLay(data, 18, im_arr_cvi_overlay);
3575 displaySelectedCalDate(data, 18);
3576 tmp_img_lyr_cvi_current_day = data.split('-')[0];
3577 tmp_img_lyr_cvi_current_month = data.split('-')[1];
3578 tmp_img_lyr_cvi_current_yr = data.split('-')[2];
3579 },
3580 maxDate: '0',
3581 onChangeMonthYear: function (year, month) {
3582 tmp_img_lyr_cvi_current_month = month;
3583 tmp_img_lyr_cvi_current_yr = year;
3584 }
3585 });
3586
3587 $(".cvi_cal_options_wrapper").append("<div class=\"lyr_cvi_view_wrapper\"><input name=\"cviView\" type=\"radio\" id=\"cviFarmView\" /><label for=\"cviFarmView\">Farm View</label><br/><input type=\"radio\" name=\"cviView\" id=\"cviFieldView\" checked /><label class=\"lyr_cvi_selected\" for=\"cviFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cvi_date_selected\"></p>");
3588
3589
3590 if ($('.cvi_cal > .layer-calendar-skip-months').length === 0) {
3591 $(".cvi_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
3592 $('.layer-calendar-skip-months:visible').fadeOut(5000);
3593 }
3594 }
3595
3596
3597 if (id == 19) {
3598 debugger;
3599 $(".cigreen_data_loader").hide();
3600
3601 //cigreen field View
3602 im_arr_cigreen_fieldView_img_overlay = [];
3603
3604 var tempArrCount = [];
3605 im_arr_cigreen_dates = [];
3606 im_arr_cigreen_dates_NoCloudCover = [];
3607 im_arr_cigreen_dates_HasCloud = [];
3608 im_arr_cigreen_dates_PartialCloudCover = [];
3609
3610 for (var i = 0; i < t.cigreenFieldView.length; i++) {
3611 tempArrCount.push(t.cigreenFieldView[i].dateperformed.split(' ')[0]);
3612
3613 if (t.cigreenFieldView[i].cloudcover > 0) {
3614 if (t.cigreenFieldView[i].cloudcover < 99) {
3615 im_arr_cigreen_dates_PartialCloudCover.push(t.cigreenFieldView[i].dateperformed.split(' ')[0] + "|" + t.cigreenFieldView[i].cloudcover);
3616 }
3617 else {
3618 im_arr_cigreen_dates_HasCloud.push(t.cigreenFieldView[i].dateperformed.split(' ')[0] + "|" + t.cigreenFieldView[i].cloudcover);
3619 }
3620 }
3621 else {
3622 im_arr_cigreen_dates_NoCloudCover.push(t.cigreenFieldView[i].dateperformed.split(' ')[0] + "|" + t.cigreenFieldView[i].cloudcover);
3623 }
3624 }
3625
3626 debugger;
3627
3628 var uniqueItems = [];
3629 //strip out dups
3630 $.each(tempArrCount, function (i, el) {
3631 if ($.inArray(el, uniqueItems) === -1) uniqueItems.push(el);
3632 });
3633
3634
3635 for (var j = 0; j < uniqueItems.length; j++) {
3636
3637 var d = uniqueItems[j].split('/')[0];
3638 var m = uniqueItems[j].split('/')[1];
3639 var y = uniqueItems[j].split('/')[2];
3640
3641 im_arr_cigreen_dates.push((new Date(m + '/' + d + '/' + y)).toISOString());
3642
3643 }
3644 debugger;
3645
3646 $(".layerInfo").each(function () {
3647
3648 if ($(this).attr("rel") == id) {
3649 $(this).show();
3650 if ($(this).children().length == 0) {
3651 $(this).html("<div id=\"leftPanelDatePickerWrapper\"><div class=\"cigreen_data_loader\"></div><div class=\"cigreen_cal_options_wrapper\"></div><div class=\"left_panel_calendar cigreen_cal\"></div></div>");
3652 }
3653 $(this).children().show();
3654 }
3655 });
3656
3657 var setDefaultDate = new Date(im_arr_cigreen_dates[0]);
3658 if ((tmp_img_lyr_cigreen_current_month != "") && (tmp_img_lyr_cigreen_current_yr != "")) {
3659 //user has browsed cigreen calendar months
3660 setDefaultDate = (new Date(tmp_img_lyr_cigreen_current_month + '/01/' + tmp_img_lyr_cigreen_current_yr)).toISOString()
3661 }
3662
3663 debugger;
3664
3665 //display calendar
3666 $(".cigreen_cal").datepicker({
3667 beforeShowDay: function (date) {
3668 return (im_arr_cigreen_dates.indexOf(date.toISOString()) > -1) ? [true, setCloudyCSS(date, im_arr_cigreen_dates_NoCloudCover, im_arr_cigreen_dates_HasCloud, im_arr_cigreen_dates_PartialCloudCover)] : [false, ""];
3669 },
3670 dateFormat: "dd-mm-yy",
3671 defaultDate: new Date(setDefaultDate),
3672 minDate: new Date(im_arr_cigreen_dates[im_arr_cigreen_dates.length - 1]),
3673 onSelect: function (data) {
3674 img_displayImageOverLay(data, 19, im_arr_cigreen_fieldView_img_overlay);
3675 displaySelectedCalDate(data, 19);
3676 },
3677 maxDate: '0'
3678 });
3679
3680
3681 //insert calendar options
3682 //$(".cigreen_cal_options_wrapper").append("<div class=\"lyr_cigreen_view_wrapper\"><input name=\"cigreenView\" type=\"radio\" id=\"cigreenFarmView\" /><label for=\"cigreenFarmView\">Farm View</label><br/><input type=\"radio\" name=\"cigreenView\" id=\"cigreenFieldView\" checked /><label class=\"lyr_misat_selected\" for=\"cigreenFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_date_selected\"></p>");
3683 //we need to find out if this las been locked from previous actions.
3684 var checkIsLayerLocked = false;
3685 $(".layerInfo").each(function () {
3686 if ($(this).attr("rel") == id && $(this).hasClass("lyr_locked")) {
3687 checkIsLayerLocked = true
3688 }
3689 });
3690 debugger;
3691
3692 if (!checkIsLayerLocked) {
3693 if ($('.imagery_layer_cigreen').find('.lyr_lock').length === 0) {
3694 $('.imagery_layer_cigreen ').append("<div class=\"lyr_lock\"><div class=\"glyphicon icon-noun_Unlock_821902 lyr_locked_icon\"></div></div>")
3695 }
3696 $(".cigreen_cal_options_wrapper").append("<div class=\"lyr_cigreen_view_wrapper\"><input name=\"cigreenView\" type=\"radio\" id=\"cigreenFarmView\" /><label for=\"cigreenFarmView\">Farm View</label><input type=\"radio\" name=\"cigreenView\" id=\"cigreenFieldView\" checked/><label class=\"lyr_cigreen_selected\" for=\"cigreenFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_date_selected\"></p>");
3697 }
3698 else {
3699 if ($('.imagery_layer_cigreen').find('.lyr_lock').length === 0) {
3700 $('.imagery_layer_cigreen ').append("<div class=\"lyr_lock\"><div class=\"glyphicon lyr_locked_icon icon-noun_Lock_747565 lyr_lock_red\"></div>");
3701 }
3702 $(".cigreen_cal_options_wrapper").append("<div class=\"lyr_cigreen_view_wrapper\"><input name=\"cigreenView\" type=\"radio\" id=\"cigreenFarmView\" /><label for=\"cigreenFarmView\">Farm View</label><input type=\"radio\" name=\"cigreenView\" id=\"cigreenFieldView\" checked/><label class=\"lyr_cigreen_selected\" for=\"cigreenFieldView\">Field View</label></div><span class=\"img_layer_legend_non_cloudy_day\" title=\"Cloud free day.\"></span>Cloud Free<br/><span class=\"img_layer_legend_partial_cloudy_day\" title=\"Partly cloudy day.\"></span>Partial Cloud<br/><span class=\"img_layer_legend_cloudy_day\" title=\"Cloud covered day.\"></span>Cloud Cover<p class=\"cigreen_date_selected\"></p>");
3703 }
3704
3705 if ($('.cigreen_cal > .layer-calendar-skip-months').length === 0) {
3706 $(".cigreen_cal").append("<p class='layer-calendar-skip-months'>Empty months will be skipped</p>")
3707 $('.layer-calendar-skip-months:visible').fadeOut(5000);
3708 }
3709 }
3710
3711 if (id == 116) {
3712 //grasshopper img
3713 im_arr_grass_cdax_img_overlay = [];
3714
3715 var tempArrCount = [];
3716 var tempArrGrassHopperImgdate = [];
3717
3718 for (var i = 0; i < t.cdaximg.length; i++) {
3719 tempArrCount.push(t.cdaximg[i].dateperformed);
3720 }
3721
3722
3723 }
3724
3725
3726
3727 im_bImgTypeDatesAjax_loading = false;
3728
3729 });
3730
3731 }
3732}
3733
3734function setCloudyCSS(date, tempArrNoCloudCover, tempArrHasCloud, tempPartialCloudCover) {
3735
3736 var css = "";
3737 var convertDtFormat = new Date(date);
3738 var mm = convertDtFormat.getMonth() + 1;
3739 var dd = convertDtFormat.getDate();
3740 var yyyy = convertDtFormat.getFullYear();
3741 var cloudyScore = 0;
3742 var dateCount = 0;
3743
3744
3745 if (dd < 10) {
3746 dd = "0" + dd;
3747 }
3748 if (mm < 10) {
3749 mm = "0" + mm;
3750 }
3751 var t = (dd + "/" + mm + "/" + yyyy);
3752
3753
3754 //look to see if we have any cloud cover days for this farm
3755 for (var j = 0; j < tempArrHasCloud.length; j++) {
3756
3757 if (t == tempArrHasCloud[j].split('|')[0]) {
3758
3759 cloudyScore = cloudyScore + parseFloat(tempArrHasCloud[j].split('|')[1])
3760 dateCount++;
3761 }
3762 }
3763
3764
3765 for (var j = 0; j < tempPartialCloudCover.length; j++) {
3766
3767 if (t == tempPartialCloudCover[j].split('|')[0]) {
3768
3769 cloudyScore = cloudyScore + parseFloat(tempPartialCloudCover[j].split('|')[1])
3770 dateCount++;
3771 }
3772 }
3773
3774
3775 for (var j = 0; j < tempArrNoCloudCover.length; j++) {
3776
3777 if (t == tempArrNoCloudCover[j].split('|')[0]) {
3778
3779 cloudyScore = cloudyScore + parseFloat(tempArrNoCloudCover[j].split('|')[1])
3780 dateCount++;
3781 }
3782 }
3783
3784 var avg = cloudyScore / dateCount;
3785
3786 if (avg > 0 && avg < 100) {
3787 css = "img_layer_calendar_date_partial_cloud_cover";
3788 }
3789 if (avg >= 100)
3790 {
3791 css = "img_layer_calendar_date_cloud_cover";
3792 }
3793
3794 if (avg == 0) {
3795 css = "img_layer_calendar_date_no_cloud_cover";
3796 }
3797
3798
3799 return css;
3800}
3801
3802
3803function getLayerImageryData() {
3804
3805 if ($("#panelLayer #imageryLayerContent").text().length == 0) {
3806
3807 if (im_polygon_overlay.length == 0) {
3808
3809
3810 $.ajax({
3811 type: "POST",
3812 url: urlPrepend + "/layerdata/imagery/" + getTradingId() + "/" + getFarmId()
3813 }).done(function (data) {
3814 if (data != "") {
3815
3816 removeLoader();
3817 var str = "";
3818 for (var i = 0; i < data.length; i++) {
3819
3820 str += "<li class=\"layer-item-imagery imagery_layer_" + cleanString(data[i].name) + "\" rel=\"" + data[i].id + "\"><span class=\"glyphicon glyphicon-expand layer-item-imagery-name-icon\"></span><span class=\"layer-item-name-imagery\">" + data[i].name + "</span><span class=\"im_map_img_lyr_ddl_wrapper\"></span></li>";
3821 }
3822
3823 if (str != "") {
3824 $("#panelLayer #imageryLayerContent").empty().html("<ul style=\"width:50%;margin-bottom:0;\">" + str + "</ul>");
3825
3826 //remove default message if we have imagery layers
3827 if (str != "") {
3828 $("#layerContent").find(".nolayer span:first-childr").remove();
3829 }
3830 }
3831
3832 }
3833
3834 });
3835 }
3836 }
3837}
3838
3839
3840
3841function createOverlayObj(jsonEle, imageType) {
3842 var dataObj = {};
3843 dataObj.id = jsonEle.fieldid;
3844 dataObj.fieldName = jsonEle.fieldName;
3845 dataObj.image = jsonEle.image;
3846 dataObj.dateperformed = jsonEle.dateperformed;
3847 dataObj.imgtype = imageType;
3848 dataObj.legend = jsonEle.legend;
3849 dataObj.subtype = jsonEle.subtype;
3850 dataObj.cloudCover = jsonEle.cloudcover;
3851 dataObj.crop = jsonEle.crop;
3852
3853 return dataObj;
3854}
3855
3856function drawOverlay(oBounds, id, img, type, legend, dateperformed, fieldName, crop, isSubType) {
3857
3858 var subType = "";
3859 if (isSubType) {
3860 subType = type.split('|')[1];
3861 type = type.split('|')[0];
3862 }
3863 var lyr_name = "";
3864
3865 //url for image
3866 var urlImg = "";
3867 if (type == 1) {
3868 urlImg = im_nsensor_url + img;
3869 lyr_name = "N-Sensor";
3870 }
3871
3872 if ((type == 2)||(type == 14)||(type == 20)) {
3873 urlImg = im_misat_url + img;
3874 lyr_name = "MiSat Farm View";
3875 if (type == 14) {
3876 lyr_name = "MiSat Field View";
3877 }
3878 if (type == 20) {
3879 lyr_name = "MiSat Variety View";
3880 }
3881 }
3882
3883 if (type == 4) {
3884 urlImg = im_uav_url + img;
3885 lyr_name = "UAV";
3886 }
3887
3888 if (type == 6) {
3889 urlImg = im_conductivity_url + img;
3890 lyr_name = "Conductivity";
3891 }
3892
3893 if (type == 7) {
3894 urlImg = im_migrass_url + img;
3895 lyr_name = "MiGrass";
3896 }
3897
3898 if (type == 8) {
3899 urlImg = im_rgb_url + img;
3900 lyr_name = "RGB";
3901 }
3902
3903 if (type == 9) {
3904 urlImg = im_yield_url + img;
3905 lyr_name = "Yield";
3906 }
3907
3908 if (type == 12) {
3909 urlImg = im_cdax_img_url + img;
3910 lyr_name = "C-Dax Images";
3911 }
3912
3913 if ((type == 17) || (type == 19) || (type == 21)) {
3914 urlImg = im_cigreen_url + img;
3915 lyr_name = "CIgreen Farm View";
3916 if (type == 19) {
3917 lyr_name = "CIgreen Field View";
3918 }
3919 if (type == 21) {
3920 lyr_name = "CIgreen Variety View";
3921 }
3922 }
3923
3924 if ((type == 16) || (type == 18)) {
3925 urlImg = im_cvi_url + img;
3926 lyr_name = "CVI Farm View";
3927 if (type == 18) {
3928 lyr_name = "CVI Field View";
3929 }
3930 }
3931
3932 //create new overlay
3933 var options = {
3934 path: oBounds,
3935 strokeColor: "#222",
3936 strokeOpacity: 1,
3937 strokeWeight: 1,
3938 fillOpacity: 0.0,
3939 zIndex: 9,
3940 id : id
3941 }
3942
3943 //Create polygon
3944 var polygon = new google.maps.Polygon(options);
3945 im_polygon_overlay_temp_customer_overlay.push(polygon);
3946 //Show it on map
3947 polygon.setMap(map); //*****
3948
3949 //new code *****************
3950 google.maps.event.addListener(polygon, 'click', function (event) {
3951 //loop through overlay array to get a match to the clicked polygon
3952 for (var i = 0; i < im_polygon_overlay.length; i++) {
3953 //match polygon to overlay
3954 if (polygon.id == im_polygon_overlay[i].id) {
3955
3956 d = dateperformed;
3957 getCropNameByDate(d, id);//in crop.js
3958 var lyr_compare_field_string = id + "|" + d + "|" + type + "_" + lyr_name + "|" + urlImg;
3959 for (var j = 0; j < im_polygon_overlay.length; j++) {
3960 if (subType.length > 0) {
3961 if ((d == im_polygon_overlay[j].date) && (im_polygon_overlay[j].id == id) && (im_polygon_overlay[j].type == type) && (im_polygon_overlay[j].subType == subType)) {
3962
3963 lyr_compare_field_string += "|" + im_polygon_overlay[j].legend + "|" + fieldName + "|" + crop + "|" + subType;
3964
3965 displayLegendImg(im_polygon_overlay[j].legend, type, fieldName, crop, id, lyr_compare_field_string, img, d);
3966 j = im_polygon_overlay.length;
3967 }
3968 }
3969 else {
3970
3971 if ((d == im_polygon_overlay[j].date) && (im_polygon_overlay[j].id == id) && (im_polygon_overlay[j].type == type)) {
3972
3973 lyr_compare_field_string += "|" + im_polygon_overlay[j].legend + "|" + fieldName + "|" + crop;
3974
3975 displayLegendImg(im_polygon_overlay[j].legend, type, fieldName, crop, id, lyr_compare_field_string, img, d);
3976 j = im_polygon_overlay.length;
3977 }
3978 }
3979
3980
3981
3982 }
3983
3984 }
3985 }
3986 });
3987
3988 addPolygonMouseCoordsData(polygon);
3989 //end of new code ***************
3990
3991 //get bounds from polygon for custom overlay
3992 if (!google.maps.Polygon.prototype.getBounds)
3993 google.maps.Polygon.prototype.getBounds = function () {
3994 var bounds = new google.maps.LatLngBounds();
3995 var paths = this.getPaths();
3996 for (var i = 0; i < paths.getLength() ; i++) {
3997 var path = paths.getAt(i);
3998 for (var j = 0; j < path.getLength() ; j++) {
3999 bounds.extend(path.getAt(j));
4000 }
4001 }
4002 return bounds;
4003 }
4004
4005 var objOverlay = {};
4006
4007 setTimeout(function(){
4008 var myOverlay = new google.maps.GroundOverlay(urlImg, polygon.getBounds(), { clickable: false });
4009 objOverlay.overlay = myOverlay;
4010 objOverlay.id = id;
4011 objOverlay.type = type;
4012 objOverlay.subType = subType;
4013 objOverlay.legend = legend;
4014 objOverlay.date = dateperformed;
4015 im_polygon_overlay.push(objOverlay);
4016
4017 myOverlay.setMap(map);
4018
4019 addPolygonMouseCoordsData(myOverlay);
4020
4021 }, 500);
4022
4023
4024
4025
4026
4027}
4028
4029function displayLegendImg(legend, type, fieldName, crop, fieldId, lyr_comp_params, selectedOverlayImg, selectedDate) {
4030
4031 var urlLegend = ""
4032 if (legend != "") {
4033 if (type == 1) {
4034 urlLegend = im_nsensor_url + legend;
4035 selectedOverlayImg = im_nsensor_url + selectedOverlayImg;
4036 }
4037 if ((type == 2) || (type == 14) || (type == 20)) {
4038 urlLegend = im_misat_url + legend;
4039 selectedOverlayImg = im_misat_url + selectedOverlayImg;
4040 if (type == 20) {
4041 lyr_comp_params = lyr_comp_params.replace("null", crop);
4042 }
4043 }
4044 if (type == 4) {
4045 urlLegend = im_uav_url + legend;
4046 selectedOverlayImg = im_uav_url + selectedOverlayImg;
4047 }
4048 if (type == 6) {
4049 urlLegend = im_conductivity_url + legend;
4050 selectedOverlayImg = im_conductivity_url + selectedOverlayImg;
4051 }
4052 if (type == 7) {
4053 urlLegend = im_migrass_url + legend;
4054 selectedOverlayImg = im_migrass_url + selectedOverlayImg;
4055 }
4056 if (type == 8) {
4057 urlLegend = im_rgb_url + legend;
4058 selectedOverlayImg = im_rgb_url + selectedOverlayImg;
4059 }
4060 if (type == 9) {
4061 urlLegend = im_yield_url + legend;
4062 selectedOverlayImg = im_yield_url + selectedOverlayImg;
4063 }
4064 if (type == 12) {
4065 urlLegend = im_cdax_img_url + legend;
4066 selectedOverlayImg = im_cdax_img_url + selectedOverlayImg;
4067 }
4068 if ((type == 16) || (type == 18)) {
4069 urlLegend = im_cvi_url + legend;
4070 selectedOverlayImg = im_cvi_url + selectedOverlayImg;
4071 }
4072 if ((type == 17) || (type == 19) || (type == 21)) {
4073 urlLegend = im_cigreen_url + legend;
4074 selectedOverlayImg = im_cigreen_url + selectedOverlayImg;
4075
4076 if (type == 21) {
4077 lyr_comp_params = lyr_comp_params.replace("null", crop);
4078 }
4079 }
4080 }
4081
4082 if (type != 8) {
4083 displayLeftDetailsPanel(true);
4084
4085 //get current crop related to the season user is viewing. Then store all layer information into variable string to use for select checkbox
4086
4087 $.ajax({
4088 type: "POST",
4089 url: urlPrepend + "/layerdata/crop/getfieldcropnamebydate",
4090 data: { farmId: getFarmId(), fieldId: fieldId, date: selectedDate }
4091 }).done(function (data) {
4092
4093 if (data != "") {
4094 crop = data;
4095
4096 //generate new string with new crop
4097 var splitParams = lyr_comp_params.split("|");
4098 if (splitParams.length > 0) {
4099 lyr_comp_params = "";
4100 for (var i = 0; i <= splitParams.length; i++) {
4101 if (splitParams[i] != undefined) {
4102 if (i != 6) {
4103 lyr_comp_params += splitParams[i] + "|";
4104 }
4105 else {
4106 lyr_comp_params += crop + "|";
4107 }
4108 }
4109
4110
4111 }
4112
4113 //trim of last seperator
4114 lyr_comp_params = lyr_comp_params.slice(0, -1);
4115 }
4116
4117
4118 var lyr_compare_checkbox_str = "<input class=\"lyr_compare_stage1_check\" type=\"checkbox\" value=\"" + lyr_comp_params + "\" />"
4119 if (lyr_compCheck(lyr_comp_params)) {
4120 lyr_compare_checkbox_str = "<input class=\"lyr_compare_stage1_check\" type=\"checkbox\" value=\"" + lyr_comp_params + "\" checked=\"checked\" />";
4121 }
4122
4123 if (type != 12) {
4124
4125 //birds eye
4126 if (getTradingId() == 2215) {
4127 $(".left_details_panel_content").empty().html("<div class=\"imagery_layer_legend\"><p>" + fieldName + "</p><p class=\"legend_view_crop_name\">" + crop + "</p><img src=\"" + urlLegend + "\" /><p>Select " + lyr_compare_checkbox_str + "<br/><button class=\"lyr_compare_modal_lnk\">Compare</button></p><p rel=\"" + selectedOverlayImg + "|" + fieldId + "\" class=\"harvest_area_link_legend_panel\">Draw Harvest Area</p></div>");
4128 }
4129 else {
4130 $(".left_details_panel_content").empty().html("<div class=\"imagery_layer_legend\"><p>" + fieldName + "</p><p class=\"legend_view_crop_name\">" + crop + "</p><img src=\"" + urlLegend + "\" /><p>Select " + lyr_compare_checkbox_str + "<br/><button class=\"lyr_compare_modal_lnk\">Compare</button></p></div>");
4131 }
4132 }
4133 else {
4134 //birds eye
4135 if (getTradingId() == 2215) {
4136 $(".left_details_panel_content").empty().html("<div class=\"imagery_layer_legend\"><p>" + fieldName + "</p><p class=\"legend_view_crop_name\">" + crop + "</p><img src=\"" + urlLegend + "\" /></div><p rel=\"" + selectedOverlayImg + "|" + fieldId + "\" class=\"harvest_area_link_legend_panel\">Draw Harvest Area</p>");
4137 }
4138 else {
4139 $(".left_details_panel_content").empty().html("<div class=\"imagery_layer_legend\"><p>" + fieldName + "</p><p class=\"legend_view_crop_name\">" + crop + "</p><img src=\"" + urlLegend + "\" /></div>");
4140 }
4141 }
4142 }
4143 else {
4144
4145 if (lyr_comp_params.length > 0) {
4146 var splitParams = lyr_comp_params.split("|");
4147 if (splitParams.length > 0) {
4148 lyr_comp_params = "";
4149 for (var i = 0; i <= splitParams.length; i++) {
4150 if (splitParams[i] != undefined) {
4151 if (i != 6) {
4152 lyr_comp_params += splitParams[i] + "|";
4153 }
4154
4155 }
4156 }
4157
4158 //trim of last seperator
4159 lyr_comp_params = lyr_comp_params.slice(0, -1);
4160 }
4161 }
4162 var lyr_compare_checkbox_str = "<input class=\"lyr_compare_stage1_check\" type=\"checkbox\" value=\"" + lyr_comp_params + "\" />"
4163
4164 $(".left_details_panel_content").empty().html("<div class=\"imagery_layer_legend\"><p>" + fieldName + "</p><p class=\"legend_view_crop_name\">" + crop + "</p><img src=\"" + urlLegend + "\" /><p>Select " + lyr_compare_checkbox_str + "<br/><button class=\"lyr_compare_modal_lnk\">Compare</button></p></div>");
4165 }
4166 });
4167
4168 }
4169
4170}
4171
4172function displayOverlay(type) {
4173 for (var i = 0; i < im_polygon_overlay.length; i++) {
4174 if (type == im_polygon_overlay[i].type) {
4175 im_polygon_overlay[i].overlay.setMap(map);
4176 }
4177 }
4178}
4179
4180function img_clearOverlay() {
4181 debugger;
4182 for (var i = 0; i < im_polygon_overlay.length; i++) {
4183 im_polygon_overlay[i].overlay.setMap(null);
4184 }
4185
4186 im_polygon_overlay = [];
4187
4188 for (var i = 0; i < im_polygon_overlay_temp_customer_overlay.length; i++) {
4189 im_polygon_overlay_temp_customer_overlay[i].setMap(null);
4190 }
4191
4192 im_polygon_overlay_temp_customer_overlay = [];
4193
4194 for (var j = 0; j < polygonsArray.length; j++) {
4195 polygonsArray[j].setMap(map);
4196 }
4197
4198 //clear any nvz overlays
4199 lyr_clear_NVZ();
4200 //clear poi
4201 lyr_hidePOI();
4202 displayLeftDetailsPanel(false);
4203}
4204
4205function im_getImgLyrTypeName(type, subType) {
4206
4207 var name = "";
4208 if (type != "") {
4209 if (type == 1) {
4210 name = "N-Sensor";
4211 if (typeof subType !== 'undefined') {
4212 name = name + " " + subType;
4213 }
4214 }
4215 if (type == 2) {
4216 //name = "MiSat";
4217 name = "NDVI";
4218 }
4219 if (type == 3) {
4220 name = "RTK";
4221 }
4222 if (type == 4) {
4223 name = "UAV";
4224 }
4225 if (type == 6) {
4226 name = "Conductivity " + subType;
4227 }
4228 if (type == 7) {
4229 name = "MiGrass";
4230 }
4231 if (type == 8) {
4232 name = "RGB";
4233 }
4234 if (type == 9) {
4235 name = "Yield";
4236 }
4237 if (type == 12) {
4238 name = "CDax-Image";
4239 }
4240 if (type == 14) {
4241 //name = "MiSat Field View";
4242 name = "NDVI Field View";
4243 }
4244 if (type == 16) {
4245 name = "CVI Farm View";
4246 }
4247 if (type == 17) {
4248 name = "CI Green Farm View";
4249 }
4250 if (type == 18) {
4251 name = "CVI Field View";
4252 }
4253 if (type == 19) {
4254 name = "CI Green Field View";
4255 }
4256 if (type == 20) {
4257 name = "MiSAT Variety View " + " - " + subType;
4258 }
4259
4260 if (type == 21) {
4261 name = "CI Green Variety View " + " - " + subType;
4262 }
4263 }
4264 return name;
4265}
4266
4267
4268/* compare start**/
4269$(document).on("click", ".lyr_compare_stage1_check", function () {
4270
4271 if (gen_lyr_compare_count < 4) {
4272 if ($(this).is(":checked")) {
4273
4274 //add to
4275 var tempStr = "<span class=\"lyr_compare_storage_item\" rel=\"" + $(this).val() + "\"></span>";
4276 $(".lyr_compare_wrapper_storage").append(tempStr);
4277 gen_lyr_compare_count++;
4278 }
4279 else {
4280
4281 var selectedVal = $(this).val();
4282 $(".lyr_compare_wrapper_storage").children().each(function () {
4283 if ($(this).attr("rel") == selectedVal) {
4284 //remove item
4285 $(this).remove();
4286 gen_lyr_compare_count--;
4287 }
4288 })
4289 }
4290 }
4291 else {
4292 $(this).prop("checked", false);
4293 displayErrMsg(txtLyrComp1);
4294 }
4295
4296
4297});
4298
4299
4300$(document).on("click", ".lyr_lock", function (event) {
4301 event.stopImmediatePropagation();
4302 debugger;
4303 //check to see if we have any data overlay to lock
4304 if (im_polygon_overlay.length > 0) {
4305 debugger;
4306 if ($(this).hasClass("locked")) {
4307 $(this).removeClass("locked");
4308 $(this).find(".lyr_lock_txt").empty().html("Lock this layer");
4309 $(this).parent().parent().parent().removeClass("lyr_locked");
4310
4311 $(this).parent().next().removeClass("lyr_locked");
4312
4313 $(this).find(".lyr_locked_icon").removeClass("icon-noun_Lock_747565 lyr_lock_red").addClass("icon-noun_Unlock_821902");
4314 if (lyr_selectedLock == 2) {
4315 $(".imagery_layer_misat").removeClass("lyr_highlight_locked_item");
4316 }
4317 if (lyr_selectedLock == 17) {
4318 $(".imagery_layer_cigreen").removeClass("lyr_highlight_locked_item");
4319 }
4320 lyr_selectedLock = "";
4321 displaySuccessMsg(txtLy23);
4322
4323 }
4324 else {
4325 var bLyrLocked = lyr_checkLoakedLayers();
4326
4327 if (bLyrLocked) {
4328 displayErrMsg(txtLy22);
4329 }
4330 else {
4331 lyr_selectedLock = $(this).parent().parent().parent().attr("rel");
4332
4333 // TT check for CiGreen and MiSAT
4334 if (lyr_selectedLock == undefined) {
4335 if ($(this).parent().attr("rel") !== undefined) {
4336 lyr_selectedLock = $(this).parent().attr("rel");
4337 }
4338 }
4339
4340 debugger;
4341 $(this).parent().next().addClass("lyr_locked");
4342 $(this).parent().parent().parent().addClass("lyr_locked");
4343 $(this).find(".lyr_lock_txt").empty().html("Layer is locked!");
4344 $(this).find(".lyr_locked_icon").removeClass("icon-noun_Unlock_821902").addClass("icon-noun_Lock_747565 lyr_lock_red");
4345 if (lyr_selectedLock == 2) {
4346 $(".imagery_layer_misat").addClass("lyr_highlight_locked_item");
4347 }
4348
4349 if (lyr_selectedLock == 17) {
4350 $(".imagery_layer_cigreen").addClass("lyr_highlight_locked_item");
4351 }
4352
4353
4354 displaySuccessMsg(txtLy21);
4355 $(this).addClass("locked");
4356 }
4357 }
4358 }
4359 else {
4360 //do we have a harvest layer on display?
4361 if (lyr_harvest_area_poygons.length > 0) {
4362 if ($(this).hasClass("locked")) {
4363 //unlock layer
4364 $(".layer-item-harvest-areas").removeClass("lyr_highlight_locked_item");
4365 $(this).find(".lyr_locked_icon").removeClass("icon-noun_Lock_747565 lyr_lock_red").addClass("icon-noun_Unlock_821902");
4366 $(this).find(".lyr_lock_txt").empty().html("Lock this layer");
4367 $(this).removeClass("locked");
4368 $(this).parent().parent().removeClass("lyr_locked");
4369
4370 $(this).parent().next().removeClass("lyr_locked");
4371
4372 lyr_selectedLock = "";
4373 displaySuccessMsg(txtLy23);
4374
4375 }
4376 else {
4377 var bLyrLocked = lyr_checkLoakedLayers();
4378
4379 if (bLyrLocked) {
4380 displayErrMsg(txtLy22);
4381 }
4382 else {
4383 lyr_selectedLock = $(this).parent().parent().attr("rel");
4384
4385 if (lyr_selectedLock == undefined) {
4386 if ($(this).parent().attr("rel") !== undefined) {
4387 lyr_selectedLock = $(this).parent().attr("rel");
4388 }
4389 }
4390 debugger;
4391 $(this).parent().next().addClass("lyr_locked");
4392 $(this).parent().parent().addClass("lyr_locked");
4393 $(this).find(".lyr_lock_txt").empty().html("Layer is locked!");
4394 $(this).find(".lyr_locked_icon").removeClass("icon-noun_Unlock_821902").addClass("icon-noun_Lock_747565 lyr_lock_red");
4395
4396 $(".layer-item-harvest-areas").addClass("lyr_highlight_locked_item");
4397
4398 displaySuccessMsg(txtLy21);
4399 $(this).addClass("locked");
4400 }
4401
4402 }
4403 }
4404 else {
4405 displayErrMsg(txtLy24);
4406 }
4407 }
4408});
4409
4410function lyr_checkLoakedLayers() {
4411 var bLyrLocked = false;
4412 //loop through layer items to see if any of them are locked.
4413 $(".layerInfo ").each(function () {
4414 debugger;
4415 if ($(this).hasClass("lyr_locked")) {
4416 bLyrLocked = true;
4417 }
4418 });
4419 return bLyrLocked;
4420}