Opened 11 years ago

Closed 11 years ago

#2588 closed defect (fixed)

GeometryCollection constructor parse defect for sub geometries (POINTM,POLYGONM,...) of GEOMETRYCOLLECTIONM

Reported by: bergun Owned by: delawen
Priority: medium Milestone: PostGIS 2.2.0
Component: java Version: master
Keywords: GEOMETRYCOLLECTIONM jdbc POINTM POLYGONM Cc:

Description

I create a GeometryCollection as below

GeometryCollection coll = new GeometryCollection(

"SRID=-1;GEOMETRYCOLLECTIONM(POINTM(10 10 100),LINESTRINGM(0 50 100, 100 50 100),POLYGONM((25 25 100,75 25 100,75 75 100,25 75 100,25 25 100),(45 45 100,55 45 100,55 55 100,45 55 100,45 45 100)))"));

when I reprint the coll.toString() I see that my geom string is changed to below :

"SRID=-1;GEOMETRYCOLLECTIONM(POINT(10 10 100),LINESTRING(0 50 100, 100 50 100),POLYGON((25 25 100,75 25 100,75 75 100,25 75 100,25 25 100),(45 45 100,55 45 100,55 55 100,45 55 100,45 45 100)))"

As you can see GEOMETRYCOLLECTIONM is preserved but POINTM LINESTRINGM and POLYGONM is changed to POINT LINESTRING and POLYGON . And because of this I get cannot mix dimensionality when I am trying to insert this geom to database.

I have tried this with postgis jdbc driver 1.1.5; 1.3.3 and 2.0.1 versions.

Similar issue http://trac.osgeo.org/postgis/ticket/724 was open and resolved for server side postgis extension.

Attachments (1)

patch_ticket_2588 (1023 bytes ) - added by bergun 11 years ago.

Download all attachments as: .zip

Change History (6)

by bergun, 11 years ago

Attachment: patch_ticket_2588 added

comment:1 by bergun, 11 years ago

I have attached patch which resolves the issue. The subgeoms outerWKT method was called with haveM false I changed them to true. This change was introduced with changeset 1417. When I make this change all the outerWKT is called with haveM true within the jdbc postgis project. And it looks like there is no need for 2 signature for outerWKT method. But I keep it as it is for backward compatibility. Our problem datanucleus unit test is now running as expected.

comment:2 by pramsey, 11 years ago

B, I don't have means to test this myself, but want to confirm: your unit tests not only test "M" geometries but also 2D and 3D geometries? I don't want to fix your case and break all the other ones by mistake.

comment:3 by bergun, 11 years ago

Our tests can be viewed from https://github.com/datanucleus/tests repository and jdo/geospatial project.

PgGeometryMappingTest.java PgGeometryMySQLTest.java PgGeometryPostGISExtMappingTest.java PgGeometrySpatialHelperTest.java PgGeometrySpatialTest.java

There are 205 tests for Mysql/Mariadb and around 230 tests for Postgresql db. There are 2D, 3D and M geometries tests if u have look at the test classes. All of the test cases I have tested to be ok after updating the GeometryCollection class.

I didnt actually understand why the second signature was added to the below method

public void outerWKT(StringBuffer sb, boolean putM)

because even putM is declared as false or true inside the method there is check for if Geometry haveM and 2dimensional.

if (putM && haveMeasure && dimension == 2) {

on line 263 Geometry.class

comment:4 by bergun, 11 years ago

The patch is not applied yet. If need any help in testing please ping me.

comment:5 by pramsey, 11 years ago

Resolution: fixed
Status: newclosed

Sorry for delay. r12202 in 2.1, r12203 in 2.0, r12204 in trunk

Note: See TracTickets for help on using tickets.