See this part of the documentation:
https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/geo/Polygon.java#L30

APIs take newPolygonQuery(Polygon...) which is treated efficiently as
a "multipolygon".

This is also what many standards (e.g. geojson) recommend, otherwise
the polygon can be ambiguous.

You can see this visually for examples like this one:
http://www.geonames.org/2017370/russian-federation.html

On Sun, Jun 12, 2016 at 1:43 PM, Randy Tidd <r...@tidd.cc> wrote:
> Thanks for the help you’ve already given me on getting search with 
> LatLonPoint working, the basics are working great and with great performance.
>
> I did some testing on some edge cases and discovered that indexing and 
> searching for points at the minimum and maximum latitude and longitude are 
> not working as I expected.  I’d appreciate some feedback on this.
>
> Take for example the point (0.0, 180.0) which is in the Pacific ocean at 
> latitude = 0.0 and longitude = 180.0.  If we create a grid of 9 points 
> centered on this location (“tic tac toe” layout) with an offset of 0.1 the 
> coordinates would be:
>
> (0.1, -179.9), (0.0, -179.9), (-0.1, -179.9), (0.1, 180.0), (0.0, 180.0), 
> (-0.1, 180.0), (0.1, 179.9), (0.0, 179.9), (-0.1, 179.9)
>
> The max longitude is 180, so if you move 0.1 degree east the next longitude 
> is actually -179.9 rather than 180.1, it wraps around.
>
> If I then create a square that encompasses these points using an offset of 
> 1.0 (larger than the 0.1 for the indexed points) that polygon would have 
> these endpoints:
>
> (-1.0, 179.0}, (1.0, 179.0), (1.0, -179.0), (-1.0, -179.0), (-1.0, 179.0)
>
> The first and last point are the same so that this is a closed polygon.
>
> When I index these points with LatLonPoint and do a search with 
> LatLonPoint.newPolygonQuery() it does not return any results, which isn’t 
> what I expected.
>
> However, if I index a grid of points around (0.0, 0.0) and search with this 
> polygon, they are returned by this search, which I don’t believe is correct.  
> It is as if the search thinks that the point (0.0, 0.0) is between the points 
> (0.0, 179) and (0.0, -179) which I don’t think is correct.  Longitude 0.0 and 
> 180.0 are on opposite sides of the globe.
>
> I see the same behavior with data centered at these points:
>
> (90.0, -180.0)
> (90.0, 0.0)
> (90.0, 180.0)
> (0.0, -180.0)
> (0.0, 180.0)
> (-90.0, -180.0)
> (-90.0, 0.0)
> (-90.0, 180.0)
>
> However, using more “normal” points such as (44.4605, -110.8281) this test 
> works fine.
>
> So I’m wondering if there is a problem with the search handling polygons that 
> span the latitude and longitude boundaries, or if maybe I am just not 
> thinking about this right to begin with.  I can post sample code if that 
> would be helpful.  Thanks for any assistance / input.
>
> Randy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to