I have a list of input geocodes (latitude/longitude pairs), with which we can create a geo shape. I have data indexed in rows and each row has the geocode (latitude/longitude) pair. For a Java based application, which is the best technology to create a shape using my input geocode list and then to search against the indexed data columns (latitude and longitude) and find the list of rows based on which geocode falls into the shape.
Asked
Active
Viewed 430 times
1 Answers
0
You are looking for Spatial4J which adds spatial support to SOLR and Lucene. The support is provided via the Java Topology Suite (JTS), which can be used in any standalone Java application also. It provides functions for contains and intersects (and many more). The C++ port, GEOS, provides much of the functionality behind Postgis spatial predicate functions. JTS is mature, fast and well tested.

John Powell
- 12,253
- 6
- 59
- 67
-
I used Spacial4j, jts and lucene index to do this and some of the code is below where it is giving some failure Shape pointShape = spatialContext.makePoint(latitude, longitude); for (IndexableField f : spatialStrategy.createIndexableFields(pointShape)) { doc.add(f); } It is able to index the rows from my data file but it is failing for some rows and the exception is .. Bad Y value -134.16105 is not in boundary Rect(minX=-180.0,maxX=180.0,minY=-90.0,maxY=90.0) – user1653727 Jan 24 '15 at 08:23
-
Do you have your lat/lon points the right way round? -134, would be out of range for a latitude. spatialContext.makePoint(x, y) means makePoint(lon, lat). – John Powell Feb 06 '15 at 10:36