zoukankan      html  css  js  c++  java
  • Oracle function real_st_astext,解决ArcSDE中st_astext函数返回字符串结构异常问题

    项目过程中发现在Oracle中调用ArcSDE的st_astext函数返回ST_Geometry类型字段的WKT文本有时空间类型前缀没有返回,例如一个点的经度为113.4,纬度为30.6,调用st_astext函数正常返回就应该是“POINT(113.4 30.6)”,但有时返回的是“(113.4 30.6)”,缺少POINT前缀,以下real_st_astext函数可解决该问题。

    create or replace function real_st_astext(geom1 in clob) return clob is
      geometry clob;
      tempGeom clob;
      geom clob;
      lonlatStr clob;--第一段经纬度字符串
      firstStr clob;--第一个点的经纬度
      lastIndex int;--第一个点最后一次出现的游标
    begin
      geom := trim(geom1);
      geom := replace(geom,'( ','(');
      geom := replace(geom,' (','(');
      geom := replace(geom,') ',')');
      geom := replace(geom,' )',')');
      geom := replace(geom,', ',',');
      geometry := upper(geom);
      if geom like '(((%' then
        geometry := 'MULTIPOLYGON' || geom;
      else
        if geom like '((%' then
          tempGeom := substr(geom, instr(geom, '((') + 2, length(geom));
          lonlatStr := substr(tempGeom, 0, instr(tempGeom, ')')-1);
          firstStr := trim(substr(lonlatStr, 0, instr(lonlatStr, ',')-1));
          lastIndex := instr(lonlatStr, firstStr, -1);
          if lastIndex = length(lonlatStr) - length(firstStr) + 1 then
            geometry := 'POLYGON '||geom;
          else
            geometry := 'MULTILINESTRING ' || geom;
          end if;
        else
          if geom like '(%' then
            if geom like '%,%' then
              geometry := 'LINESTRING' || geom;
            else
              geometry := 'POINT' || geom;
            end if;
          end if;
        end if;
      end if;
      return geometry;
    end;
    
  • 相关阅读:
    laravel中使用ElasticSearch详情
    linux 使用大全
    常见监控软件介绍及原理介绍
    DNS与域名解析
    linux基础入门(基础命令+vi+shell)
    php-fpm与fastcgi、php-cgi之间的关系及源码解析
    web系统整体性能测试
    typescript入门
    webpack
    React
  • 原文地址:https://www.cnblogs.com/nihaorz/p/5332556.html
Copyright © 2011-2022 走看看