/** * Creates an empty {@code LineString} for a coordinate reference system * * @param crs the coordinate reference system for the created {@code LineString} * @param <P> the type of {@code Position} * @return an empty {@code LineString} with the specified coordinate reference system */ public static <P extends Position> LineString<P> mkEmptyLineString(CoordinateReferenceSystem<P> crs) { return new LineString<P>(crs); }
private static JGeometry convert(LineString geometry) { int srid = geometry.getSRID(); int dim = geometry.getCoordinateDimension(); double[] points = getPoints(geometry.getPoints()); int[] elemInfo = new int[]{1, 2, 1}; int gtype = dim * 1000 + (geometry.isMeasured() ? dim : 0) * 100 + GTYPE_CURVE; return new JGeometry(gtype, srid, elemInfo, points); }
@Override @SuppressWarnings("unchecked") public <Q extends Position> LineString<Q> as(Class<Q> castToType){ checkCast(castToType); return (LineString<Q>)this; }
@Override public void visit(LineString<P> geom) { writeByteOrder(output); writeTypeCodeAndSrid(geom, output); if (geom.isEmpty()) { output.putUInt(0); } else { output.putUInt(geom.getNumPositions()); writePoints(geom.getPositions(), geom.getCoordinateDimension(), output); } }
private static org.postgis.LineString convert(LineString lineString) { org.postgis.Point[] pgPoints = convertPoints(lineString); org.postgis.LineString pgLineString = new org.postgis.LineString(pgPoints); pgLineString.haveMeasure = lineString.isMeasured(); pgLineString.setSrid(lineString.getSRID()); return pgLineString; }
private <T extends C2D & Measured> LineString<T> measure(LineString<T> geometry) { CoordinateReferenceSystem<T> crs = geometry.getCoordinateReferenceSystem(); PositionSequence originalPoints = geometry.getPositions(); PositionSequenceBuilder<T> builder = PositionSequenceBuilders.fixedSized(originalPoints.size(), geometry.getPositionClass()); int mIdx = hasVerticalAxis(crs) ? 3 :2; double[] coordinates = new double[geometry.getCoordinateDimension()]; double[] prevCoordinates = new double[geometry.getCoordinateDimension()]; for (int i = 0; i < originalPoints.size(); i++) { originalPoints.getCoordinates(i, coordinates); if (i > 0) { length += Math.hypot(coordinates[0] - prevCoordinates[0], coordinates[1] - prevCoordinates[1]); } coordinates[mIdx] = length; builder.add(coordinates); prevCoordinates[0] = coordinates[0]; prevCoordinates[1] = coordinates[1]; } return new LineString<T>(builder.toPositionSequence(), crs); }
data.add(LineString.createEmpty()); for (int i = 0; i < 6; i++) { data.add(new LineString(createSequence(crs, (Point) data.get(i), (Point) data.get(i))));
public void visit(LineString lineString, int parent) { Shape shape = new Shape(); shape.type = LINE_STRING; shape.figureOffset = figures.size(); shape.parentOffset = parent; shapes.add(shape); Figure figure = new Figure(); figure.attributes = 1; figure.pointOffset = points.size(); figures.add(figure); for (Point point : lineString.getPoints()) { points.add(point); } }
private static JGeometry convert(MultiLineString geometry) { int srid = geometry.getSRID(); int dim = geometry.getCoordinateDimension(); double[] points = getPoints(geometry.getPoints()); int[] elemInfo = new int[geometry.getNumGeometries() * 3]; int offset = 0; int pointOffset = 1; for (int i = 0; i < geometry.getNumGeometries(); i++) { elemInfo[offset++] = pointOffset; elemInfo[offset++] = 2; elemInfo[offset++] = 1; pointOffset += geometry.getGeometryN(i).getNumPoints() * dim; } int gtype = dim * 1000 + (geometry.isMeasured() ? dim : 0) * 100 + GTYPE_MULTICURVE; return new JGeometry(gtype, srid, elemInfo, points); }
private static org.postgis.LineString convert(LineString lineString) { org.postgis.Point[] pgPoints = convertPoints(lineString); org.postgis.LineString pgLineString = new org.postgis.LineString(pgPoints); pgLineString.haveMeasure = lineString.isMeasured(); pgLineString.setSrid(lineString.getSRID()); return pgLineString; }
public void visit(LineString lineString, int parent) { Shape shape = new Shape(); shape.type = LINE_STRING; shape.figureOffset = figures.size(); shape.parentOffset = parent; shapes.add(shape); Figure figure = new Figure(); figure.attributes = 1; figure.pointOffset = points.size(); figures.add(figure); for (Point point : lineString.getPoints()) { points.add(point); } }
private static JGeometry convert(MultiLineString geometry) { int srid = geometry.getSRID(); int dim = geometry.getCoordinateDimension(); double[] points = getPoints(geometry.getPoints()); int[] elemInfo = new int[geometry.getNumGeometries() * 3]; int offset = 0; int pointOffset = 1; for (int i = 0; i < geometry.getNumGeometries(); i++) { elemInfo[offset++] = pointOffset; elemInfo[offset++] = 2; elemInfo[offset++] = 1; pointOffset += geometry.getGeometryN(i).getNumPoints() * dim; } int gtype = dim * 1000 + (geometry.isMeasured() ? dim : 0) * 100 + GTYPE_MULTICURVE; return new JGeometry(gtype, srid, elemInfo, points); }
/** * Creates a {@code LineString} from a {@code PositionSequence} and coordinate reference system * * @param seq the {@code PositionSequence} for the created {@code LineString} * @param crs the coordinate reference system for the created {@code LineString} * @param <P> the type of {@code Position} * @return a {@code LineString} with the specified positions and coordinate reference system */ public static <P extends Position> LineString<P> mkLineString(PositionSequence<P> seq, CoordinateReferenceSystem<P> crs) { return new LineString<P>(seq, crs); }
private static JGeometry convert(LineString geometry) { int srid = geometry.getSRID(); int dim = geometry.getCoordinateDimension(); double[] points = getPoints(geometry.getPoints()); int[] elemInfo = new int[]{1, 2, 1}; int gtype = dim * 1000 + (geometry.isMeasured() ? dim : 0) * 100 + GTYPE_CURVE; return new JGeometry(gtype, srid, elemInfo, points); }
protected LineString<?> createNullGeometry(CoordinateReferenceSystem<?> crs) { return new LineString(crs); }
@Override LineString<P> toGeometry(CoordinateReferenceSystem<P> crs) { return new LineString<P>(toSeq(crs, positions), crs); } }
private LineString decodeLineString(int shapeIdx) { Shape shape = shapes[shapeIdx]; return new LineString(createPoints(shape.figureOffset)); }
private LineString decodeLineString(int shapeIdx) { Shape shape = shapes[shapeIdx]; return new LineString(createPoints(shape.figureOffset)); }
/** * Creates a {@code LineString} * * @param crs the {@code CoordinateReferenceSystem} for the {@code LineString} * @param positions the {@code Position}s for the {@code LineString} * @param <P> the {@code Position} type * @return a {@code LineString} having the specified {@code Position}s and {@code CoordinateReferenceSystem} */ public static <P extends Position> LineString<P> linestring(CoordinateReferenceSystem<P> crs, P... positions) { return new LineString<P>(toSeq(crs, positions), crs); }
@SuppressWarnings("unchecked") public static <P extends Position> Geometry<P> mkGeometry(Class<? extends Simple> geometryClass, PositionSequence<P> positions, CoordinateReferenceSystem<P> crs) { if (geometryClass == null) { throw new IllegalArgumentException("Null argument not allowed"); } if (Point.class.isAssignableFrom(geometryClass)) { return new Point<P>(positions, crs); } if (LinearRing.class.isAssignableFrom(geometryClass)) { return new LinearRing<P>(positions, crs); } if (LineString.class.isAssignableFrom(geometryClass)) { return new LineString<P>(positions, crs); } throw new IllegalStateException("Unknown Geometry class"); }