Hello,I am running db2 10.1 with spatial extender.
I am trying to insert a raw into a table with a spatial area column.
Here is the table def:
CREATE TABLE test1.areas1 (area db2gse.ST_polygon, id integer)
When I try to perform the following insert:
insert into test1.areas1(id,area) values(1,db2gse.ST_PolyFromText('polygon((33.039749731553464 34.01353063350853,33.04575109023584 34.04494032719386,33.03557814117029 34.010830886211814, 33.039749731553464 34.01353063350853))',0))
I get the following exception:
Routine "DB2GSE.GSEGEOMFROMWKT" (specific name "GSEGEOMWKT1") has returned an error SQLSTATE with diagnostic text "GSE3421N Polygon is not closed.".. SQLCODE=-443, SQLSTATE=38SSL, DRIVER=3.63.108
It seems to me the polygon is closed, what could be the problem?
This topic has been locked.
Pinned topic db2 spatial extender - insert fails due to unclosed polygon
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
DavidWAdler 1200006AT714 Posts
Re: db2 spatial extender - insert fails due to unclosed polygon2012-12-18T12:20:39ZThis is the accepted answer. This is the accepted answer.The problem is due to using the spatial reference system (SRS) with the identifier '0'. This SRS is not associated with a coordinate system and is seldom used, although it may be appropriate for integer coordinates.
Spatial Extender stores coordinates internally as 64-bit integers for efficiency in processing. The offset and scale values of an SRS convert between the external floating point representation and internal integer representation. The offset and scale values need to be set so that coordinate precision is not lost.
SRS 0 uses an offset of 0 and scale of 1. This means that the coordinates you specified are basically converted to integers, (33 34, 33 34, 33 34, 33 34), collapsing to a single point.
What do these coordinates represent?
If they are North America latitude and longitude, SRS 1 is appropriate and if they are other worldwide coordinates, SRS 1003 is appropriate. SRS 1 has a multiplier of 1,000,000 and SRS 1003 has a multiplier of 5,965,232.