Changeset 33858 for other-projects/maori-lang-detection/src/org/greenstone/atea/CountryCodeCountsMapData.java
- Timestamp:
- 2020-01-22T19:31:09+13:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/maori-lang-detection/src/org/greenstone/atea/CountryCodeCountsMapData.java
r33853 r33858 347 347 // to grow northwards. 348 348 Double north = lat + (vertical_factor * count); 349 349 350 350 while (north > 90) { 351 351 // recalculate north after decreasing histogram's vertical growth … … 358 358 Double west = lng - half_width; 359 359 Double south = lat; 360 360 /* 361 System.err.println("For country " + countryCode + ":"); 362 System.err.println("north = " + north); 363 System.err.println("south = " + south); 364 System.err.println("east = " + east); 365 System.err.println("west = " + west + "\n"); 366 */ 361 367 // Check if we're dealing with very large numbers, in which case, we can have follow off the longitude edges 362 // Max longitude values are -180 to 180. So a max of 360 units between them. 368 // Max longitude values are -180 to 180. So a max of 360 units between them. (Max latitude is -90 to 90) 369 // "Longitude is in the range -180 and +180 specifying coordinates west and east of the Prime Meridian, respectively. 370 // For reference, the Equator has a latitude of 0°, the North pole has a latitude of 90° north (written 90° N or +90°), 371 // and the South pole has a latitude of -90°." 363 372 if((east + Math.abs(west)) > 360 || east > 180 || west < -180) { 364 373 half_width = HISTOGRAM_WIDTH/2; // reset half_width 365 374 366 375 double v_tmp_count = Math.sqrt(count); 367 double h_tmp_count = Math.floor(v_tmp_count); 368 v_tmp_count = Math.ceil(v_tmp_count); 376 //double h_tmp_count = Math.floor(v_tmp_count); 377 //v_tmp_count = Math.ceil(v_tmp_count); 378 double h_tmp_count = v_tmp_count; 369 379 370 380 /* 371 System.err.println("HERE, count = " + count); 372 System.err.println("HERE, v = " + v_tmp_count); 373 System.err.println("HERE, h = " + h_tmp_count); 374 System.err.println("HERE, lat = " + lat); 375 System.err.println("HERE, lng = " + lng + "\n"); 381 System.err.println("Recalculating polygon for country with high count: " + countryCode + "."); 382 System.err.println("count = " + count); 383 System.err.println("v = " + v_tmp_count); 384 System.err.println("h = " + h_tmp_count); 385 System.err.println("lat = " + lat); 386 System.err.println("lng = " + lng + "\n"); 376 387 */ 377 388 378 389 north = lat + v_tmp_count; 379 390 south = lat; 380 east = lng + (h_tmp_count/2 * half_width); // a certain width, half_width, represents one unit in the x axis 381 west = lng - (h_tmp_count/2 * half_width); 382 391 east = lng + (h_tmp_count * half_width); // a certain width, half_width, represents one unit in the x axis 392 west = lng - (h_tmp_count * half_width); 393 394 /* 395 System.err.println("north = " + north); 396 System.err.println("south = " + south); 397 System.err.println("east = " + east); 398 System.err.println("west = " + west + "\n"); 399 */ 400 383 401 if(north > 90) { 384 402 // centre vertically on lat … … 388 406 389 407 if(west < -180.0) { 390 double h_diff = lng - 180.0; // the country's longitude (lng) is h_diff from the western edge391 west = 180.0; // maximise western edge392 east = h_tmp_count - h_diff/half_width;// then grow the remainder of h_tmp_count in the opposite (eastern) direction408 double h_diff = -180.0 - west; // west is a larger negative value than -180, so subtracting west from -180 produces a positive h_diff value 409 west = -180.0; // set to extreme western edge 410 east = east + h_diff; 393 411 } 394 412 else if(east > 180.0) { 395 double h_diff = 180.0 - lng; // the country's longitude (lng) is h_diff from the eastern edge413 double h_diff = east - 180.0; // the country's longitude (lng) is h_diff from the eastern edge 396 414 east = 180.0; // maximise eastern edge 397 west = -1 * (h_tmp_count - (h_diff/half_width)); // then grow the remainder of h_tmp_count in the opposite (western) direction415 west = west - h_diff; // then grow the remainder of h_tmp_count in the opposite (western/negative) direction 398 416 } 399 417 400 // CAN'T centre on country, (lat,lng), as we don't know whether either of lat or lng has gone past the edge 401 //north = lat + (v_tmp_count/2); 402 //south = lat - (v_tmp_count/2); 403 //east = lng + (h_tmp_count/2); 404 //west = lng - (h_tmp_count/2); 405 406 // hopefully we don't exceed +90/-90 lat and +/-180 longitude 407 // "Longitude is in the range -180 and +180 specifying coordinates west and east of the Prime Meridian, respectively. 408 // For reference, the Equator has a latitude of 0°, the North pole has a latitude of 90° north (written 90° N or +90°), 409 // and the South pole has a latitude of -90°." 410 418 // NOTE: Can't centre on country, (lat,lng), as we don't know whether either of lat or lng has gone past the edge 419 420 // Hopefully we don't exceed +90/-90 lat and +/-180 longitude 411 421 /* 412 422 System.err.println("north = " + north);
Note:
See TracChangeset
for help on using the changeset viewer.