Oracle(空间几何)查询的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3259226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 21:02:45  来源:igfitidea点击:

Problem with Oracle (Spatial Geometry) query

sqloraclespatial

提问by Dan

I'm trying to form a query that returns a list of entities within a given rectangle, using SDO_WITHIN_DISTANCE. The query I've made seems like it should work, but Oracle is giving me some strange errors. Here's the query:

我正在尝试使用 SDO_WITHIN_DISTANCE 形成一个查询,该查询返回给定矩形内的实体列表。我所做的查询似乎应该可以工作,但是 Oracle 给了我一些奇怪的错误。这是查询:

SELECT * 
FROM TBLENTITYLOCATION TL
      INNER JOIN TBLENTITY TE 
      ON TE.ENTITYID=TL.ENTITYID  
WHERE SDO_WITHIN_DISTANCE (TL.GEOLOCATION
                           , SDO_GEOMETRY (2003
                                         , NULL
                                         , NULL
                                         , SDO_ELEM_INFO_ARRAY(1, 1003, 3)
                                         , SDO_ORDINATE_ARRAY(41, -73, 36, -82)
                              ), 'DISTANCE=10 UNIT=M'
                          ) = 'TRUE' 
AND  TL.LOCATIONDATETIME= (select MAX(LOCATIONDATETIME) 
                           FROM TBLENTITYLOCATION 
                           WHERE  ENTITYID = TE.ENTITYID)

The error is as follows:

错误如下:

ORA-29902: error in executing ODCIIndexStart() routine
ORA-13208: internal error while evaluating [window SRID does not match layer SRID] operator
ORA-06512: at MDSYS.SDO_INDEX_METHOD_10I", line 286

OERR says:

OERR 说:

29902. 00000 -  "error in executing ODCIIndexStart() routine"
*Cause:    The execution of ODCIIndexStart routine caused an error.
*Action:   Examine the error messages produced by the indextype code and take appropriate action.

Thanks for any help or ideas.

感谢您的任何帮助或想法。

回答by Gary Myers

The ORA-13208 error is the prime one here. The TL.GEOLOCATION needs a matching value in the SRID (second parameter of the SDO_GEOMETRY)

ORA-13208 错误是这里的主要错误。TL.GEOLOCATION 需要 SRID 中的匹配值(SDO_GEOMETRY 的第二个参数)

See if the response herehelps you out.

看看这里的回复是否对你有帮助。

回答by DimaA6_ABC

Gary Myers provided correct answer, let me augment it. If you don't know which SRID is used by your table, do a query:

加里迈尔斯提供了正确的答案,让我补充一下。如果您不知道您的表使用的是哪个 SRID,请执行查询:

select SRID from USER_SDO_GEOM_METADATA where TABLE_NAME='TBLENTITYLOCATION' and COLUMN_NAME='TBLENTITYLOCATION'

Also, to query for objects which are within a rectangle, you don't need SDO_WITHIN_DISTANCE operator. Instead, use SDO_RELATE with mask=ANYINTERACT. See http://docs.oracle.com/cd/B12037_01/appdev.101/b10826/sdo_operat.htm#i78531for more details.

此外,要查询矩形内的对象,您不需要 SDO_WITHIN_DISTANCE 运算符。相反,使用带有掩码=ANYINTERACT 的 SDO_RELATE。有关更多详细信息,请参阅http://docs.oracle.com/cd/B12037_01/appdev.101/b10826/sdo_operat.htm#i78531