How Do I use stored geometries in the Spatial functions?

77 views
Skip to first unread message

Devdatta Tengshe

unread,
Feb 19, 2016, 3:37:23 AM2/19/16
to OrientDB
Hi,
I've been trying to evaluate the use of OrientDB for our spatial data.
I'm using the following version:
OrientDB: orientdb-community-2.2.0-20160217.214325-39
OrientDB-Spatial: JAR built from develop branch of the github Repo
OS: Win7 64Bit

Right now what I was to do, is if I have polygons stored in the db, and the input is a location (latitude & longitude) then I need to get the polygon which contains that location.

I created a Class to store the State polygons like this:
CREATE class state
CREATE PROPERTY state.name STRING
CREATE PROPERTY state.shape EMBEDDED OPolygon

I Inserted a State with the following command:
INSERT INTO state SET name = 'Center', shape = ST_GeomFromText('POLYGON((77.16796875 26.068502530912397,75.7177734375 21.076171072527064,81.650390625 19.012137871930328,82.9248046875 25.196864372861896,77.16796875 26.068502530912397))')

I've tried several ways of getting the state which contains the given latlong, but all of them give error.

Even something as simple as: 
SELECT from state WHERE ST_Contains(shape, ST_GeomFromText('POINT(77.420654296875 23.23929558106523)'))

Gives the following error:

com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Error parsing query: SELECT from state WHERE ST_Contains(shape, ST_GeomFromText('POINT(77.420654296875 23.23929558106523)')) Encountered "" at line 1, column 25. Was expecting one of: Storage URL="plocal:E:/DevTools/OrientDB2.2_new/databases/spatial" Storage URL="plocal:E:/DevTools/OrientDB2.2_new/databases/spatial" --> com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Encountered "" at line 1, column 25. Was expecting one of: Storage URL="plocal:E:/DevTools/OrientDB2.2_new/databases/spatial"

I can run all the spatial functions when I enter the geometries directly in the spatial function, such as:

Select ST_Contains(ST_geomFromText('POLYGON((77.16796875 26.068502530912397,75.7177734375 21.076171072527064,81.650390625 19.012137871930328,82.9248046875 25.196864372861896,77.16796875 26.068502530912397))'), ST_GeomFromText('POINT(77.420654296875 23.23929558106523)'))

I just can't figure out how to get these function to run on shapes which are stored as properties on records.

How are the geometries which are stored, to be used in these spatial functions? Is there some other syntax for doing so? 

Luca Son

unread,
Feb 19, 2016, 11:31:05 PM2/19/16
to OrientDB
I'm posting the answer given on StackOverflow about this question:

thulaseeswara reddy gajjala

unread,
Dec 5, 2016, 5:19:48 AM12/5/16
to OrientDB
HI Luca,

How can I compare dynamically like this,

select St_disjoint(  st_geomfromtext(select st_astext(name)from PolYgonwsg) , st_geomfromtext(select st_astext(name)from smallpolygon) );

hear I am applying  St_disjoint() on two different tables which have same polygon data its not getting.
is I am doing wrong? or is there any way to compare two different row's or two different tables data dynamic values not a static data like


Select ST_Contains(ST_geomFromText('POLYGON((77.16796875 26.068502530912397,75.7177734375 21.076171072527064,81.650390625 19.012137871930328,82.9248046875 25.196864372861896,77.16796875 26.068502530912397))'), ST_GeomFromText('POINT(77.420654296875 23.23929558106523)'))

On Saturday, February 20, 2016 at 10:01:05 AM UTC+5:30, Luca Son wrote:
Reply all
Reply to author
Forward
0 new messages