1

我们在 Grails 项目 2.4.3中使用Spring Data Neo4j 3.2.0Neo4j-spatial 0.13-neo4j-2.1.6

在用户域中

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

在用户存储库中

    @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)

所以当我们跑

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

然后它给出准确的数据,但是当我们运行时

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

那么它不会给出任何数据,但如果我们将距离增加到 10000,那么它会给出数据。

实际上,我们想使用 Cypher Query 获得正确的数据。我们错过了什么吗?反正有没有使用 Cypher 获得正确的数据?

4

1 回答 1

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);
于 2015-02-21T18:43:18.290 回答