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

bbox of polygons that cross the international date line #5

Open
semiaddict opened this issue Oct 12, 2011 · 5 comments
Open

bbox of polygons that cross the international date line #5

semiaddict opened this issue Oct 12, 2011 · 5 comments

Comments

@semiaddict
Copy link

Hi,

Thank you very much for this library.
I've added a few functionalities such as Yahoo geocoding and reverse geocoding (they have greater request limits than google's) which I will submit as a pull request as soon as my project's rush period is over.

However, I'm getting strange results when using the getBBox function on a multipolygon representing countries that cross the international date line such as Russia and New Zealand.

For Russia, for example, I'm getting a very thin line that follows the international date line.
I'm guessing this is an issue with the calculation of the min and max values.

Any idea how to fix this ?

Thank you.

@phayes
Copy link
Owner

phayes commented Oct 12, 2011

Hmm, this is a super-tricky issue as it only appears for certain projections that "wrap" their coordinates, and geoPHP doesn't really do anything with SRIDs at the moment.

in the getBBOX method we could likely do some fancy-footwork to detect weather the shape crosses such a boundary and do something intelligent. I don't have time to look into this at the moment, but if you find a solution I would encourage a pull request.

@phayes
Copy link
Owner

phayes commented Oct 12, 2011

Just thinking some more.. I think this is how we do it..

Before doing the actual bbox calulation, we run through all the points to find the global minimum value of each of the X and Y axis. If any of these are less than zero, we mark the amount they are less than zero as a "x-transpose" or "y-transpose" amount.

Next, for calculating or min and max values, we add this transpose amount to our calculations, thereby insuring that the resulting bounding-box only has positive values. Finally, right before passing the bounding-box back, we un-transpose the bounding-box back to normal.

The only tricky piece is that this might result in longitudes like "-190", which your application will have to be able to deal with.

@semiaddict
Copy link
Author

Thank you phayes for the super fast reply.
I'll try out this solution and let you know.

Note: the application uses Google Earth, which I'm guessing should be able to deal with longitudes like "-190".

@phayes
Copy link
Owner

phayes commented Jan 9, 2012

Any success on this?

@semiaddict
Copy link
Author

No, I didn't manage to get this working, and due to limited time and budget, I ended up going with manual bboxes that didn't overlap the international date line.

misterbisson added a commit to misterbisson/geoPHP that referenced this issue Nov 7, 2014
working around the following fatal by forcing `geosInstalled( FALSE )`

Fatal error: Uncaught exception 'Exception' with message 'ParseException: Expected word but encountered end of stream' in /var/www/wphost/wp-content/plugins/bgeo/components/external/geoPHP/lib/adapters/WKT.class.php:38 Stack trace: #0 /var/www/wphost/wp-content/plugins/bgeo/components/external/geoPHP/lib/adapters/WKT.class.php(38): GEOSWKTReader->read('') phayes#1 [internal function]: WKT->read(NULL) phayes#2 /var/www/wphost/wp-content/plugins/bgeo/components/external/geoPHP/geoPHP.inc(79): call_user_func_array(Array, Array) phayes#3 /var/www/wphost/wp-content/plugins/bgeo/components/class-bgeo.php(166): geoPHP::load(NULL, 'wkt') phayes#4 /var/www/wphost/wp-content/plugins/bgeo/components/class-bgeo.php(196): bGeo->new_geometry(NULL, 'wkt') phayes#5 /var/www/wphost/wp-content/plugins/bgeo/components/templates/metabox-details.php(7): bGeo->get_geo('1159', 'bgeo_tags') phayes#6 /var/www/wphost/wp-content/plugins/bgeo/components/class-bgeo-admin.php(105): include_once('/var/www/wphost...') phayes#7 [internal function]: bGeo_Admin->metabox(Object(stdClass), 'bgeo_tag in /var/www/wphost/wp-content/plugins/bgeo/components/external/geoPHP/lib/adapters/WKT.class.php on line 38

Also fixing a bad variable reference.
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

No branches or pull requests

2 participants