不同SDE GeoSQL构造函数的效率问题

今天有问题咨询了一下几个SDE For Oracle函数的效率比较问题:
问题如下: SDE提供了 ST_LineString、ST_Point、ST_PolyFromText几个函数来进行点,线,面的构建,同时也提供了 ST_Geometry函数进行点线面的构建,这些函数的功能都是相同的,到底谁的效率更好。
初步判断:
从字面上看ST_LINESTRING,ST_POINT应该是ST_GEOMETRY的子类,以我对ESRI研发人员的风格了解,应该不会每个函数使用不同的算法,这些对象应该最终都会指向同一个函数,也就是说效率是一样的,下面我们可以查看一下源码验证一下。
查看ST_LINESTRING是怎么定义的
SQL> select text from user_source where name='ST_LINESTRING' and type='TYPE BODY';

TEXT --------------------------------------------------------------------------------
Type Body st_linestring AS constructor Function st_linestring(geom_str clob,srid number)
Return self AS result
IS
temp varchar2(1);
tempraw raw(1);
entity number;
geom_type number;
name varchar2(32);
spref_r SDE.spx_util.spatial_ref_record_t;

TEXT --------------------------------------------------------------------------------
shape SDE.st_geom_util.shape_r;
is_empty boolean := False;
rc number;
buffer clob;

Begin

geom_type := SDE.st_geom_util.unspecified_type;
buffer := geom_str;
SDE.st_geom_util.get_type(buffer,entity,geom_type,is_empty,SDE.st_geom_util.l
inestring_type); TEXT --------------------------------------------------------------------------------


