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 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 like the distance between the inner point > and the geometry centroid. > > Alireza > > > On Tuesday, September 23, 2014 8:17:04 PM UTC+2, Craig Taverner wrote: >> >> 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 can, for example, search for everything within >> some maximum bounds, sort by distance and pick the closest 'k' elements. >> >> On Tue, Sep 23, 2014 at 8:14 PM, Craig Taverner <cr...@amanzi.com> wrote: >> >>> 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 < >>> alire...@gmail.com> wrote: >>> >>>> >>>> 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 polygons? >>>> >>>> Related to the concept of distance, it is possible to find objects >>>> within a given distance of a >>>> given object. But what about computing knn, i.e., finding k elements >>>> which are closets to the >>>> given object? Shall we compute all distances and then pick top k or >>>> there is implemented >>>> and optimized way to do this? >>>> >>>> Thanks, >>>> Best, >>>> Alireza >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Neo4j" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to neo4j+un...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >> -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to neo4j+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.