Skip to content

OUT_OF_BOUNDS datacheck; datacheck.log header row - #86

Merged
jteresco merged 2 commits into
TravelMapping:masterfrom
yakra:master
May 24, 2018
Merged

OUT_OF_BOUNDS datacheck; datacheck.log header row#86
jteresco merged 2 commits into
TravelMapping:masterfrom
yakra:master

Conversation

@yakra

@yakrayakra commented May 24, 2018

Copy link
Copy Markdown
Contributor

OUT_OF_BOUNDS datacheck
Checks for latitude > 90 or < -90 or longitude > 180 or < -180
Google coped with these cases OK, but Leaflet doesn't like them.
forum thread with discussion
forum thread without discussion

Of course, it would be possible to detect these cases and correct them while loading the waypoint objects from disk. For example, this is what I'm planning for a future commit to yakra/tmtools:

// Yes, this is C++, not Python. Sorry...voidwaypoint::InitCoords()
{	// parse URLsize_t latBeg = URL.find("lat=")+4;	if (latBeg == 3) latBeg = URL.size();
size_t lonBeg = URL.find("lon=")+4;	if (lonBeg == 3) lonBeg = URL.size();
Lat = strtod(&URL[latBeg], 0);
Lon = strtod(&URL[lonBeg], 0);
// check for out-of-bounds coordsif (Lat > 90)
{	std::cout << "Warning: latitude > 90 in " << hwy->Root << " @ " << label[0] << "\n";
std::cout << "" << std::to_string(Lat) << " converted to ";
while (Lat > 360)	Lat -= 360;
if (Lat > 90) Lat = 180-Lat;
if (Lat < -90) Lat = -180-Lat;
std::cout << std::to_string(Lat) << '\n';
}
if (Lat < -90)
{	std::cout << "Warning: latitude < -90 in " << hwy->Root << " @ " << label[0] << "\n";
std::cout << "" << std::to_string(Lat) << " converted to ";
while (Lat < -360)	Lat += 360;
if (Lat < -90) Lat = -180-Lat;
if (Lat > 90) Lat = 180-Lat;
std::cout << std::to_string(Lat) << '\n';
}
if (Lon > 180)
{	std::cout << "Warning: longitude > 180 in " << hwy->Root << " @ " << label[0] << "\n";
std::cout << "" << std::to_string(Lon) << " converted to ";
while (Lon > 180)	Lon -= 360;
std::cout << std::to_string(Lon) << '\n';
}
if (Lon < -180)
{	std::cout << "Warning: longitude < -180 in " << hwy->Root << " @ " << label[0] << "\n";
std::cout << "" << std::to_string(Lon) << " converted to ";
while (Lon < -180)	Lon += 360;
std::cout << std::to_string(Lon) << '\n';
}//*/// ...and some other gisplunge-specific code that's not relevant here
}

...I already had the datacheck pretty much done before starting on working this out.
For how exactly this would be done in Python, I've not looked that deeply into the code yet.
There's always the possibility than an out-of-bounds coordinate is just completely rubbish, and the "fixed" coordinate from the above function still isn't the intended location. Fixing these just seems like it'd be Good Practice.


Along for the ride: this closes#84.

@jteresco
jteresco merged commit a005deb into TravelMapping:masterMay 24, 2018
@yakrayakra mentioned this pull request Oct 29, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

datacheck.log: header row

2 participants

@yakra@jteresco