Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OUT_OF_BOUNDS datacheck; datacheck.log header row #86

Merged
merged 2 commits into from May 24, 2018

Conversation

yakra
Copy link
Contributor

@yakra yakra commented May 24, 2018

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...

void waypoint::InitCoords()
{	// parse URL
	size_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 coords
	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 (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:master May 24, 2018
Sign up for free to 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