/** * 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); }
/** * 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); }
protected LineString<?> createNullGeometry(CoordinateReferenceSystem<?> crs) { return new LineString(crs); }
@Override LineString<P> toGeometry(CoordinateReferenceSystem<P> crs) { return new LineString<P>(toSeq(crs, positions), crs); } }
/** * 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); }
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)); }
@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"); }
protected LineString<?> createLineString(SqlServerGeometry nativeGeom, IndexRange pntIndexRange) { PositionSequence<?> coordinates = nativeGeom.coordinateRange( pntIndexRange ); CoordinateReferenceSystem<?> coordinateReferenceSystem = nativeGeom.getCoordinateReferenceSystem(); return new LineString(coordinates, coordinateReferenceSystem); } }
private <P extends Position> LineString<P> decodeLineString(ByteBuffer byteBuffer, CoordinateReferenceSystem<P> crs) { int numPoints = byteBuffer.getInt(); PositionSequence<P> points = readPositions(numPoints, byteBuffer, crs); return new LineString<P>(points, crs); }
private static LineString convert(org.postgis.LineString geometry) { PointSequence points = convertPoints(geometry.getPoints()); return new LineString(points); }
private static LineString convert(org.postgis.LineString geometry) { PointSequence points = convertPoints(geometry.getPoints()); return new LineString(points); }
private <P extends Position> LineString<P> decodeLineStringText(CoordinateReferenceSystem<P> crs) { WktPointSequenceToken<P> token = decodePointSequence(crs); if (token != null) { PositionSequence<P> positionSequence = token.getPositions(); CoordinateReferenceSystem<P> tcrs = token.getCoordinateReferenceSystem(); return new LineString<P>(positionSequence, tcrs); } if (matchesEmptyToken()) { return new LineString<P>(crs); } throw new WktDecodeException(buildWrongSymbolAtPositionMsg()); }
private static <P extends Position> org.geolatte.geom.LineString<P> from(LineString jtsLineString, CoordinateReferenceSystem<P> crs) { CoordinateSequence cs = jtsLineString.getCoordinateSequence(); return new org.geolatte.geom.LineString<P>(pscsFactory.toPositionSequence(cs, crs.getPositionClass(), crs), crs); }
private static LineString convertCurve(JGeometry geometry) { CrsId crs = CrsId.valueOf(geometry.getSRID()); PointSequence points = getPoints(geometry); return new LineString(points); }
private static LineString convertCurve(JGeometry geometry) { CrsId crs = CrsId.valueOf(geometry.getSRID()); PointSequence points = getPoints(geometry); return new LineString(points); }
private static MultiLineString convertMultiCurve(JGeometry geometry) { JGeometry[] elements = geometry.getElements(); if (elements == null || elements.length == 0) { return MultiLineString.createEmpty(); } CrsId crs = CrsId.valueOf(geometry.getSRID()); LineString[] lineStrings = new LineString[elements.length]; for (int i = 0; i < elements.length; i++) { PointSequence points = getPoints(elements[i]); lineStrings[i] = new LineString(points); } return new MultiLineString(lineStrings); }
private static MultiLineString convertMultiCurve(JGeometry geometry) { JGeometry[] elements = geometry.getElements(); if (elements == null || elements.length == 0) { return MultiLineString.createEmpty(); } CrsId crs = CrsId.valueOf(geometry.getSRID()); LineString[] lineStrings = new LineString[elements.length]; for (int i = 0; i < elements.length; i++) { PointSequence points = getPoints(elements[i]); lineStrings[i] = new LineString(points); } return new MultiLineString(lineStrings); }
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); }
@Override @SuppressWarnings("unchecked") protected Geometry<?> internalDecode(SDOGeometry nativeGeom) { final CoordinateReferenceSystem<?> crs = getCoordinateReferenceSystem(nativeGeom); final ElemInfo info = nativeGeom.getInfo(); PositionSequence cs = null; int i = 0; while (i < info.getSize()) { if (info.getElementType(i).isCompound()) { final int numCompounds = info.getNumCompounds(i); cs = add(cs, getCompoundCSeq(i + 1, i + numCompounds, nativeGeom)); i += 1 + numCompounds; } else { cs = add(cs, getElementCSeq(i, nativeGeom, false, crs)); i++; } } return new LineString(cs, crs); }