Home » Server Options » Spatial » Different WKB values (Oracle 11g on Windows XP)
Different WKB values [message #464655] Thu, 08 July 2010 11:05
johnwater1234
Messages: 1
Registered: July 2010
Location: Canada
Junior Member
Hi All,

It looks like my Oracle 11g server gives me different WKB values for the same polygon I inserted into a table using the Oracle native function SDO_Geometry. Here are my SQL statements to reproduce this problem:

create table test (pk int not null primary key, c1 sdo_geometry )
/
insert into test values( 1,
SDO_Geometry( 'polygon ((1.0 1.0, 5.0 1.0, 5.0 7.0, 1.0 7.0, 1.0 1.0))', 4326 ) )
/
insert into test values( 2,
SDO_GEOMETRY(
2003, -- two-dimensional polygon
4326,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3), -- one rectangle (1003 = exterior)
SDO_ORDINATE_ARRAY(1,1, 5,7 ) -- only 2 points needed to
-- define rectangle (lower left and upper right) with
-- Cartesian-coordinate data
) )
/


If I fetch the polygons in WKT format, these two polygons would be the same and the query results are shown below:

-- select pk, g.c1.Get_WKt(), g.c1.sdo_srid from test g
1,'POLYGON ((1.0 1.0, 5.0 1.0, 5.0 7.0, 1.0 7.0, 1.0 1.0))', 4326.0
2,'POLYGON ((1.0 1.0, 5.0 1.0, 5.0 7.0, 1.0 7.0, 1.0 1.0))', 4326.0

However, if I fetch the polygons in WKB format, the query results would be

-- select pk, g.c1.Get_WKB(), g.c1.sdo_srid from test g
1,0x00000000030000000100000005 3ff00000000000003ff000000000000040140000000000003ff00000000000004014000000000000401c0000000000003ff0000000000000401c0000000000003ff00 000000000003ff0000000000000,4326.0

2,0x00000000030000000100000002 3ff00000000000003ff000000000000040140000000000003ff00000000000004014000000000000401c0000000000003ff0000000000000401c0000000000003ff00 000000000003ff0000000000000,4326.0

The differences are marked in red.

The WKB value of the polygon in the first row has the following representation:

0x00 Big endian
00000003 WKB_POLYGON
00000001 num_rings
00000005 num_points_in_ring
3ff0000000000000 3ff0000000000000 1.0,1.0
4014000000000000 3ff0000000000000 5.0,1.0
4014000000000000 401c000000000000 5.0,7.0
3ff0000000000000 401c000000000000 1.0,7.0
3ff0000000000000 3ff0000000000000 1.0,1.0

This is correct and it matches the standard WKB representation. It is also identical to the WKB value generated by SQL Server and DB2.

However, the WKB value of the polygon in the second row has the following meaning:

0x00 Big endian
00000003 WKB_POLYGON
00000001 num_rings
00000002 num_points_in_ring
3ff0000000000000 3ff0000000000000 1.0,1.0
4014000000000000 3ff0000000000000 5.0,1.0
4014000000000000 401c000000000000 5.0,7.0
3ff0000000000000 401c000000000000 1.0,7.0
3ff0000000000000 3ff0000000000000 1.0,1.0

It says the number of points in the polygon is two, but it then provides five points. Is this right? Is it a bug in the server?

Any helps would be appreciated!

John
Previous Topic: To convert from 3785 to 8265 srid
Next Topic: query to find out whether it is point,line or polygon feature
Goto Forum:
  


Current Time: Thu Mar 28 20:28:01 CDT 2024