1

We are using Spring Data Neo4j 3.2.0 ,and Neo4j-spatial 0.13-neo4j-2.1.6 in a Grails Project 2.4.3

In UserDomain

@Indexed(indexType = IndexType.POINT, indexName = "junctionLocations")
  Point wkt

In UserRepository

    @Transactional
        Result<UserDomain> findWithinDistance( final String indexName, Circle circle)

@Query("START item=node:junctionLocations({0}) RETURN labels(item) as label ,item")
        List match(String a)

So when we run

    Iterable<UserDomain> teamMembers1 = userDomainRepository.findWithinDistance
("junctionLocations", new
                Circle(new Point(28.6100,77.2300),new Distance(2, Metrics.KILOMETERS)));

Then it give exact data but when we run

Iterable<UserDomain> teamMembers = userDomainRepository.match("withinDistance:[28.6100,77.2300,2.0]")

then it does not give any data but if we increase the distance to 10000 then it give data .

Actually we want to get correct data using Cypher Query. Are we missing something ? Is there anyway to get correct data using Cypher ?

abhaygarg12493
  • 1,565
  • 2
  • 20
  • 40
  • 1
    Could be that the default distance is meters. Or you have to flip lat/lon. Not sure. – Michael Hunger Feb 21 '15 at 11:38
  • If the Distance in meter then , how should this work Iterable teamMembers1 = userDomainRepository.findWithinDistance ("junctionLocations", new Circle(new Point(28.6100,77.2300),new Distance(2, Metrics.KILOMETERS))); . I dont think so problem is with meter or kilo meter – abhaygarg12493 Feb 21 '15 at 18:13
  • It works , problem is I flip lat/lon ... My mistake – abhaygarg12493 Feb 21 '15 at 18:27

1 Answers1

0

I think there is some problem in Documentation of Spatial Repository

@Transactional
Result<T> findWithinDistance(final String indexName, final double lat, double lon, double distanceKm);

. In database we have corrdinates of Delhi and Gurgaon

Delhi Latitude : 28.38 Longitude : 77.12

Gurgaon Latitude : 30.30 Longitude : 74.60

So from my point of view , If I search

findWithinDistance("junctionLocations", 28.6100,77.2300, 35.5);

i.e 28.6100 lat and 77.23 long and 35.5 Distance in km

this does not give any data

But if I swap lat,lon position then Query give appropriate result

findWithinDistance("junctionLocations",77.2300, 28.6100, 35.5);

So If I am correct then in Spatial Repository correct way is

@Transactional
Result<T> findWithinDistance(final String indexName, final double lon, double lat, double distanceKm);
abhaygarg12493
  • 1,565
  • 2
  • 20
  • 40