Changeset 33796
- Timestamp:
- 2019-12-12T15:42:19+13:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/maori-lang-detection/src/org/greenstone/atea/CountryCodeCountsMapData.java
r33794 r33796 88 88 for(JsonElement obj : countryCountsJsonArray) { 89 89 JsonObject json = obj.getAsJsonObject(); 90 String countryCode = json.get("_id").getAsString(); 90 String countryCode = json.get("_id").getAsString().toUpperCase(); 91 // set the property back as uppercase and with property name "countrycode" instead of "_id" 92 json.remove("_id"); 93 json.addProperty("countrycode", countryCode); 94 91 95 int count = (int)json.get("count").getAsDouble(); 92 96 … … 215 219 JsonObject json = obj.getAsJsonObject(); 216 220 217 String countryCode = json.get(" _id").getAsString();221 String countryCode = json.get("countrycode").getAsString(); 218 222 String region = json.get("region").getAsString(); 219 223 int count = json.get("count").getAsInt(); … … 244 248 Double lat = json.get("lat").getAsDouble(); 245 249 246 String countryCode = json.get("_id").getAsString(); 247 248 // US is a special case. Count is too high by a factor of 8. 249 // So reduce height by twice that factor, and width by twice that factor too. 250 // (A factor of 8 makes north at +125 too high for latitude, 251 // see http://www.learnz.org.nz/sites/learnz.org.nz/files/lat-long-geo-data-01_0.jpg) 252 if(countryCode.equals("US")) { 253 half_width = 16 * half_width; 254 vertical_factor = vertical_factor/16.0; 255 } 250 String countryCode = json.get("countrycode").getAsString(); 251 252 253 //create the 4 corners of the rectangle 254 // West is negative, east is positive, south is negative, north is positive 255 // See http://www.learnz.org.nz/sites/learnz.org.nz/files/lat-long-geo-data-01_0.jpg 256 // But since the histograms grow vertically/northwards and we can't go past a latitude of 90, 257 // to compensate, we increase the width of the histograms by the same factor as our inability 258 // to grow northwards. 259 Double north = lat + (vertical_factor * count); 260 while (north > 90) { 261 // recalculate north after decreasing histogram's vertical growth 262 // by the same factor as we increase its width 263 vertical_factor = vertical_factor/2.0; 264 half_width = 2 * half_width; 265 north = lat + (vertical_factor * count); 266 } 267 Double east = lng + half_width; 268 Double west = lng - half_width; 269 Double south = lat; 256 270 257 271 List<List<Position>> outerList = new LinkedList<List<Position>>(); … … 259 273 outerList.add(points); 260 274 261 //create the 4 corners of the rectangle 262 // West is negative, east is positive, south is negative, north is positive 263 // See http://www.learnz.org.nz/sites/learnz.org.nz/files/lat-long-geo-data-01_0.jpg 264 Double east = lng + half_width; 265 Double west = lng - half_width; 266 Double north = lat + (vertical_factor * count); 267 Double south = lat; 275 268 276 points.add(new Position(west, south)); // Position(lng, lat) not Position(lat, lng) 269 277 points.add(new Position(west, north));
Note:
See TracChangeset
for help on using the changeset viewer.