nextCoordSeq = geomFactory.getCoordinateSequenceFactory().create(1 + cmdLength, 2);
final CoordinateSequence coordSeq = geomFactory.getCoordinateSequenceFactory().create(cmdLength, 2); int coordIndex = 0; Coordinate nextCoord;
nextCoordSeq = geomFactory.getCoordinateSequenceFactory().create(2 + cmdLength, 2);
/** * Splits the input geometry into two LineStrings at a fraction of the distance covered. */ public static P2<LineString> splitGeometryAtFraction(Geometry geometry, double fraction) { LineString empty = new LineString(null, gf); Coordinate[] coordinates = geometry.getCoordinates(); CoordinateSequence sequence = gf.getCoordinateSequenceFactory().create(coordinates); LineString total = new LineString(sequence, gf); if (coordinates.length < 2) return new P2<LineString>(empty, empty); if (fraction <= 0) return new P2<LineString>(empty, total); if (fraction >= 1) return new P2<LineString>(total, empty); double totalDistance = total.getLength(); double requestedDistance = totalDistance * fraction; // An index in JTS can actually refer to any point along the line. It is NOT an array index. LocationIndexedLine line = new LocationIndexedLine(geometry); LinearLocation l = LengthLocationMap.getLocation(geometry, requestedDistance); LineString beginning = (LineString) line.extractLine(line.getStartIndex(), l); LineString ending = (LineString) line.extractLine(l, line.getEndIndex()); return new P2<LineString>(beginning, ending); }
/** * Creates a Point using the given Coordinate; a null Coordinate will create * an empty Geometry. */ public Point createPoint(Coordinate coordinate) { return createPoint(coordinate != null ? getCoordinateSequenceFactory().create(new Coordinate[]{coordinate}) : null); }
public WKBReader(GeometryFactory geometryFactory) { this.factory = geometryFactory; precisionModel = factory.getPrecisionModel(); csFactory = factory.getCoordinateSequenceFactory(); }
/** * Convenience method which provides standard way of * creating a {@link CoordinateSequence} * * @param coords the coordinate array to copy * @return a coordinate sequence for the array */ protected final CoordinateSequence createCoordinateSequence(Coordinate[] coords) { return factory.getCoordinateSequenceFactory().create(coords); }
/** * This method is ONLY used to avoid deprecation warnings. * @param points * @param factory * @throws IllegalArgumentException if the ring is not closed, or has too few points */ private LinearRing(Coordinate points[], GeometryFactory factory) { this(factory.getCoordinateSequenceFactory().create(points), factory); }
private GeometryFactory createFactory(GeometryFactory inputFactory, PrecisionModel pm) { GeometryFactory newFactory = new GeometryFactory(pm, inputFactory.getSRID(), inputFactory.getCoordinateSequenceFactory()); return newFactory; }
/** * Creates a {@link LinearRing} using the given {@link Coordinate}s. * A null or empty array will * create an empty LinearRing. The points must form a closed and simple * linestring. Consecutive points must not be equal. * @param coordinates an array without null elements, or an empty array, or null */ public LinearRing createLinearRing(Coordinate[] coordinates) { return createLinearRing(coordinates != null ? getCoordinateSequenceFactory().create(coordinates) : null); }
/** * Creates a {@link MultiPoint} using the given {@link Coordinate}s. * A null or empty array will create an empty MultiPoint. * * @param coordinates an array (without null elements), or an empty array, or <code>null</code> * @return a MultiPoint object */ public MultiPoint createMultiPoint(Coordinate[] coordinates) { return createMultiPoint(coordinates != null ? getCoordinateSequenceFactory().create(coordinates) : null); }
/** * Creates a LineString using the given Coordinates; a null or empty array will * create an empty LineString. Consecutive points must not be equal. * @param coordinates an array without null elements, or an empty array, or null */ public LineString createLineString(Coordinate[] coordinates) { return createLineString(coordinates != null ? getCoordinateSequenceFactory().create(coordinates) : null); } /**
/** @deprecated Use GeometryFactory instead */ public LineString(Coordinate points[], PrecisionModel precisionModel, int SRID) { super(new GeometryFactory(precisionModel, SRID)); init(getFactory().getCoordinateSequenceFactory().create(points)); }
private void init(CoordinateSequence points) { if (points == null) { points = getFactory().getCoordinateSequenceFactory().create(new Coordinate[]{}); } if (points.size() == 1) { throw new IllegalArgumentException("Invalid number of points in LineString (found " + points.size() + " - must be 0 or >= 2)"); } this.points = points; } public Coordinate[] getCoordinates() {
/** * Constructs a <code>Point</code> with the given coordinate. * *@param coordinate the coordinate on which to base this <code>Point</code> * , or <code>null</code> to create the empty geometry. *@param precisionModel the specification of the grid of allowable points * for this <code>Point</code> *@param SRID the ID of the Spatial Reference System used by this * <code>Point</code> * @deprecated Use GeometryFactory instead */ public Point(Coordinate coordinate, PrecisionModel precisionModel, int SRID) { super(new GeometryFactory(precisionModel, SRID)); init(getFactory().getCoordinateSequenceFactory().create( coordinate != null ? new Coordinate[]{coordinate} : new Coordinate[]{})); }
protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) { Coordinate[] inputPts = coords.toCoordinateArray(); Coordinate[] newPts = DouglasPeuckerLineSimplifier.simplify(inputPts, distanceTolerance); return factory.getCoordinateSequenceFactory().create(newPts); }
protected CoordinateSequence transformCoordinates( CoordinateSequence coords, Geometry parent) { Coordinate[] inputPts = coords.toCoordinateArray(); Coordinate[] newPts = Densifier .densifyPoints(inputPts, distanceTolerance, parent.getPrecisionModel()); // prevent creation of invalid linestrings if (parent instanceof LineString && newPts.length == 1) { newPts = new Coordinate[0]; } return factory.getCoordinateSequenceFactory().create(newPts); }
protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) { Coordinate[] srcPts = coords.toCoordinateArray(); Coordinate[] newPts = snapLine(srcPts, snapPts); return factory.getCoordinateSequenceFactory().create(newPts); }
private void init(CoordinateSequence coordinates) { if (coordinates == null) { coordinates = getFactory().getCoordinateSequenceFactory().create(new Coordinate[]{}); } Assert.isTrue(coordinates.size() <= 1); this.coordinates = coordinates; }
/** * Creates a {@link MultiPoint} using the * points in the given {@link CoordinateSequence}. * A <code>null</code> or empty CoordinateSequence creates an empty MultiPoint. * * @param coordinates a CoordinateSequence (possibly empty), or <code>null</code> * @return a MultiPoint geometry */ public MultiPoint createMultiPoint(CoordinateSequence coordinates) { if (coordinates == null) { return createMultiPoint(new Point[0]); } Point[] points = new Point[coordinates.size()]; for (int i = 0; i < coordinates.size(); i++) { CoordinateSequence ptSeq = getCoordinateSequenceFactory() .create(1, coordinates.getDimension()); CoordinateSequences.copy(coordinates, i, ptSeq, 0, 1); points[i] = createPoint(ptSeq); } return createMultiPoint(points); }