Re: [Neo4j] Spatial Distance Between Objects

2014-10-10 Thread Craig Taverner
The SimplePointLayer and the GeoPipeline have methods for this, but they do make some assumptions. See SimplePointLayer.findClosestPointsTo(Coordinate,int) and GeoPipeline.startNeiarestNeighborLatLonSearch(Layer,Coordinate,int). The former just calls the latter. The int passed is the number of geom

Re: [Neo4j] Spatial Distance Between Objects

2014-10-09 Thread Alireza Rezaei Mahdiraji
Hi Craig, Any idea how to implement the knn in efficient way? We need to specify an initial distance and if we do not find k neighbours within that distance we need to increase it, which does not seem like very efficient approach. Thanks, Alireza On Tuesday, September 23, 2014 8:17:04 PM

Re: [Neo4j] Spatial Distance Between Objects

2014-09-24 Thread Craig Taverner
If you want the distance to the centroid, just use getCentroid(). For example, instead of g1.distance(g2) use g1.getCentroid().distance(g2.getCentroid()). On Wed, Sep 24, 2014 at 5:06 PM, Alireza Rezaei Mahdiraji < alireza...@gmail.com> wrote: > > Regarding the distance, for inner point of a geom

Re: [Neo4j] Spatial Distance Between Objects

2014-09-24 Thread Alireza Rezaei Mahdiraji
Regarding the distance, for inner point of a geometry the distance returns zero. Although, I saw the definition of the distance in http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html#distance%28com.vividsolutions.jts.geom.Geometry%29 but expected to see something lik

Re: [Neo4j] Spatial Distance Between Objects

2014-09-23 Thread Craig Taverner
I did not answer everything. But the JTS distance method will work for all geometries, so that answers most of your questions. The GeoPipeline methods also provide ways to find objects within distances of other objects (using the rtree for optimized searches). And it provides sorting too, so you c

Re: [Neo4j] Spatial Distance Between Objects

2014-09-23 Thread Craig Taverner
The distance is calculated best using JTS. For example: double distance = pointA.distance(pointB) See http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html#distance(com.vividsolutions.jts.geom.Geometry) On Tue, Sep 23, 2014 at 3:26 PM, Alireza Rezaei Mahdiraji < alireza

[Neo4j] Spatial Distance Between Objects

2014-09-23 Thread Alireza Rezaei Mahdiraji
Hi All, Given two geometries how do compute the distance between them in neo4j spatial? For instance given two points stored in two nodes? What other kind of distance are defined? For instance, is it possible to find distance between a point and a linestring/polygon or distance between two