Skip to content

Commit

Permalink
Better detection of average locations.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwichary committed Dec 26, 2014
1 parent c9b7836 commit a6a1509
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ function normalizeCountryName(str) {
}

function getSampleLatLon(shapes) {
if (shapes[0] && shapes[0][0] && shapes[0][0][0]) {
if (shapes[0] && shapes[0][0] && shapes[0][0][0] && shapes[0][0][0][0]) {
return [shapes[0][0][0][0], shapes[0][0][0][1]]
} else if (shapes[0] && shapes[0][0] && shapes[0][0][0]) {
return [shapes[0][0][0], shapes[0][0][1]]
} else if (shapes[0] && shapes[0][0]) {
return [shapes[0][0], shapes[0][1]]
Expand Down Expand Up @@ -191,9 +193,13 @@ fsTools.findSorted('public/data', /[^.]+\.metadata.json/, function(err, files) {
process.exit(1)
}

var latLon = geoJsonData.features[0].geometry.coordinates[0];

var latLon = geoJsonData.features[0].geometry.coordinates;
metadata[locationName].sampleLatLon = getSampleLatLon(latLon);

if ((metadata[locationName].sampleLatLon[0] == null) || (metadata[locationName].sampleLatLon[1] == null)) {
console.log('------------------------------------------------------')
console.log('WARNING: Unknown average location for ' + locationName + '…')
}
}
}

Expand Down

0 comments on commit a6a1509

Please sign in to comment.