/** * Transforms a {@link LineString} geometry. * * @param geom * @param parent * @return */ protected Geometry transformLineString(LineString geom, Geometry parent) { // should check for 1-point sequences and downgrade them to points return factory.createLineString( transformCoordinates(geom.getCoordinateSequence(), geom)); }
protected Geometry transformPoint(Point geom, Geometry parent) { return factory.createPoint( transformCoordinates(geom.getCoordinateSequence(), geom)); }
protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) { if (coords.size() == 0) return null; // for linear components (including rings), simplify the linestring if (parent instanceof LineString) { TaggedLineString taggedLine = (TaggedLineString) linestringMap.get(parent); return createCoordinateSequence(taggedLine.getResultCoordinates()); } // for anything else (e.g. points) just copy the coordinates return super.transformCoordinates(coords, parent); } }
/** * Transforms a LinearRing. * The transformation of a LinearRing may result in a coordinate sequence * which does not form a structurally valid ring (i.e. a degenerate ring of 3 or fewer points). * In this case a LineString is returned. * Subclasses may wish to override this method and check for this situation * (e.g. a subclass may choose to eliminate degenerate linear rings) * * @param geom the ring to simplify * @param parent the parent geometry * @return a LinearRing if the transformation resulted in a structurally valid ring * @return a LineString if the transformation caused the LinearRing to collapse to 3 or fewer points */ protected Geometry transformLinearRing(LinearRing geom, Geometry parent) { CoordinateSequence seq = transformCoordinates(geom.getCoordinateSequence(), geom); if (seq == null) return factory.createLinearRing((CoordinateSequence) null); int seqSize = seq.size(); // ensure a valid LinearRing if (seqSize > 0 && seqSize < 4 && ! preserveType) return factory.createLineString(seq); return factory.createLinearRing(seq); }