Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在oracle中从sdo_几何图形中获取lat和long_Oracle_Latitude Longitude_Oracle Spatial - Fatal编程技术网

如何在oracle中从sdo_几何图形中获取lat和long

如何在oracle中从sdo_几何图形中获取lat和long,oracle,latitude-longitude,oracle-spatial,Oracle,Latitude Longitude,Oracle Spatial,如何在oracle中从point获得lat和long 像这样: MDSYS.SDO_GEOMETRY(2001,4326,NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1), MDSYS.SDO_ORDINATE_ARRAY(51.702814,32.624736)) 可以使用sdo_util.getvertices。来自 您显示的符号不是表示单个2D或3D点的最佳符号。对这些点进行编码的常见且最有效的方法如下: SDO_GEOMETRY(2001,4326,

如何在oracle中从point获得lat和long

像这样:

MDSYS.SDO_GEOMETRY(2001,4326,NULL,
  MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),
  MDSYS.SDO_ORDINATE_ARRAY(51.702814,32.624736))

可以使用sdo_util.getvertices。来自


您显示的符号不是表示单个2D或3D点的最佳符号。对这些点进行编码的常见且最有效的方法如下:

SDO_GEOMETRY(2001,4326,SDO_POINT_TYPE(51.702814,32.624736,NULL),NULL,NULL)
我见过的所有GIS工具都使用这种符号。您显示的一个也是有效的-它只是使用了更多的存储空间。但这两种符号在功能上完全相同

使用紧凑表示法,获取单个坐标是很简单的。例如,考虑到美国城市包含上述紧凑符号中的点:

select c.city, c.location.sdo_point.x longitude, c.location.sdo_point.y latitude 
from us_cities c where state_abrv='CO';

CITY                                        LONGITUDE   LATITUDE
------------------------------------------ ---------- ----------
Aurora                                     -104.72977  39.712267
Lakewood                                   -105.11356    39.6952
Denver                                     -104.87266  39.768035
Colorado Springs                            -104.7599    38.8632

4 rows selected.
从您使用的更复杂的基于数组的表示法中获得相同的结果更复杂。您可以使用SDO_UTIL.GETVERTICES方法。例如,假设US_CITIES_A包含相同的点,但采用基于数组的表示法:

select city, t.x longitude, t.y latitude
from us_cities_a, table (sdo_util.getvertices(location)) t
where state_abrv = 'CO';

CITY                                        LONGITUDE   LATITUDE
------------------------------------------ ---------- ----------
Aurora                                     -104.72977  39.712267
Lakewood                                   -105.11356    39.6952
Denver                                     -104.87266  39.768035
Colorado Springs                            -104.7599    38.8632

4 rows selected.
我发现另一种更简单的方法是只定义两个简单的函数来从数组中提取值:

create or replace function get_x (g sdo_geometry) return number is
begin
  return g.sdo_ordinates(1);
end;
/

然后,使用函数可以简化语法:

select city, get_x(location) longitude, get_y(location) latitude
from us_cities_a
where state_abrv = 'CO';

CITY                                        LONGITUDE   LATITUDE
------------------------------------------ ---------- ----------
Aurora                                     -104.72977  39.712267
Lakewood                                   -105.11356    39.6952
Denver                                     -104.87266  39.768035
Colorado Springs                            -104.7599    38.8632

4 rows selected.

从geometry_表a、表(sdo_util.getvertices(a.geometry_列))t中选择a.id、t.x、t.y,其中a.id=1

如果您不使用别名,这将不起作用。

如果您只有定位器许可证,则接受的答案似乎不起作用。至少对我们来说不是这样。这个答案适用于定位器许可证。这很奇怪,因为定位器中非常支持使用sdo_point_类型。这很奇怪,我不是说没有其他原因。但我在a.ora_几何中有一个点几何。如果我像上面那样使用sdo_util.getvertices(a.ora_geometry),它就可以工作。如果我说“从a中选择ora_geometry.sdo_点”,我会得到“ora_geometry.sdo_点:ungültiger Bezeichner”。此语法应该有效:从表中选择t.geometry.sdo_点。您是正确的。如果我使用select ora_geometry.sdo_point from foo_table,我会得到无效的标识符。如果我使用select t.ora_geometry.sdo_point from foo_table t,它会工作。你能解释一下为什么需要表别名吗?你能给你的答案添加更多的上下文吗?使用表的别名表单名称,例如:select*from tabla TFASCING,仅供参考,你必须在具有使用sdo_点的几何图形的表上使用表别名。x | t要清楚:这是在Oracle中使用对象时的一般要求。您还需要一个别名来调用任何对象方法。这是在SQL中,而不是在OL/SQL中:您可以直接检查变量中的对象。
create or replace function get_y (g sdo_geometry) return number is
begin
  return g.sdo_ordinates(2);
end;
/
select city, get_x(location) longitude, get_y(location) latitude
from us_cities_a
where state_abrv = 'CO';

CITY                                        LONGITUDE   LATITUDE
------------------------------------------ ---------- ----------
Aurora                                     -104.72977  39.712267
Lakewood                                   -105.11356    39.6952
Denver                                     -104.87266  39.768035
Colorado Springs                            -104.7599    38.8632

4 rows selected.