-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
LUCENE-8632: New XYShape Field and Queries for indexing and searching general cartesian geometries #726
Conversation
This all sounds great; I like the use of the "XY" as a naming prefix to help clarify the coordinate system so we don't confuse it with LatLon. In your mind... with the increase spatial code in core, are you still resolute in your opinion of Lucene-core having all this spatial code? I mean... wow... it's not like Lucene core doesn't have a rich module system already. Yeah I know this is kinda settled already but this just gnaws at me. |
With extensions like this (and possibly more to come) it certainly adds a lot to core. I'm not at all bound to the idea that |
Yeah, lets do that then (another issue). When the spatial stuff "graduates", as some say, out of sandbox. This stuff here can stay in sandbox since it's where LatLonShape is now. |
Thanks Nick! I am having problems with Polygon and XYPolygon and Line and XYLine and so on. Are we keeping Polygon for backwards compatibility? It looks like it should be called LatLonPolygon for consistency. |
@iverase +1 for renaming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me. It would be nice if the new XY points, lines and polygons could take floats from an API perspective since this is the accuracy they provide, even if we keep storing doubles internally in order to be able to share code with LatLon shapes?
lucene/sandbox/src/java/org/apache/lucene/document/XYShape.java
Outdated
Show resolved
Hide resolved
lucene/sandbox/src/test/org/apache/lucene/document/TestXYShape.java
Outdated
Show resolved
Hide resolved
lucene/sandbox/src/java/org/apache/lucene/document/LatLonShape.java
Outdated
Show resolved
Hide resolved
The renames make sense to me but maybe they should go into a separate change and only go to master since Polygon is a quite a high level user-facing API? |
I went ahead and updated I'm also in favor of handling the rename to |
…c XYShape testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how ShapeField and ShapeQuery work, they glue everything together nicely.
I don't think we need a XYPolygon2D and I am wondering if we need a XYRectangle2D at all. We can use Rectangle2D for XY as well. WDYT?
lucene/sandbox/src/java/org/apache/lucene/geo/XYRectangle2D.java
Outdated
Show resolved
Hide resolved
I am wondering if we can test the tessellator with XYPolygons as well. What I am thinking is to modify the current test and build the polygons as XYPolygons as well and run the tessellation through them. In a similar fashion we might want to test the encoding/decoding for XYShapes. |
Note to us: Currently XY shapes are under the geo package. I don't think that is correct and maybe we should add a different package (xy package?). I don't think we need it in this iteration but just writing it here so it is considered later on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to change the name of the methods in Tessellator.Triangle
as it still have methods referring to Lat and Lon but is generically used by LatLonShape
and XYShape
…reate new TestXYShapeEncoding for testing encoding of tessellated XYShapes
Cleaned up the API a bit:
Refactored I think this PR is just about ready to merge and continue iterating in sandbox? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We can then iterate in the sandbox, thanks!
Closing: Merged in commit 0c09481 |
The
LatLonShape
field andLatLonShape
query classes added the ability to index and search geospatial geometries in the WGS-84 latitude, longitude coordinate reference system. The foundation for this capability is provided by theTessellator
that converts an array of vertices describing aPoint
Line
orPolygon
into a stream of 3 vertex triangles that are encoded as a seven dimension point and indexed using the BKDPOINT
structure. A nice property of the Tessellator is thatlat, lon
restrictions are artificial and really only bound by the API.This commit builds on top of / abstracts the
Tessellator
LatLonShape
andLatLonShapeQuery
classes to provide the ability to index & search general cartesian (non WGS84 lat,lon restricted) geometry. It does so by introducing two new base classes:ShapeField
andShapeQuery
that provide the indexing and search foundation forLatLonShape
and theLatLonShape
derived query classes (LatLonShapeBoundingBoxQuery
,LatLonShapeLineQuery
,LatLonShapePolygonQuery
) and introducing a newXYShape
factory class along withXYShape
derived query classes (XYShapeBoundingBoxQuery
,XYShapeLineQuery
,XYShapePolygonQuery
). The heart of the cartesian indexing is achieved throughXYShapeEncodingUtils
that converts the double precision vertices into aninteger
encoded seven dimension point (similar to LatLonShape).The test framework is also further abstracted and extended to provide a full test suite for the new
XYShape
capability that works the same way as theLatLonShape
test suite (but applied to non GIS geometries).