6 use SGN::Test::Fixture;
8 use Test::WWW::Mechanize;
11 use CXGN::Genotype::Protocol;
12 use CXGN::Genotype::Search;
15 #Needed to update IO::Socket::SSL
18 local $Data::Dumper::Indent = 0;
20 my $f = SGN::Test::Fixture->new();
21 my $schema = $f->bcs_schema;
23 for my $extension ("xls", "xlsx") {
25 my $mech = Test::WWW::Mechanize->new;
27 $mech->post_ok('http://localhost:3010/brapi/v1/token', [ "username" => "janedoe", "password" => "secretpw", "grant_type" => "password" ]);
28 my $response = decode_json $mech->content;
29 print STDERR Dumper $response;
30 is($response->{'metadata'}->{'status'}->[2]->{'message'}, 'Login Successfull');
31 my $sgn_session_id = $response->{access_token};
32 print STDERR $sgn_session_id . "\n";
34 my $ua = LWP::UserAgent->new;
35 $response = $ua->get('http://localhost:3010/api/drone_imagery/upload_drone_imagery_check_drone_name?sgn_session_id=' . $sgn_session_id . '&drone_run_name=NewDroneRunProject');
37 ok($response->is_success);
38 my $message = $response->decoded_content;
39 my $message_hash = decode_json $message;
40 print STDERR Dumper $message_hash;
41 is_deeply($message_hash, { 'success' => 1 });
43 my $field_trial_id = $schema->resultset("Project::Project")->search({ name => 'test_trial' })->first->project_id();
45 $response = $ua->get('http://localhost:3010/api/drone_imagery/new_imaging_vehicle?sgn_session_id=' . $sgn_session_id . '&vehicle_name=Drone1&vehicle_description=dronedesc&battery_names=blue,green');
46 ok($response->is_success);
47 my $message = $response->decoded_content;
48 my $message_hash = decode_json $message;
49 print STDERR Dumper $message_hash;
50 ok($message_hash->{success});
51 ok($message_hash->{new_vehicle_id});
52 my $new_vehicle_id = $message_hash->{new_vehicle_id};
54 if ($f->config->{enable_opendronemap}) {
56 #Testing upload of unstitched Micasense RedEdge 5 band raw captures.
57 my $file_micasense5channel_image_zip = "/home/production/public/static_content/imagebreed/AlfalfaExample35MeterMicasenseAerialDroneFlightRawCaptures.zip";
58 my $micasense5bandpanelzipfile = $f->config->{basepath} . "/t/data/imagebreed/ExampleAerialDroneFlightMicasensePanel.zip";
59 $ua = LWP::UserAgent->new;
61 my $response_micasense_stitch = $ua->post(
62 'http://localhost:3010/api/drone_imagery/upload_drone_imagery',
63 Content_Type => 'form-data',
65 "sgn_session_id" => $sgn_session_id,
66 upload_drone_images_zipfile => [ $file_micasense5channel_image_zip, 'upload_drone_images_zipfile' ],
67 upload_drone_images_panel_zipfile => [ $micasense5bandpanelzipfile, 'upload_drone_images_panel_zipfile' ],
68 "drone_run_field_trial_id" => $field_trial_id,
69 "drone_run_name" => "NewMicasenseUnstitchedDroneRunProject",
70 "drone_run_type" => "Aerial Medium to High Res",
71 "drone_run_date" => "2019/01/03 12:12:12",
72 "drone_run_description" => "test new drone run",
73 "drone_run_imaging_vehicle_id" => $new_vehicle_id,
74 "drone_run_imaging_vehicle_battery_name" => "blue",
75 "drone_image_upload_camera_info" => "micasense_5",
76 "drone_image_upload_drone_run_band_stitching" => "yes_open_data_map_stitch"
80 ok($response_micasense_stitch->is_success);
81 my $message_micasense_stitch = $response_micasense_stitch->decoded_content;
82 my $message_hash_micasense_stitch = decode_json $message_micasense_stitch;
83 print STDERR Dumper $message_hash_micasense_stitch;
84 is($message_hash_micasense_stitch->{success}, 1);
85 is(scalar(@{$message_hash_micasense_stitch->{drone_run_band_project_ids}}), 6);
86 is(scalar(@{$message_hash_micasense_stitch->{drone_run_band_image_ids}}), 6);
88 #Testing upload of RGB unstitched raw captures.
89 my $rgbrawimageszipfile = "/home/production/public/static_content/imagebreed/ExampleColorAerialDroneFlightRawCaptures.zip";
90 $ua = LWP::UserAgent->new;
92 my $response_rgb_stitch = $ua->post(
93 'http://localhost:3010/api/drone_imagery/upload_drone_imagery',
94 Content_Type => 'form-data',
96 "sgn_session_id" => $sgn_session_id,
97 upload_drone_images_zipfile => [ $rgbrawimageszipfile, 'upload_drone_images_zipfile' ],
98 "drone_run_field_trial_id" => $field_trial_id,
99 "drone_run_name" => "NewRGBUnstitchedDroneRunProject",
100 "drone_run_type" => "Aerial Medium to High Res",
101 "drone_run_date" => "2019/01/02 12:12:12",
102 "drone_run_description" => "test new drone run",
103 "drone_run_imaging_vehicle_id" => $new_vehicle_id,
104 "drone_run_imaging_vehicle_battery_name" => "blue",
105 "drone_image_upload_camera_info" => "ccd_color",
106 "drone_image_upload_drone_run_band_stitching" => "yes_open_data_map_stitch"
110 ok($response_rgb_stitch->is_success);
111 my $message_rgb_stitch = $response_rgb_stitch->decoded_content;
112 my $message_hash_rgb_stitch = decode_json $message_rgb_stitch;
113 print STDERR Dumper $message_hash_rgb_stitch;
114 is($message_hash_rgb_stitch->{success}, 1);
115 is(scalar(@{$message_hash_rgb_stitch->{drone_run_band_project_ids}}), 2);
116 is(scalar(@{$message_hash_rgb_stitch->{drone_run_band_image_ids}}), 2);
120 #Testing upload of RGB unstitched raw captures.
121 my $rasterblue = $f->config->{basepath} . "/t/data/imagebreed/RasterBlue.png";
122 my $rastergreen = $f->config->{basepath} . "/t/data/imagebreed/RasterGreen.png";
123 my $rasterred = $f->config->{basepath} . "/t/data/imagebreed/RasterRed.png";
124 my $rasternir = $f->config->{basepath} . "/t/data/imagebreed/RasterNIR.png";
125 my $rasterrededge = $f->config->{basepath} . "/t/data/imagebreed/RasterRedEdge.png";
126 $ua = LWP::UserAgent->new;
127 my $response_raster = $ua->post(
128 'http://localhost:3010/api/drone_imagery/upload_drone_imagery',
129 Content_Type => 'form-data',
131 "sgn_session_id" => $sgn_session_id,
132 "drone_run_field_trial_id" => $field_trial_id,
133 "drone_run_name" => "NewStitchedMicasense5BandDroneRunProject",
134 "drone_run_type" => "Aerial Medium to High Res",
135 "drone_run_date" => "2019/01/01 12:12:12",
136 "drone_run_description" => "test new drone run",
137 "drone_image_upload_camera_info" => "micasense_5",
138 "drone_run_imaging_vehicle_id" => $new_vehicle_id,
139 "drone_run_imaging_vehicle_battery_name" => "blue",
140 "drone_image_upload_drone_run_band_stitching" => "no",
141 "drone_run_band_number" => 5,
142 "drone_run_band_name_0" => "NewStitchedMicasense5BandDroneRunProject_Blue",
143 "drone_run_band_description_0" => "raster blue",
144 "drone_run_band_type_0" => "Blue (450-520nm)",
145 drone_run_band_stitched_ortho_image_0 => [ $rasterblue, basename($rasterblue) ],
146 "drone_run_band_name_1" => "NewStitchedMicasense5BandDroneRunProject_Green",
147 "drone_run_band_description_1" => "raster green",
148 "drone_run_band_type_1" => "Green (515-600nm)",
149 drone_run_band_stitched_ortho_image_1 => [ $rastergreen, basename($rastergreen) ],
150 "drone_run_band_name_2" => "NewStitchedMicasense5BandDroneRunProject_Red",
151 "drone_run_band_description_2" => "raster red",
152 "drone_run_band_type_2" => "Red (600-690nm)",
153 drone_run_band_stitched_ortho_image_2 => [ $rasterred, basename($rasterred) ],
154 "drone_run_band_name_3" => "NewStitchedMicasense5BandDroneRunProject_NIR",
155 "drone_run_band_description_3" => "raster NIR",
156 "drone_run_band_type_3" => "NIR (780-3000nm)",
157 drone_run_band_stitched_ortho_image_3 => [ $rasternir, basename($rasternir) ],
158 "drone_run_band_name_4" => "NewStitchedMicasense5BandDroneRunProject_RedEdge",
159 "drone_run_band_description_4" => "raster rededge",
160 "drone_run_band_type_4" => "Red Edge (690-750nm)",
161 drone_run_band_stitched_ortho_image_4 => [ $rasterrededge, basename($rasterrededge) ],
165 ok($response_raster->is_success);
166 my $message_raster = $response_raster->decoded_content;
167 my $message_hash_raster = decode_json $message_raster;
168 print STDERR Dumper $message_hash_raster;
169 is($message_hash_raster->{success}, 1);
170 is(scalar(@{$message_hash_raster->{drone_run_band_project_ids}}), 5);
171 is(scalar(@{$message_hash_raster->{drone_run_band_image_ids}}), 5);
172 my $a_drone_run_project_id = $message_hash_raster->{drone_run_project_id};
173 ok($a_drone_run_project_id);
175 $ua = LWP::UserAgent->new;
176 my $response_get_image = $ua->get('http://localhost:3010/api/drone_imagery/get_image?sgn_session_id=' . $sgn_session_id . '&image_id=' . $message_hash_raster->{drone_run_band_image_ids}->[0]);
177 ok($response_get_image->is_success);
178 my $message_get_image = $response_get_image->decoded_content;
179 my $message_hash_get_image = decode_json $message_get_image;
180 print STDERR Dumper $message_hash_get_image;
181 ok($message_hash_get_image->{image_url});
182 ok($message_hash_get_image->{image_fullpath});
183 is($message_hash_get_image->{image_width}, 1280);
184 is($message_hash_get_image->{image_height}, 960);
186 $ua = LWP::UserAgent->new;
187 my $response_denoised = $ua->get('http://localhost:3010/api/drone_imagery/denoise?sgn_session_id=' . $sgn_session_id . '&image_id=' . $message_hash_raster->{drone_run_band_image_ids}->[0] . '&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0]);
188 ok($response_denoised->is_success);
189 my $message_denoised = $response_denoised->decoded_content;
190 my $message_hash_denoised = decode_json $message_denoised;
191 print STDERR Dumper $message_hash_denoised;
192 ok($message_hash_denoised->{denoised_image_id});
193 ok($message_hash_denoised->{denoised_image_url});
195 my $sp_rotate_angle = "2.1";
196 my $sp_rotate_angle_rad = $sp_rotate_angle * 0.0174533;
198 $ua = LWP::UserAgent->new;
199 my $response_rotate = $ua->get('http://localhost:3010/api/drone_imagery/rotate_image?sgn_session_id=' . $sgn_session_id . '&image_id=' . $message_hash_denoised->{denoised_image_id} . '&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0] . '&angle=' . $sp_rotate_angle . '&view_only=0');
200 ok($response_rotate->is_success);
201 my $message_rotate = $response_rotate->decoded_content;
202 my $message_hash_rotate = decode_json $message_rotate;
203 print STDERR Dumper $message_hash_rotate;
204 ok($message_hash_rotate->{rotated_image_id});
205 ok($message_hash_rotate->{rotated_image_url});
207 my $crop_polygon = [ { 'x' => 100, 'y' => 100 }, { 'x' => 120, 'y' => 100 }, { 'x' => 120, 'y' => 80 }, { 'x' => 100, 'y' => 70 } ];
208 my $polygon_crop = encode_json $crop_polygon;
209 $ua = LWP::UserAgent->new;
210 my $response_crop = $ua->get('http://localhost:3010/api/drone_imagery/crop_image?sgn_session_id=' . $sgn_session_id . '&image_id=' . $message_hash_rotate->{rotated_image_id} . '&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0] . '&polygon=' . $polygon_crop);
211 ok($response_crop->is_success);
212 my $message_crop = $response_crop->decoded_content;
213 my $message_hash_crop = decode_json $message_crop;
214 print STDERR Dumper $message_hash_crop;
215 ok($message_hash_crop->{cropped_image_id});
216 ok($message_hash_crop->{cropped_image_url});
218 $ua = LWP::UserAgent->new;
219 my $response_background_removed = $ua->post('http://localhost:3010/api/drone_imagery/remove_background_save?sgn_session_id=' . $sgn_session_id . '&image_id=' . $message_hash_crop->{cropped_image_id} . '&image_type=threshold_background_removed_stitched_drone_imagery_blue&lower_threshold=20&upper_threshold=180&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0]);
220 ok($response_background_removed->is_success);
221 my $message_background_removed = $response_background_removed->decoded_content;
222 my $message_hash_background_removed = decode_json $message_background_removed;
223 print STDERR Dumper $message_hash_background_removed;
224 ok($message_hash_background_removed->{removed_background_image_id});
225 ok($message_hash_background_removed->{removed_background_image_url});
227 $ua = LWP::UserAgent->new;
228 my $response_background_removed_percentage = $ua->post('http://localhost:3010/api/drone_imagery/remove_background_percentage_save?sgn_session_id=' . $sgn_session_id . '&image_id=' . $message_hash_crop->{cropped_image_id} . '&image_type_list=threshold_background_removed_stitched_drone_imagery_blue&lower_threshold_percentage=20&upper_threshold_percentage=20&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0]);
229 ok($response_background_removed_percentage->is_success);
230 my $message_background_removed_percentage = $response_background_removed_percentage->decoded_content;
231 my $message_hash_background_removed_percentage = decode_json $message_background_removed_percentage;
232 print STDERR Dumper $message_hash_background_removed_percentage;
233 ok($message_hash_background_removed_percentage->[0]->{removed_background_image_id});
234 ok($message_hash_background_removed_percentage->[0]->{removed_background_image_url});
236 $ua = LWP::UserAgent->new;
237 my $response_contours = $ua->get('http://localhost:3010/api/drone_imagery/get_contours?sgn_session_id=' . $sgn_session_id . '&image_id=' . $message_hash_raster->{drone_run_band_image_ids}->[0] . '&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0]);
238 ok($response_contours->is_success);
239 my $message_contours = $response_contours->decoded_content;
240 my $message_hash_contours = decode_json $message_contours;
241 print STDERR Dumper $message_hash_contours;
242 ok($message_hash_contours->{contours_image_id});
243 ok($message_hash_contours->{contours_image_url});
245 my %stock_polygons = ('test_trial1' => [ { 'x' => 1, 'y' => 1 }, { 'x' => 12, 'y' => 1 }, { 'x' => 12, 'y' => 8 }, { 'x' => 1, 'y' => 7 }, { 'x' => 1, 'y' => 1 } ]);
246 my $stock_polygon_json = encode_json \%stock_polygons;
248 $ua = LWP::UserAgent->new;
249 my $response_save_template = $ua->post('http://localhost:3010/api/drone_imagery/save_plot_polygons_template?sgn_session_id=' . $sgn_session_id . '&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0] . '&stock_polygons=' . $stock_polygon_json);
250 ok($response_save_template->is_success);
251 my $message_save_template = $response_save_template->decoded_content;
252 my $message_hash_save_template = decode_json $message_save_template;
253 print STDERR Dumper $message_hash_save_template;
254 ok($message_hash_save_template->{success});
255 ok($message_hash_save_template->{drone_run_band_template_id});
257 $ua = LWP::UserAgent->new;
258 my $response_assign_plot_polygons = $ua->post('http://localhost:3010/api/drone_imagery/assign_plot_polygons?sgn_session_id=' . $sgn_session_id . '&image_id=' . $message_hash_crop->{cropped_image_id} . '&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0] . '&stock_polygons=' . $stock_polygon_json . '&assign_plot_polygons_type=observation_unit_polygon_blue_imagery');
259 ok($response_assign_plot_polygons->is_success);
260 my $message_assign_plot_polygons = $response_assign_plot_polygons->decoded_content;
261 my $message_hash_assign_plot_polygons = decode_json $message_assign_plot_polygons;
262 print STDERR Dumper $message_hash_assign_plot_polygons;
263 ok($message_hash_assign_plot_polygons->{success});
264 ok($message_hash_assign_plot_polygons->{drone_run_band_template_id});
266 $ua = LWP::UserAgent->new;
267 my $response_get_template = $ua->get('http://localhost:3010/api/drone_imagery/retrieve_parameter_template?plot_polygons_template_projectprop_id=' . $message_hash_assign_plot_polygons->{drone_run_band_template_id});
268 ok($response_get_template->is_success);
269 my $message_get_template = $response_get_template->decoded_content;
270 my $message_hash_get_template = decode_json $message_get_template;
271 print STDERR Dumper $message_hash_get_template;
272 ok($message_hash_get_template->{success});
273 ok($message_hash_get_template->{parameter});
275 $ua = LWP::UserAgent->new;
276 my $response_drone_runs = $ua->get('http://localhost:3010/api/drone_imagery/drone_runs?select_checkbox_name=drone_test_checkbox&field_trial_id=' . $field_trial_id);
277 ok($response_drone_runs->is_success);
278 my $message_drone_runs = $response_drone_runs->decoded_content;
279 my $message_hash_drone_runs = decode_json $message_drone_runs;
280 print STDERR Dumper $message_hash_drone_runs;
281 if ($f->config->{enable_opendronemap}) {
282 is(scalar(@{$message_hash_drone_runs->{data}}), 3);
285 is(scalar(@{$message_hash_drone_runs->{data}}), 1);
288 $ua = LWP::UserAgent->new;
289 my $response_image_types = $ua->get('http://localhost:3010/api/drone_imagery/plot_polygon_types?select_checkbox_name=drone_test_checkbox&field_trial_id=' . $field_trial_id);
290 ok($response_image_types->is_success);
291 my $message_image_types = $response_image_types->decoded_content;
292 my $message_hash_image_types = decode_json $message_image_types;
293 print STDERR Dumper $message_hash_image_types;
294 is(scalar(@{$message_hash_image_types->{data}}), 1);
296 $ua = LWP::UserAgent->new;
297 my $response_drone_run_bands = $ua->get('http://localhost:3010/api/drone_imagery/drone_run_bands?select_checkbox_name=drone_test_checkbox&field_trial_id=' . $field_trial_id . '&drone_run_project_id=' . $message_hash_raster->{drone_run_project_id});
298 ok($response_drone_run_bands->is_success);
299 my $message_drone_run_bands = $response_drone_run_bands->decoded_content;
300 my $message_hash_drone_run_bands = decode_json $message_drone_run_bands;
301 print STDERR Dumper $message_hash_drone_run_bands;
302 is(scalar(@{$message_hash_drone_run_bands->{data}}), 5);
304 $ua = LWP::UserAgent->new;
305 my $response_weeks_after_planting = $ua->get('http://localhost:3010/api/drone_imagery/get_weeks_after_planting_date?select_checkbox_name=drone_test_checkbox&field_trial_id=' . $field_trial_id . '&drone_run_project_id=' . $message_hash_raster->{drone_run_project_id});
306 ok($response_weeks_after_planting->is_success);
307 my $message_weeks_after_planting = $response_weeks_after_planting->decoded_content;
308 my $message_hash_weeks_after_planting = decode_json $message_weeks_after_planting;
309 my $message_hash_days_time_cvterm_id = $message_hash_weeks_after_planting->{time_ontology_day_cvterm_id};
310 ok($message_hash_days_time_cvterm_id);
311 print STDERR Dumper $message_hash_weeks_after_planting;
312 ok($message_hash_weeks_after_planting->{drone_run_date});
313 is($message_hash_weeks_after_planting->{rounded_time_difference_weeks}, 78);
315 $ua = LWP::UserAgent->new;
317 my $apply_drone_run_band_project_ids = encode_json $message_hash_raster->{drone_run_band_project_ids};
318 my $vegetative_indices = encode_json [ 'TGI', 'VARI', 'NDVI', 'NDRE' ];
319 my $response_standard_process = $ua->post('http://localhost:3010/api/drone_imagery/standard_process_apply?sgn_session_id=' . $sgn_session_id . '&apply_drone_run_band_project_ids=' . $apply_drone_run_band_project_ids . '&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0] . '&drone_run_project_id=' . $message_hash_raster->{drone_run_project_id} . '&vegetative_indices=' . $vegetative_indices . '&field_trial_id=' . $field_trial_id);
320 ok($response_standard_process->is_success);
321 my $message_standard_process = $response_standard_process->decoded_content;
322 my $message_hash_standard_process = decode_json $message_standard_process;
323 print STDERR Dumper $message_hash_standard_process;
324 ok($message_hash_standard_process->{success});
326 # my $response_extended = $ua->get('http://localhost:3010/api/drone_imagery/standard_process_extended_apply?sgn_session_id='.$sgn_session_id.'&drone_run_project_id='.$message_hash_raster->{drone_run_project_id});
327 # ok($response_extended->is_success);
328 # my $message_extended = $response_extended->decoded_content;
329 # my $message_hash_extended = decode_json $message_extended;
330 # print STDERR Dumper $message_hash_extended;
331 # ok($message_hash_extended->{success});
333 $ua = LWP::UserAgent->new;
334 my $saving_gcp_template_1 = $ua->post(
335 'http://localhost:3010/api/drone_imagery/saving_gcp',
336 Content_Type => 'form-data',
338 "sgn_session_id" => $sgn_session_id,
339 "drone_run_project_id" => $a_drone_run_project_id,
343 "latitude" => "62.21",
344 "longitude" => "-79.11"
347 ok($saving_gcp_template_1->is_success);
349 my $saving_gcp_template_2 = $ua->post(
350 'http://localhost:3010/api/drone_imagery/saving_gcp',
351 Content_Type => 'form-data',
353 "sgn_session_id" => $sgn_session_id,
354 "drone_run_project_id" => $a_drone_run_project_id,
358 "latitude" => "63.21",
359 "longitude" => "-78.11"
362 ok($saving_gcp_template_2->is_success);
364 my $saving_gcp_template_3 = $ua->post(
365 'http://localhost:3010/api/drone_imagery/saving_gcp',
366 Content_Type => 'form-data',
368 "sgn_session_id" => $sgn_session_id,
369 "drone_run_project_id" => $a_drone_run_project_id,
377 ok($saving_gcp_template_3->is_success);
379 my $saving_gcp_template_4 = $ua->post(
380 'http://localhost:3010/api/drone_imagery/saving_gcp',
381 Content_Type => 'form-data',
383 "sgn_session_id" => $sgn_session_id,
384 "drone_run_project_id" => $a_drone_run_project_id,
392 ok($saving_gcp_template_4->is_success);
394 my $message_save_gcp_template = $saving_gcp_template_4->decoded_content;
395 my $message_hash_gcp_template = decode_json $message_save_gcp_template;
396 print STDERR Dumper $message_hash_gcp_template;
397 is_deeply($message_hash_gcp_template->{saved_gcps_full}, { 'GCP4' => { 'x_pos' => '102', 'longitude' => '', 'name' => 'GCP4', 'latitude' => '', 'y_pos' => '105' }, 'GCP3' => { 'longitude' => '', 'x_pos' => '101', 'y_pos' => '105', 'latitude' => '', 'name' => 'GCP3' }, 'GCP2' => { 'x_pos' => '105', 'longitude' => '-78.11', 'name' => 'GCP2', 'latitude' => '63.21', 'y_pos' => '105' }, 'GCP1' => { 'name' => 'GCP1', 'latitude' => '62.21', 'y_pos' => '101', 'x_pos' => '101', 'longitude' => '-79.11' } });
399 $ua = LWP::UserAgent->new;
400 my $response_raster_gcp_run = $ua->post(
401 'http://localhost:3010/api/drone_imagery/upload_drone_imagery',
402 Content_Type => 'form-data',
404 "sgn_session_id" => $sgn_session_id,
405 "drone_run_field_trial_id" => $field_trial_id,
406 "drone_run_name" => "NewStitchedMicasense5BandDroneRunProjectForGCPStandardProcess",
407 "drone_run_type" => "Aerial Medium to High Res",
408 "drone_run_date" => "2019/01/01 18:12:12",
409 "drone_run_description" => "test new drone run",
410 "drone_image_upload_camera_info" => "micasense_5",
411 "drone_image_upload_drone_run_band_stitching" => "no",
412 "drone_run_imaging_vehicle_id" => $new_vehicle_id,
413 "drone_run_imaging_vehicle_battery_name" => "blue",
414 "drone_run_band_number" => 5,
415 "drone_run_band_name_0" => "NewStitchedMicasense5BandDroneRunProjectForGCPStandardProcess_Blue",
416 "drone_run_band_description_0" => "raster blue",
417 "drone_run_band_type_0" => "Blue (450-520nm)",
418 drone_run_band_stitched_ortho_image_0 => [ $rasterblue, basename($rasterblue) ],
419 "drone_run_band_name_1" => "NewStitchedMicasense5BandDroneRunProjectForGCPStandardProcess_Green",
420 "drone_run_band_description_1" => "raster green",
421 "drone_run_band_type_1" => "Green (515-600nm)",
422 drone_run_band_stitched_ortho_image_1 => [ $rastergreen, basename($rastergreen) ],
423 "drone_run_band_name_2" => "NewStitchedMicasense5BandDroneRunProjectForGCPStandardProcess_Red",
424 "drone_run_band_description_2" => "raster red",
425 "drone_run_band_type_2" => "Red (600-690nm)",
426 drone_run_band_stitched_ortho_image_2 => [ $rasterred, basename($rasterred) ],
427 "drone_run_band_name_3" => "NewStitchedMicasense5BandDroneRunProjectForGCPStandardProcess_NIR",
428 "drone_run_band_description_3" => "raster NIR",
429 "drone_run_band_type_3" => "NIR (780-3000nm)",
430 drone_run_band_stitched_ortho_image_3 => [ $rasternir, basename($rasternir) ],
431 "drone_run_band_name_4" => "NewStitchedMicasense5BandDroneRunProjectForGCPStandardProcess_RedEdge",
432 "drone_run_band_description_4" => "raster rededge",
433 "drone_run_band_type_4" => "Red Edge (690-750nm)",
434 drone_run_band_stitched_ortho_image_4 => [ $rasterrededge, basename($rasterrededge) ],
438 ok($response_raster_gcp_run->is_success);
439 my $message_raster_gcp_run = $response_raster_gcp_run->decoded_content;
440 my $message_hash_raster_gcp_run = decode_json $message_raster_gcp_run;
441 print STDERR Dumper $message_hash_raster_gcp_run;
442 is($message_hash_raster_gcp_run->{success}, 1);
443 is(scalar(@{$message_hash_raster_gcp_run->{drone_run_band_project_ids}}), 5);
444 is(scalar(@{$message_hash_raster_gcp_run->{drone_run_band_image_ids}}), 5);
445 my $gcp_apply_drone_run_project_id = $message_hash_raster_gcp_run->{drone_run_project_id};
446 ok($gcp_apply_drone_run_project_id);
448 my $saving_gcp_target_1 = $ua->post(
449 'http://localhost:3010/api/drone_imagery/saving_gcp',
450 Content_Type => 'form-data',
452 "sgn_session_id" => $sgn_session_id,
453 "drone_run_project_id" => $gcp_apply_drone_run_project_id,
457 "latitude" => "62.21",
458 "longitude" => "-79.11"
461 ok($saving_gcp_target_1->is_success);
463 my $saving_gcp_target_2 = $ua->post(
464 'http://localhost:3010/api/drone_imagery/saving_gcp',
465 Content_Type => 'form-data',
467 "sgn_session_id" => $sgn_session_id,
468 "drone_run_project_id" => $gcp_apply_drone_run_project_id,
472 "latitude" => "63.21",
473 "longitude" => "-78.11"
476 ok($saving_gcp_target_2->is_success);
478 my $saving_gcp_target_3 = $ua->post(
479 'http://localhost:3010/api/drone_imagery/saving_gcp',
480 Content_Type => 'form-data',
482 "sgn_session_id" => $sgn_session_id,
483 "drone_run_project_id" => $gcp_apply_drone_run_project_id,
491 ok($saving_gcp_target_3->is_success);
493 my $saving_gcp_target_4 = $ua->post(
494 'http://localhost:3010/api/drone_imagery/saving_gcp',
495 Content_Type => 'form-data',
497 "sgn_session_id" => $sgn_session_id,
498 "drone_run_project_id" => $gcp_apply_drone_run_project_id,
506 ok($saving_gcp_target_4->is_success);
508 $ua = LWP::UserAgent->new;
510 my $response_raster_gcp_apply = $ua->post('http://localhost:3010/api/drone_imagery/standard_process_apply_ground_control_points?sgn_session_id=' . $sgn_session_id . '&gcp_drone_run_project_id=' . $a_drone_run_project_id . '&field_trial_id=' . $field_trial_id . '&drone_run_project_id=' . $gcp_apply_drone_run_project_id . '&drone_run_band_project_id=' . $message_hash_raster_gcp_run->{drone_run_band_project_ids}->[3] . '&time_cvterm_id=' . $message_hash_days_time_cvterm_id . '&is_test=1&test_run=No');
511 ok($response_raster_gcp_apply->is_success);
512 my $message_raster_gcp_apply = $response_raster_gcp_apply->decoded_content;
513 my $message_hash_raster_gcp_apply = decode_json $message_raster_gcp_apply;
514 print STDERR Dumper $message_hash_raster_gcp_apply;
515 is($message_hash_raster_gcp_apply->{success}, 1);
517 my $response_project_md_image = $ua->get('http://localhost:3010/api/drone_imagery/get_project_md_image?sgn_session_id=' . $sgn_session_id . '&drone_run_band_project_id=' . $message_hash_raster->{drone_run_band_project_ids}->[0] . '&project_image_type_name=observation_unit_polygon_blue_imagery');
518 ok($response_project_md_image->is_success);
519 my $message_project_md_image = $response_project_md_image->decoded_content;
520 my $message_hash_project_md_image = decode_json $message_project_md_image;
521 print STDERR Dumper $message_hash_project_md_image;
522 ok($message_hash_project_md_image->{data});
524 my $response_remove_image = $ua->get('http://localhost:3010/api/drone_imagery/remove_image?sgn_session_id=' . $sgn_session_id . '&image_id=' . $message_hash_raster->{drone_run_band_image_ids}->[0]);
525 ok($response_remove_image->is_success);
526 my $message_remove_image = $response_remove_image->decoded_content;
527 my $message_hash_remove_image = decode_json $message_remove_image;
528 print STDERR Dumper $message_hash_remove_image;
529 ok($message_hash_remove_image->{status});
531 #Testing upload of bulk imaging events
533 my $file_previous_geotiff_image_zip = "/home/production/public/static_content/imagebreed/RiceExampleRGBandDSMOrthophotosGeoTIFFs.zip";
534 my $file_previous_geojson_zip = "/home/production/public/static_content/imagebreed/RiceExampleGeoJSONs.zip";
535 my $file_previous_imaging_events = "/home/production/public/static_content/imagebreed/RiceExampleRGBandDSMGeoJSONImagingEvent.$extension";
537 my $bulk_loading_csv = $f->config->{basepath} . "/t/data/imagebreed/bulk_loading/BTI_rig_images.$extension";
538 my $bulk_loading_image_zip = $f->config->{basepath} . "/t/data/imagebreed/bulk_loading/BTI_rig_images.zip";
541 skip 'Some required files not available for these tests', 6, unless ((-e $file_previous_geotiff_image_zip) && (-e $file_previous_geojson_zip) && (-e $file_previous_imaging_events) && (-e $bulk_loading_csv) && (-e $bulk_loading_image_zip));
543 $ua = LWP::UserAgent->new;
545 my $response_raster = $ua->post(
546 'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk',
547 Content_Type => 'form-data',
549 "sgn_session_id" => $sgn_session_id,
550 upload_drone_imagery_bulk_images_zipfile => [ $bulk_loading_image_zip, basename($bulk_loading_image_zip) ],
551 upload_drone_imagery_bulk_imaging_events => [ $bulk_loading_csv, basename($bulk_loading_csv) ],
555 ok($response_raster->is_success);
556 my $message_raster = $response_raster->decoded_content;
557 print STDERR Dumper $message_raster;
558 ok($message_raster =~ /Successfully uploaded!/);
560 $ua = LWP::UserAgent->new;
562 my $response_raster = $ua->post(
563 'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk_previous',
564 Content_Type => 'form-data',
566 "sgn_session_id" => $sgn_session_id,
567 upload_drone_imagery_bulk_images_zipfile_previous => [ $file_previous_geotiff_image_zip, basename($file_previous_geotiff_image_zip) ],
568 upload_drone_imagery_bulk_geojson_zipfile_previous => [ $file_previous_geojson_zip, basename($file_previous_geojson_zip) ],
569 upload_drone_imagery_bulk_imaging_events_previous => [ $file_previous_imaging_events, basename($file_previous_imaging_events) ],
573 ok($response_raster->is_success);
574 my $message_raster = $response_raster->decoded_content;
575 print STDERR Dumper $message_raster;
576 ok($message_raster =~ /Successfully uploaded!/);
578 my $rasterblue = $f->config->{basepath} . "/t/data/imagebreed/RasterBlue.png";
579 my $rastergreen = $f->config->{basepath} . "/t/data/imagebreed/RasterGreen.png";
580 my $rasterred = $f->config->{basepath} . "/t/data/imagebreed/RasterRed.png";
581 my $rasternir = $f->config->{basepath} . "/t/data/imagebreed/RasterNIR.png";
582 my $rasterrededge = $f->config->{basepath} . "/t/data/imagebreed/RasterRedEdge.png";
583 $ua = LWP::UserAgent->new;
585 my $response_raster = $ua->post(
586 'http://localhost:3010/drone_imagery/upload_drone_imagery',
587 Content_Type => 'form-data',
589 "sgn_session_id" => $sgn_session_id,
590 "drone_run_field_trial_id" => $field_trial_id,
591 "drone_run_name" => "NewStitchedMicasense5BandDroneRunProjectTESTING",
592 "drone_run_type" => "Aerial Medium to High Res",
593 "drone_run_date" => "2019/02/01 13:14:15",
594 "drone_run_description" => "test new drone run",
595 "drone_image_upload_camera_info" => "micasense_5",
596 "drone_run_imaging_vehicle_id" => $new_vehicle_id,
597 "drone_run_imaging_vehicle_battery_name" => "blue",
598 "drone_image_upload_drone_run_band_stitching" => "no",
599 "drone_run_band_number" => 5,
600 "drone_run_band_name_1" => "NewStitchedMicasense5BandDroneRunProjectTESTING_Blue",
601 "drone_run_band_description_1" => "raster blue",
602 "drone_run_band_type_1" => "Blue (450-520nm)",
603 drone_run_band_stitched_ortho_image_1 => [ $rasterblue, basename($rasterblue) ],
604 "drone_run_band_name_2" => "NewStitchedMicasense5BandDroneRunProjectTESTING_Green",
605 "drone_run_band_description_2" => "raster green",
606 "drone_run_band_type_2" => "Green (515-600nm)",
607 drone_run_band_stitched_ortho_image_2 => [ $rastergreen, basename($rastergreen) ],
608 "drone_run_band_name_3" => "NewStitchedMicasense5BandDroneRunProjectTESTING_Red",
609 "drone_run_band_description_3" => "raster red",
610 "drone_run_band_type_3" => "Red (600-690nm)",
611 drone_run_band_stitched_ortho_image_3 => [ $rasterred, basename($rasterred) ],
612 "drone_run_band_name_4" => "NewStitchedMicasense5BandDroneRunProjectTESTING_NIR",
613 "drone_run_band_description_4" => "raster NIR",
614 "drone_run_band_type_4" => "NIR (780-3000nm)",
615 drone_run_band_stitched_ortho_image_4 => [ $rasternir, basename($rasternir) ],
616 "drone_run_band_name_5" => "NewStitchedMicasense5BandDroneRunProjectTESTING_RedEdge",
617 "drone_run_band_description_5" => "raster rededge",
618 "drone_run_band_type_5" => "Red Edge (690-750nm)",
619 drone_run_band_stitched_ortho_image_5 => [ $rasterrededge, basename($rasterrededge) ],
623 ok($response_raster->is_success);
624 my $message_raster = $response_raster->decoded_content;
625 print STDERR Dumper $message_raster;
626 ok($message_raster =~ /Successfully uploaded!/);