If entity = SDE.st_geom_util.sg_illegal_shape THEN
raise_application_error (SDE.st_type_util.st_geometry_invalid_type,'Invalid
ST_Linestring type.');

End If;

SDE.st_geom_util.get_name(entity,name);

If name != 'LINESTRING' THEN

TEXT --------------------------------------------------------------------------------
raise_application_error (SDE.st_type_util.st_geometry_invalid_type,'ST_Line
string must use a LINESTRING type.'); End If;

spref_r.srid := srid;
rc := SDE.st_spref_util.select_spref(spref_r);
If rc != SDE.st_type_user.se_success THEN
raise_application_error (SDE.st_type_util.st_no_srid,'srid '||spref_r.srid||



TEXT --------------------------------------------------------------------------------
' does not exist in st_spatial_references table.');


End If;

shape.points := empty_blob();
shape.numpts := 0;
shape.entity := 0;
shape.minx := 0;
shape.miny := 0;
shape.maxx := 0;

TEXT --------------------------------------------------------------------------------
shape.maxy := 0;
shape.area := 0;
shape.len := 0;
shape.minz := NULL;
shape.maxz := NULL;
shape.minm := NULL;
shape.maxm := NULL;

temp := lpad('a', 1, 'a');
tempraw := utl_raw.cast_to_raw (temp);
shape.points := tempraw;

TEXT --------------------------------------------------------------------------------

If is_empty = False THEN
SDE.st_geometry_shapelib_pkg.geometryfromtext(buffer,spref_r.srid,spref_r.x
_offset,spref_r.y_offset,spref_r.xyunits,

spref_r.z_offset,spref_r.z_sc
ale,spref_r.m_offset,spref_r.m_scale,

spref_r.Definit
hape.minx,shape.miny,


TEXT --------------------------------------------------------------------------------
shape.maxx,shap
hape.maxm,shape.area,shape.len,

shape.points);
ELSE
shape.numpts := 0;
If geom_type > SDE.st_geom_util.unspecified_type Then
shape.entity := geom_type;
else
shape.entity := 0;
end if;

TEXT --------------------------------------------------------------------------------
shape.minx := 0;
shape.miny := 0;
shape.maxx := 0;
shape.maxy := 0;
shape.minz := NULL;
shape.maxz := NULL;
shape.minm := NULL;
shape.maxm := NULL;
shape.area := 0;
shape.len := 0;
shape.points := empty_blob();

TEXT --------------------------------------------------------------------------------
shape.srid := srid;
End If;

if(shape.numpts IS NULL and shape.entity = 0) then
self.entity := shape.entity;
self.numpts := 0;
self.minx := 0;
self.maxx := 0;
self.miny := 0;
self.maxy := 0;
self.minz := NULL;

TEXT --------------------------------------------------------------------------------
self.maxz := NULL;
self.minm := NULL;
self.maxm := NULL;
self.srid := srid;
else
self.entity := shape.entity;
self.numpts := shape.numpts;
self.minx := shape.minx;
self.miny := shape.miny;
self.maxx := shape.maxx;
self.maxy := shape.maxy;

TEXT --------------------------------------------------------------------------------

if(shape.minz IS NULL) then
self.minz := NULL;
else
self.minz := shape.minz;
end if;

if(shape.maxz IS NULL) then
self.maxz := NULL;
else
self.maxz := shape.maxz;

TEXT --------------------------------------------------------------------------------
end if;

if(shape.minm IS NULL) then
self.minm := NULL;
else
self.minm := shape.minm;
end if;

if(shape.maxm IS NULL) then
self.maxm := NULL;
else

TEXT --------------------------------------------------------------------------------
self.maxm := shape.maxm;
end if;

end if;

self.area := 0;
self.len := shape.len;
self.srid := srid;
self.points := shape.points;
Return;
End;

TEXT --------------------------------------------------------------------------------

static Function get_release Return number IS c_type_release Constant pls_integer := 1007;

Begin
Return c_type_release;
End get_release;
End;

SQL> select text from user_source where name='ST_GEOMFROMTEXT' and type='TYPE BODY';

TEXT --------------------------------------------------------------------------------
Type Body st_geomfromtext AS constructor Function st_geomfromtext(geom_str clob,srid number)
Return self AS result
IS
temp varchar2(1);
tempraw raw(1);
entity number;
geom_type number;
name varchar2(32);
spref_r SDE.spx_util.spatial_ref_record_t;

TEXT --------------------------------------------------------------------------------
shape SDE.st_geom_util.shape_r;
is_empty boolean := False;
rc number;
buffer clob;

Begin

geom_type := SDE.st_geom_util.unspecified_type;
buffer := geom_str;
SDE.st_geom_util.get_type(buffer,entity,geom_type,is_empty,SDE.st_geom_util.s
t_geometry_type);

TEXT --------------------------------------------------------------------------------


If entity = SDE.st_geom_util.sg_illegal_shape THEN
raise_application_error (SDE.st_type_util.st_geometry_invalid_type,'Invalid
ST_GEOMETRY type.');

End If;

SDE.st_geom_util.get_name(entity,name);

If name != 'POINT' AND name != 'LINESTRING' AND name != 'POLYGON' AND

TEXT --------------------------------------------------------------------------------
name != 'MULTIPOINT' AND name != 'MULTILINESTRING' AND name != 'MULTIPOLYG
ON' THEN

raise_application_error (SDE.st_type_util.st_geometry_invalid_type,'ST_GEOM
ETRY type must be a valid subtype.'); End If;

spref_r.srid := srid;
rc := SDE.st_spref_util.select_spref(spref_r);
If rc <> SDE.st_type_user.se_success THEN

TEXT --------------------------------------------------------------------------------
raise_application_error (SDE.st_type_util.spx_no_srid,'Parameter ST_SRID '||
spref_r.srid|| ' does not exist in ST_SPATIAL_REFERENCES table.');


End If;

shape.points := empty_blob();
shape.numpts := 0;
shape.entity := 0;

TEXT --------------------------------------------------------------------------------
shape.minx := 0;
shape.miny := 0;
shape.maxx := 0;
shape.maxy := 0;
shape.area := 0;
shape.len := 0;
shape.minz := NULL;
shape.maxz := NULL;
shape.minm := NULL;
shape.maxm := NULL;


TEXT --------------------------------------------------------------------------------
-- Initialize POINTS blob.
temp := lpad('a', 1, 'a');
tempraw := utl_raw.cast_to_raw (temp);
shape.points := tempraw;

If is_empty = False THEN
SDE.st_geometry_shapelib_pkg.geometryfromtext (buffer,spref_r.srid,spref_r.x_
offset,spref_r.y_offset,spref_r.xyunits, spref_r.z_offset,spref_r.z_sca
le,spref_r.m_offset,spref_r.m_scale,

TEXT --------------------------------------------------------------------------------

spref_r.D
ape.minx,shape.miny,

shape.ma
hape.maxm,shape.area,shape.len,

shape.po

ELSE
shape.numpts := 0;

TEXT --------------------------------------------------------------------------------
If geom_type > SDE.st_geom_util.unspecified_type Then
shape.entity := geom_type;
else
shape.entity := 0;
end if;
shape.minx := 0;
shape.miny := 0;
shape.maxx := 0;
shape.maxy := 0;
shape.minz := NULL;
shape.maxz := NULL;

TEXT --------------------------------------------------------------------------------
shape.minm := NULL;
shape.maxm := NULL;
shape.area := 0;
shape.len := 0;
shape.points := empty_blob();
shape.srid := srid;
End If;

if(shape.numpts IS NULL and shape.entity = 0) then
self.entity := shape.entity;
self.numpts := 0;

TEXT --------------------------------------------------------------------------------
self.minx := 0;
self.maxx := 0;
self.miny := 0;
self.maxy := 0;
self.minz := NULL;
self.maxz := NULL;
self.minm := NULL;
self.maxm := NULL;
self.srid := srid;
else
self.entity := shape.entity;

TEXT --------------------------------------------------------------------------------
self.numpts := shape.numpts;
self.minx := shape.minx;
self.miny := shape.miny;
self.maxx := shape.maxx;
self.maxy := shape.maxy;

if(shape.minz IS NULL) then
self.minz := NULL;
else
self.minz := shape.minz;
end if;

TEXT --------------------------------------------------------------------------------

if(shape.maxz IS NULL) then
self.maxz := NULL;
else
self.maxz := shape.maxz;
end if;

if(shape.minm IS NULL) then
self.minm := NULL;
else
self.minm := shape.minm;

TEXT --------------------------------------------------------------------------------
end if;

if(shape.maxm IS NULL) then
self.maxm := NULL;
else
self.maxm := shape.maxm;
end if;

end if;

self.area := shape.area;

TEXT --------------------------------------------------------------------------------
self.len := shape.len;
self.srid := srid;
self.points := shape.points;
Return;
End;

static Function get_release
Return number
IS
c_type_release Constant pls_integer := 1007;


TEXT --------------------------------------------------------------------------------
Begin
Return c_type_release;
End get_release;
End;

CREATE OR REPLACE Type Body st_geometry AS

constructor Function st_geometry (geom_str clob, srid number)
Return self AS result
IS
temp varchar2(1);
tempraw raw(1);
entity number;
geom_type number;
name varchar2(32);
spref_r SDE.st_spref_util.spatial_ref_record_t;
shape SDE.st_geom_util.shape_r;
is_empty boolean := False;
rc number;
buffer clob;
Begin

geom_type := SDE.st_geom_util.unspecified_type;
buffer := geom_str;
SDE.st_geom_util.get_type(buffer,entity,geom_type,is_empty,SDE.st_geom_util.st_geometry_type);

If entity = SDE.st_geom_util.sg_illegal_shape THEN
raise_application_error (SDE.st_type_util.st_geometry_invalid_type,'ST_GEOMETRY type must be a geometry type.');
End If;

SDE.st_geom_util.get_name(entity,name);

spref_r.srid := srid;
rc := SDE.st_spref_util.select_spref(spref_r);
If rc != SDE.st_type_user.se_success THEN
raise_application_error (SDE.st_type_util.st_no_srid,'SRID '||spref_r.srid||
' does not exist in ST_SPATIAL_REFERENCES table.');
End If;

shape.points := empty_blob();
shape.numpts := 0;
shape.entity := 0;
shape.minx := 0;
shape.miny := 0;
shape.maxx := 0;
shape.maxy := 0;
shape.area := 0;
shape.len := 0;
shape.minz := NULL;
shape.maxz := NULL;
shape.minm := NULL;
shape.maxm := NULL;

temp := lpad('a', 1, 'a');
tempraw := utl_raw.cast_to_raw (temp);
shape.points := tempraw;

If is_empty = False THEN
geom_type := SDE.st_geom_util.unspecified_type;
SDE.st_geometry_shapelib_pkg.geometryfromtext(buffer,spref_r.srid,spref_r.x_offset,spref_r.y_offset,spref_r.xyunits,
spref_r.z_offset,spref_r.z_scale,spref_r.m_offset,spref_r.m_scale,
spref_r.Definition,geom_type,shape.numpts,shape.entity,shape.minx,shape.miny,
shape.maxx,shape.maxy,shape.minz,shape.maxz,shape.minm,shape.maxm,
shape.area,shape.len,shape.points);

发现最终调用的是SDE.st_geometry_shapelib_pkg.geometryfromtext函数进行对象的构建。
所以效率是一样的。
文章来源:http://blog.csdn.net/liufeng1980423/article/details/71158153

0 个评论

要回复文章请先登录注册