-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fix geo normalization #1997
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
Comments
In multiple classes you can control whether or not to normalize and validate latitude and/or longitude. I can only think of one use case: One wants to superpose an (indefinite and dynamic) number of layers that must not be merged. |
Geo normalization of latitude was not properly performed. 90°lat is the north pole, and +1°lat beyond is still the north pole, not the south pole. Latitude should not be wrapped like longitude but rather reflected, accompanied with a +180°lon shift. Normalizing ranges cannot be performed by normalizing its top-left and bottom-right points, but must be split into multiple ranges. And two "qeo"->"geo" type fixes as bonuses. Note: There is still a problem with GeoPolygon, like for ranges, but I'll fix this in a separate commit. See elasticsearch/elasticsearch issue elastic#1997.
Normalizing geo polygonsKeep in mind that a polygon is defined by a list connected of points, defining contiguous edges. The idea
Note: This algorithm keeps parts of the polygon that are in the same normalization space as part of a single polygon, hence self intersections are kept intact. However this comes with eventual edges being along the splitting axis, sometime multiple such edges being superposed, and this may affect the Complexity: This algorithm is O(n), n being the number of points defining the polygon to normalize, but it's a bit verbose... (can it really be less?) Pseudo-implementation stub
Feedback requiredI'm not really going to implement it because: I'm not 100% sure it works fine in all cases, and I'm not convinced geo polygon normalization is a real need. It may even be prevented by other means if such problem arise. |
Normalizing geo polygonsA naive approachWhy didn't I even think about that one before... Near up to 3 time slower. No impact if already normalized. Assumptions:
Steps:
Feedback requiredDo you think such assumptions are fair? the performance impact acceptable? |
Normalizing geo polygonsUsing triangulation
Complexity: Triangulation can be no faster than O(n*log(n)) if polygon has holes, O(n) otherwise. Furthermore, re-normalization of split triangles are sometimes needed. Feedback requiredThis method seems more conventional and simple. If not handled by the triangulation method, it however it breaks the crossing number method, by ignoring the self-intersections. |
=============== The code handling geo-shapes is not centralized and creating points takes place at different places. Also the collection of supported geo_shapes is not complete regarding to the GEOJSon specification. This commit centralizes the code related to GEO calculations and extends the old API by a set of new shapes. Null-Shapes =========== The latest implementation of geo-shapes allows to index null-shapes. This means a field that is defined to hold a geo-shape can be set to null. In example: { "shape": null } New Shapes ========== The geo-shapes multipoint and multilinestring have been added to the geo_shape types. Also geo_circle is introduced by this commit. Dateline wrapping ================= A major issue of geo-shapes is the spherical geometry. Since ElasticSearch works on the Geo-Coordinates by wrapping the Earths surface to a plane, some shapes are hard to define if it’s crossing the +180°, -180 longitude. To solve this issue ElasticSearch offers the possibility to define geo shapes crossing this borders and decompose these shapes and automatically re-compose them in a spherical manner. This feature may change the indexed shape-type. If for example a polygon is defined, that crosses the dateline, it will be re-assembled to a set of polygons. This causes indexing a multipolygon. Also linestrings crossing the dateline might be re-assembled to multilinestrings. Builders ======== The API has been refactored to use builders instead of using shapes. So parsing geo-shapes will result in builder objects. These builders can be parsed and serialized without generating any shapes. this causes shape generation only on the nodes executing the actual operation. Also the baseclass ShapeBuilder implements the ToXContent interface which allows to set fields of XContent directly. TODO’s ====== - The geo-circle will not work, if it’s crossing the dateline - The envelope also needs to wrapped Closes elastic#1997 elastic#2708
We have 3 problems:
Let me explain:
When you cross past the 180° meridian, you arrive near the -180° meridian (which is actually the same / does not exist).
In other words longitude wraps.
When you cross past the 90° parallel at the north pole, you are still in the north pole, but you are now going back down along the opposite meridian.
In other words latitude reflects, accompanied with a 180° shift in longitude.
This implies that we cannot normalize latitude without affecting (or even normalizing) longitude.
Moreover when describing an area you have to split it in multiple areas. This affects geo bounding boxes and geo polygons.
The easiest example is considering the range
[(10°;170°);(-10°;190°)]
, it must be splitted into[(10°;170°);(-10°;180°)]
and[(10°;-180°);(-10°;-170°)]
.The text was updated successfully, but these errors were encountered: