如何在空间函数中使用存储的几何图形?
How do I use stored geometries in the Spatial functions?
我一直在尝试评估 OrientDB 在空间数据中的使用情况。
我正在使用以下版本:
OrientDB: orientdb-community-2.2.0-20160217.214325-39
OrientDB-Spatial: JAR built from develop branch of the github Repo OS:
Win7 64Bit
现在我要做的是,如果我在数据库中存储了多边形,并且输入是一个位置(纬度和经度),那么我需要获取包含该位置的多边形。
我创建了一个 Class 来存储这样的州多边形:
CREATE class state
CREATE PROPERTY state.name STRING
CREATE PROPERTY state.shape EMBEDDED OPolygon
我使用以下命令插入了一个状态:
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))')
我尝试了几种方法来获取包含给定 latlong 的状态,但所有方法都出错。
甚至像这样简单的东西:
SELECT from state WHERE ST_Contains(shape, ST_GeomFromText('POINT(77.420654296875 23.23929558106523)'))
给出以下错误:
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"
我可以运行所有的空间函数,直接在空间函数里面输入几何就可以了,比如:
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)'))
我只是想不出如何将这些函数用于 运行 形状,这些形状作为属性存储在记录中。
存储的几何图形如何用于这些空间函数?这样做还有其他语法吗?
试试这个
SELECT from state WHERE ST_Contains(shape, ST_GeomFromText('POINT(77.420654296875 23.23929558106523)')) = true
尚不支持 where function() 的语法
我一直在尝试评估 OrientDB 在空间数据中的使用情况。 我正在使用以下版本:
OrientDB: orientdb-community-2.2.0-20160217.214325-39
OrientDB-Spatial: JAR built from develop branch of the github Repo OS:
Win7 64Bit
现在我要做的是,如果我在数据库中存储了多边形,并且输入是一个位置(纬度和经度),那么我需要获取包含该位置的多边形。
我创建了一个 Class 来存储这样的州多边形:
CREATE class state
CREATE PROPERTY state.name STRING
CREATE PROPERTY state.shape EMBEDDED OPolygon
我使用以下命令插入了一个状态:
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))')
我尝试了几种方法来获取包含给定 latlong 的状态,但所有方法都出错。
甚至像这样简单的东西:
SELECT from state WHERE ST_Contains(shape, ST_GeomFromText('POINT(77.420654296875 23.23929558106523)'))
给出以下错误:
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"
我可以运行所有的空间函数,直接在空间函数里面输入几何就可以了,比如:
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)'))
我只是想不出如何将这些函数用于 运行 形状,这些形状作为属性存储在记录中。
存储的几何图形如何用于这些空间函数?这样做还有其他语法吗?
试试这个
SELECT from state WHERE ST_Contains(shape, ST_GeomFromText('POINT(77.420654296875 23.23929558106523)')) = true
尚不支持 where function() 的语法