Open rogerallen opened 3 years ago
Trying out the Earthquake sample, I was confused by where the earthquakes were appearing. I tracked it down to swapped latitude, longitude usage.
In https://github.com/cinder/Cinder/blob/master/samples/Earthquake/src/EarthquakeApp.cpp parseEarthquakes() the code parses the coordinates of the earthquakes via:
auto &coords = feature["geometry"]["coordinates"];
and inserts them like so:
mEarth.addQuake( coords[0].getValue<float>(), coords[1].getValue<float>(), mag, title );
The addQuake routine signature expects coords in the order Lat, Lon
void Earth::addQuake( float aLat, float aLong, float aMag, const std::string &aTitle )
but the earthquake data in GeoJSON is in Lon, Lat order. See: https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
geometry: { type: "Point", coordinates: [ longitude, latitude, depth ]
swapping the coordinate order to the call fixes this:
mEarth.addQuake( coords[1].getValue<float>(), coords[0].getValue<float>(), mag, title );
Trying out the Earthquake sample, I was confused by where the earthquakes were appearing. I tracked it down to swapped latitude, longitude usage.
In https://github.com/cinder/Cinder/blob/master/samples/Earthquake/src/EarthquakeApp.cpp parseEarthquakes() the code parses the coordinates of the earthquakes via:
and inserts them like so:
The addQuake routine signature expects coords in the order Lat, Lon
but the earthquake data in GeoJSON is in Lon, Lat order. See: https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
swapping the coordinate order to the call fixes this: