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(
       geom       in clob
) return clob
is
  geometry   clob;
  tempGeom      clob;
begin
  geometry := upper(geom);
  if geom like '(((%' then
    geometry := 'MULTIPOLYGON'||geom;
  else
    if geom like '((%' then
      tempGeom := substr(geom, instr(geom, '((')+2, length(geom));
      if tempGeom like '%(%' then
        geometry := 'MULTILINESTRING '||geom;
      else
        geometry := 'POLYGON '||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;

你可能感兴趣的:(Oracle function real_st_astext,解决ArcSDE中st_astext函数返回字符串结构异常问题)