I have saved latitude-longitude data in Janusgraph with Cassandra backend. Data were input via a graphson file. The goal is to use these values to calculate the distance between selected points. But I'm struggling to understand how to call the distance function via gremlin-python. Actually, I use python goblin.
The schema contains:
point = mgmt.makePropertyKey('point').dataType(org.janusgraph.core.attribute.Geoshape.class).cardinality(org.janusgraph.core.Cardinality.SINGLE).make()
The graphson file contains vertex properties that have this form:
vp = {
"id": {
"@type": "g:Int64",
"@value": 10
},
"value": {
"@type": "janusgraph:Geoshape",
"@value": {"type": "Point", "coordinates": [{"@value": -90.2, "@type": "g:Double"}, {"@value": 30.3, "@type": "g:Double"}]}
},
"properties": {}
}
I can successfully read the data into Janusgraph/Cassandra. But I don't understand how to construct a query to calculate and return the distance between two vertices, say, with IDs 10 and 20, or even more simply, between vertex ID 10 and itself. For example, the following does not work:
results = await (session.g.V(10)
.properties('point')
.as_("a")
.distance(__.select('a'))
.toList()
)
It fails with the message: TypeError: 'AsyncGraphTraversal' object is not callable
The javadocs for Janusgraph indicate that the distance function is:
public double distance(Geoshape.Point other)
where other is a second point. Most of the Geoshape examples I can find on the web look something like this:
g.E().has("place", geoWithin(Geoshape.circle(37.97, 23.72, 50)))
But that is not my use case. I have geo data saved, and I wish to select points, calculate distances between them, and return the results. Any suggestions would be appreciated.