orientdb geospatial request

55 Views Asked by At

I created a spacial class OPoint and I created some points

create property Tag.coor EMBEDDED Opoint
update Tag set coor = ST_GeomFromText(WKT)

insert into Tag set name=‘tag01’, coor= {"@class": "OPoint","coordinates" : [1,1]}
insert into Tag set name=‘tag02’, coor= {"@class": "OPoint","coordinates" : [2,2]}
insert into Tag set name=‘tag03’, coor= {"@class": "OPoint","coordinates" : [3,3]}
insert into Tag set name=‘tag04’, coor= {"@class": "OPoint","coordinates" : [4,4]}

I want to make a polygon request which returns all the points in the polygon: something like

SELECT FROM tag WHERE polygon (0 0, 0 2, 2 2, 2 0, 0 0)

expected result:

tag01 (1 1) 
tag02 (2 2)
2

There are 2 best solutions below

0
On

Take a look to spatial functions., especially http://orientdb.com/docs/last/Spatial-Index.html#stwithin

The showed example fit your use case, I guess

0
On

Thx I find the good command (ST_WITHIN):

select coor from Tag where  ST_WITHIN(coor,'POLYGON ((0 0, 20 0, 20 20,0 20, 0 0))') = true