public Object getSimplifiedShape() { CoordinateSequenceFactory csf = geometryFactory.getCoordinateSequenceFactory(); if (type.isPointType()) { CoordinateSequence cs = csf.create(1, 2); cs.setOrdinate(0, 0, (minX + maxX) / 2); cs.setOrdinate(0, 1, (minY + maxY) / 2); return geometryFactory.createMultiPoint(new Point[] {geometryFactory.createPoint(cs)}); } else if (type.isLineType()) { CoordinateSequence cs = csf.create(2, 2); cs.setOrdinate(0, 0, minX); cs.setOrdinate(0, 1, minY); cs.setOrdinate(1, 0, maxX); cs.setOrdinate(1, 1, maxY); return geometryFactory.createMultiLineString( new LineString[] {geometryFactory.createLineString(cs)}); } else if (type.isPolygonType()) { CoordinateSequence cs = csf.create(5, 2); cs.setOrdinate(0, 0, minX); cs.setOrdinate(0, 1, minY); cs.setOrdinate(1, 0, minX); cs.setOrdinate(1, 1, maxY); cs.setOrdinate(2, 0, maxX); cs.setOrdinate(2, 1, maxY); cs.setOrdinate(3, 0, maxX); cs.setOrdinate(3, 1, minY); cs.setOrdinate(4, 0, minX); cs.setOrdinate(4, 1, minY); LinearRing ring = geometryFactory.createLinearRing(cs); return geometryFactory.createMultiPolygon( new Polygon[] {geometryFactory.createPolygon(ring, null)}); } else { return shape(); } }
public Object getSimplifiedShape(ScreenMap sm) { if (type.isPointType()) { return shape(); } Class geomType = Geometry.class; if (type.isLineType()) { geomType = MultiLineString.class; } else if (type.isMultiPointType()) { geomType = MultiPoint.class; } else if (type.isPolygonType()) { geomType = MultiPolygon.class; } return sm.getSimplifiedShape(minX, minY, maxX, maxY, geometryFactory, geomType); }