我试图了解如何使用 pyorient 在 Orientdb 2.2.17 中使用 LUCENE 空间查询。
我已经注意到如何从另一个类中选择位于多边形顶点内的点顶点类的所有属性。
区域顶点类有两个属性:
- 姓名
坐标(嵌入式 OPolygon) LUCENE 索引
CREATE CLASS Region EXTENDS V
CREATE PROPERTY Region.name IF NOT EXISTS STRING
CREATE PROPERTY Region.coordinates IF NOT EXISTS EMBEDDED OPolygon
CREATE INDEX Region.coordinates ON Region(coordinates) SPATIAL ENGINE LUCENE
Points 顶点类,也有两个属性:
- 站名
坐标 (EMBEDDED OPoint) LUCENE 索引
CREATE CLASS Point EXTENDS V
CREATE PROPERTY Point.station_name IF NOT EXISTS STRING
CREATE PROPERTY Point.coordinates IF NOT EXISTS EMBEDDED OPoint
CREATE INDEX Point.coordinates ON Point(coordinates) SPATIAL ENGINE LUCENE
现在,添加区域多边形点:
INSERT INTO Region SET name = 'region01', coordinates = St_GeomFromText("POLYGON ((13.178784796476098 59.058001210852922,14.161006039084404 59.058001210852922,14.176596852459138 58.122552408368826,13.178784796476098 58.122552408368826,13.178784796476098 59.058001210852922))")
添加点顶点:
INSERT INTO Point SET station_name = 0, coordinates = st_GeomFromText("POINT (13.459419437221328 58.808548196857167)")
INSERT INTO Point SET station_name = 1, coordinates = st_GeomFromText("POINT (14.332504986206489 58.605867622985606)")
INSERT INTO Point SET station_name = 2, coordinates = st_GeomFromText("POINT (13.724463264591824 57.779554514124655)")
INSERT INTO Point SET station_name = 3, coordinates = st_GeomFromText("POINT (12.617515514985637 58.66823087648455)")
我尝试了类似的东西及其变体但失败了,这是查询示例:
SELECT from Point WHERE ST_WITHIN(coordinates, ST_AsText(SELECT coordinates FROM Region where name='region01')) = true
我收到以下错误,我在查询上尝试了不同的方法但没有成功。
解析查询时出错:SELECT from Point WHERE ST_WITHIN(coordinates, ST_AsText(SELECT coordinates FROM Region where name='region01')) = true ^ 在第 1 行第 25 列遇到“”。期待其中之一:DB name="envlay- D b”
预期结果是检索多边形包含的 station_name=0 点。
非常感激任何的帮助。
;)
约贝尔