Hello.

I am using GeometryFactory.buildGeometry() to create a common geometry from a List of geometries. I just discovered that with a List with a single MultiPolygon the buildGeometry() returns a GeometryCollection of that single MultiPolygon. This is with jts-1.9.

From the documentation, buildGeometry() will collect several Polygons to a common MultiPolygon. Perhaps it should also collect several MultiPolygons to a common MultiPolygon?

    public void testBuildGeometryWithSingleMultipolygon() {
String a = "MULTIPOLYGON (((105 -9, 104.7719981 -9, 99 -9, 99 -6.6735324, 99 -6.4769693, 99 -5.5, 99.1535114 -5.5, 99.6949253 -5.5, 100.4429739 -5.5, 100.4968864 -5.5, 100.5130253 -5.5, 100.5618621 -5.5, 100.5837587 -5.5, 100.6700839 -5.5, 101.1448967 -5.5, 101.2765547 -5.5, 101.5917338 -5.5, 101.8689332 -5.5, 101.9972856 -5.5, 102.0943862 -5.5, 102.2292855 -5.5, 102.2646017 -5.5, 102.2882864 -5.5, 102.3513297 -5.5, 102.3738666 -5.5, 102.4045993 -5.5, 102.4964335 -5.5, 102.701965 -5.5, 103.0498502 -5.5, 103.5239897 -5.5, 103.965577 -5.5, 104.0948186 -5.5, 104.1457929 -5.5, 104.1895725 -5.5, 105 -5.5, 105 -5.7329791, 105 -5.8032427, 105 -6.0876523, 105 -6.1837199, 105 -6.23532, 105 -6.344359, 105 -6.434243, 105 -6.6469016, 105 -7.1982306, 105 -7.6548277, 105 -8.0483834, 105 -8.1408521, 105 -8.2582398, 105 -8.8460797, 105 -9)), ((100.547619 0, 103.5872531 0, 103.5933789 0, 103.770947 0, 104.4792819 0, 104.5856461 0, 105 0, 105 -2.3273102, 105 -2.4860457, 105 -5.5, 100.547619 0)))";
                GeometryFactory gf = new GeometryFactory();
                try {
                        Geometry g1 = new WKTReader().read(a);
                        assertTrue(g1.isValid());
                        Geometry g2 = 
gf.buildGeometry(Collections.singletonList(g1));
                        assertTrue(g2.isValid());
assertTrue("should be " + MultiPolygon.class + ", not " + g2.getClass(), g2 instanceof MultiPolygon);
                } catch (ParseException e) {
                        fail(e.getMessage());
                }
        }

Regards,
 - Tore.
_______________________________________________
jts-devel mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jts-devel

Reply via email to