質問

I have some triples that represent the locations of several cities. I want to be able to fire off a Prolog query like

(select (?x ?y ?dist) 
(q- ?x !exns:geolocation ?locx)
(q- ?y !exns:geolocation ?locy)
(geo-distance ?locx ?locy ?dist))

but I get this error:

Server returned 400: attempt to call '#:geo-distance/3' which is an undefined function.

I'd like to understand how to use the geospatial reasoning methods like geo-distance (I assumed it was built-in because they use it here. Is this not true though?) in a Prolog query, because this is currently a mystery to me and I haven't found any good examples for doing this.

I am using the Python API, BTW, and in the Python API tutorial they use the getStatements method to retrieve triples within a circle of some radius. I want to be able to do this kind of thing in a Prolog query, and from the Python API, not from AllegroCL--I'd like to build web apps and I don't know how to do that in AllegroCL, but I do know how in Python.

役に立ちましたか?

解決

It's not possible to make geospatial Prolog queries from the Python API. You have to use the Allegro Common Lisp IDE to do this.

EDIT: Not So!

With AllegroGraph 4.6 you can do this! The problem was that I was using AllegroGraph 3.3, so I'm an idiot.

Here's a Prolog rule that works from the Python API using AllegroGraph 4.6:

(<-- (geo-distance ?point1 ?point2 ?dist)
      (lisp ?dist (let (lon1 lat1 lon2 lat2)
           (setf (values lon1 lat1) (upi->longitude-latitude ?point1))
           (setf (values lon2 lat2) (upi->longitude-latitude ?point2))
           (haversine-miles lon1 lat1 lon2 lat2))))

Special thanks to the folks at Franz Allegro support for helping me!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top