@Test public void testAccumulateWithDifferentGeometryTypes() throws Exception { List<Geometry> resultGeoms = new ArrayList<>(); Geometry point = wktReader.read("POINT(1 1)"); Geometry line = wktReader.read("LINESTRING(1 1, 1 2, 2 2)"); GeometryCollection collection = new GeometryCollection(new Geometry[] {point, line}, gf); ReferencedEnvelope envelope = new ReferencedEnvelope(0, 5, 0, 5, CRS.decode("EPSG:4326")); Class resultClass = WrappingProjectionHandler.accumulate(resultGeoms, collection, null, envelope); assertEquals(Geometry.class, resultClass); }
static Class accumulate( List<Geometry> geoms, Geometry geometry, Class geomType, ReferencedEnvelope envelope) { Class gtype = null; for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry g = geometry.getGeometryN(i); Class lastType = gtype; if (g instanceof GeometryCollection) { gtype = accumulate(geoms, g, geomType, envelope); } else { if (envelope.intersects(g.getEnvelopeInternal())) { geoms.add(g); gtype = g.getClass(); } } if (gtype == null) { gtype = g.getClass(); } else if (geomType != null && !g.getClass().equals(geomType) || lastType != null && !g.getClass().equals(lastType)) { gtype = Geometry.class; } } return gtype; }
WrappingProjectionHandler extends ProjectionHandler { static Class accumulate( List<Geometry> geoms, Geometry geometry, Class geomType, ReferencedEnvelope envelope) { Class gtype = null; for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry g = geometry.getGeometryN(i); Class lastType = gtype; if (g instanceof GeometryCollection) { gtype = accumulate(geoms, g, geomType, envelope); } else { if (envelope.intersects(g.getEnvelopeInternal())) { geoms.add(g); gtype = g.getClass(); } } if (gtype == null) { gtype = g.getClass(); } else if (geomType != null && !g.getClass().equals(geomType) || lastType != null && !g.getClass().equals(lastType)) { gtype = Geometry.class; } } return gtype; } }
WrappingProjectionHandler extends ProjectionHandler { static Class accumulate( List<Geometry> geoms, Geometry geometry, Class geomType, ReferencedEnvelope envelope) { Class gtype = null; for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry g = geometry.getGeometryN(i); Class lastType = gtype; if (g instanceof GeometryCollection) { gtype = accumulate(geoms, g, geomType, envelope); } else { if (envelope.intersects(g.getEnvelopeInternal())) { geoms.add(g); gtype = g.getClass(); } } if (gtype == null) { gtype = g.getClass(); } else if (geomType != null && !g.getClass().equals(geomType) || lastType != null && !g.getClass().equals(lastType)) { gtype = Geometry.class; } } return gtype; } WrappingProjectionHandler(
            ReferencedEnvelope renderingEnvelope,
            ReferencedEnvelope validArea,
            CoordinateReferenceSystem sourceCrs,
            double centralMeridian,
            int maxWraps); }
WrappingProjectionHandler extends ProjectionHandler { static Class accumulate( List<Geometry> geoms, Geometry geometry, Class geomType, ReferencedEnvelope envelope) { Class gtype = null; for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry g = geometry.getGeometryN(i); Class lastType = gtype; if (g instanceof GeometryCollection) { gtype = accumulate(geoms, g, geomType, envelope); } else { if (envelope.intersects(g.getEnvelopeInternal())) { geoms.add(g); gtype = g.getClass(); } } if (gtype == null) { gtype = g.getClass(); } else if (geomType != null && !g.getClass().equals(geomType) || lastType != null && !g.getClass().equals(lastType)) { gtype = Geometry.class; } } return gtype; } WrappingProjectionHandler(
            ReferencedEnvelope renderingEnvelope,
            ReferencedEnvelope validArea,
            CoordinateReferenceSystem sourceCrs,
            double centralMeridian,
            int maxWraps); @Override void setProjectionParameters(Map projectionParameters); @Override Geometry preProcess(Geometry geometry); @Override Geometry postProcess(MathTransform mt, Geometry geometry); @Override boolean requiresProcessing(Geometry geometry); boolean isDatelineWrappingCheckEnabled(); void setDatelineWrappingCheckEnabled(boolean datelineWrappingCheckEnabled); }
WrappingProjectionHandler extends ProjectionHandler { static Class accumulate( List<Geometry> geoms, Geometry geometry, Class geomType, ReferencedEnvelope envelope) { Class gtype = null; for (int i = 0; i < geometry.getNumGeometries(); i++) { Geometry g = geometry.getGeometryN(i); Class lastType = gtype; if (g instanceof GeometryCollection) { gtype = accumulate(geoms, g, geomType, envelope); } else { if (envelope.intersects(g.getEnvelopeInternal())) { geoms.add(g); gtype = g.getClass(); } } if (gtype == null) { gtype = g.getClass(); } else if (geomType != null && !g.getClass().equals(geomType) || lastType != null && !g.getClass().equals(lastType)) { gtype = Geometry.class; } } return gtype; } WrappingProjectionHandler(
            ReferencedEnvelope renderingEnvelope,
            ReferencedEnvelope validArea,
            CoordinateReferenceSystem sourceCrs,
            double centralMeridian,
            int maxWraps); @Override void setProjectionParameters(Map projectionParameters); @Override Geometry preProcess(Geometry geometry); @Override Geometry postProcess(MathTransform mt, Geometry geometry); @Override boolean requiresProcessing(Geometry geometry); boolean isDatelineWrappingCheckEnabled(); void setDatelineWrappingCheckEnabled(boolean datelineWrappingCheckEnabled); static final String DATELINE_WRAPPING_CHECK_ENABLED; }