zoukankan      html  css  js  c++  java
  • Oracle spatial 将Geometry转换为gml字符串

    oracle spatial有个函数  将geometry转换为gml.函数名称为SDO_UTIL.TO_GMLGEOMETRY(geo)。这个geo就是SDO.Geometry类型 可是这个函数的返回值是Clob类型的Geometry。当然我们可以使用TO_CHAR函数 将其转为字符串类型。下面是一个测试的sql:

    select t.objectid,TO_CHAR(sdo_util.TO_GMLGEOMETRY(t.shape)) AS GML,t.comp_type,t.datatype,t.comp_name,t.health_lic,t.shape.SDO_POINT.X as x,t.shape.SDO_POINT.Y as y,t.reg_addr,t.bus_addr from t_publicplaces t where 1=1 and substr(t.comp_type,0,2)='01' and sdo_within_distance(t.SHAPE,SDO_GEOMETRY(2001,8307,SDO_POINT_TYPE(116.4,39.9,NULL),NULL,NULL),'distance=1500.0 unit=m')='TRUE'

    查询的gml字符串为:

    <gml:Point srsName="SDO:8307" xmlns:gml="http://www.opengis.net/gml"><gml:coordinates decimal="." cs="," ts=" ">116.4,39.9 </gml:coordinates></gml:Point>。

    由于我们前端使用openlayers作为客户端  openlayers常接收gml、wkt、geojson等字符串数据。至于wkt oralce spatial是内置支持的,这个函数名称叫get_wkt(),它是geometry直接的方法。那么将上面的函数换一下就是:

    select t.objectid,TO_CHAR(t.shape.get_wkt()) AS wkt,t.comp_type,t.datatype,t.comp_name,t.health_lic,t.shape.SDO_POINT.X as x,t.shape.SDO_POINT.Y as y,t.reg_addr,t.bus_addr from t_publicplaces t where 1=1 and substr(t.comp_type,0,2)='01' and sdo_within_distance(t.SHAPE,SDO_GEOMETRY(2001,8307,SDO_POINT_TYPE(116.4,39.9,NULL),NULL,NULL),'distance=1500.0 unit=m')='TRUE'

    查询wkt字符串:POINT (116.4 39.9)。

    如果将它专为geojson,目前无解,只能自己使用程序拼写geojson字符串(规则见其官网:http://geojson.org/

  • 相关阅读:
    Unity 之 中文乱码
    fork调用的底层实现
    Linux错误代码含义
    VMware 获取该虚拟机的所有权失败
    Qt ------ QAction
    C++ ------ const迭代器 和 const_iterator的区别
    IAR ------- 在线调试技巧
    STM32 ------ HardFault_Hander 中断函数
    从一张表中复制数据到另一张表中
    分布式任务调度平台xxl-job
  • 原文地址:https://www.cnblogs.com/likehua/p/2730172.html
Copyright © 2011-2022 走看看