/** * Creates a {@code Point} * * @param crs the {@code CoordinateReferenceSystem} for the {@code Point} * @param p the {@code Position} for the {@code Point} * @param <P> the {@code Position} type * @return a {@code Point} having the specified {@code Position} and {@code CoordinateReferenceSystem} */ public static <P extends Position> Point<P> point(CoordinateReferenceSystem<P> crs, P p) { return new Point<>(p, crs); }
/** * Creates an empty {@code Point} for a coordinate reference system * * @param crs the coordinate reference system for the created {@code Point} * @param <P> the type of {@code Position} * @return an empty {@code Point} with the specified coordinate reference system */ public static <P extends Position> Point<P> mkEmptyPoint(CoordinateReferenceSystem<P> crs) { return new Point<P>(crs); }
@Override Point<P> toGeometry(CoordinateReferenceSystem<P> crs) { return new Point<P>(p, crs); } }
/** * Creates a {@code Point} from a Position and coordinate reference system * * @param pos the position for the created {@code Point} * @param crs the coordinate reference system for the created {@code Point} * @param <P> the type of {@code Position} * @return a {@code Point} with the specified position and coordinate reference system */ public static <P extends Position> Point<P> mkPoint(P pos, CoordinateReferenceSystem<P> crs) { return new Point<P>(pos, crs); }
protected Point<?> createNullGeometry(CoordinateReferenceSystem<?> crs) { return new Point(crs); }
private <P extends Position> Point<P> decodePoint(ByteBuffer byteBuffer, CoordinateReferenceSystem<P> crs) { PositionSequence<P> points = readPositions(1, byteBuffer, crs); return new Point<P>(points, 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"); }
@Override public Point<P> generate() { return new Point(positionWithin(bbox, rnd), bbox.getCoordinateReferenceSystem()); }
private static <P extends Position> org.geolatte.geom.Point<P> from(org.locationtech.jts.geom.Point jtsPoint, CoordinateReferenceSystem<P> crs) { CoordinateSequence cs = jtsPoint.getCoordinateSequence(); return new org.geolatte.geom.Point<P>(pscsFactory.toPositionSequence(cs, crs.getPositionClass(), crs), crs); }
@Override public <P extends C2D & Measured> Geometry<P> locateBetween(final Geometry<P> geometry, final double startMeasure, final double endMeasure) { if (geometry == null) throw new IllegalArgumentException("Null geometries not allowed."); if (geometry.isEmpty()) return new Point<P>(geometry.getCoordinateReferenceSystem()); if (C2D.class.isAssignableFrom(geometry.getPositionClass()) && Measured.class.isAssignableFrom(geometry.getPositionClass())) { MeasureInterpolatingVisitor visitor = new MeasureInterpolatingVisitor(geometry, startMeasure, endMeasure); geometry.accept((GeometryVisitor<P>) visitor); return (Geometry<P>) visitor.result(); } throw new IllegalArgumentException("Requires projected coordinates"); }
private <P extends Position> Point<P> decodePointText(CoordinateReferenceSystem<P> crs) { WktPointSequenceToken<P> token = decodePointSequence(crs); if (token != null) { PositionSequence<P> positionSequence = token.getPositions(); CoordinateReferenceSystem<P> tcrs = token.getCoordinateReferenceSystem(); return new Point<P>(positionSequence, tcrs); } if (matchesEmptyToken()) { return new Point<P>(crs); } throw new WktDecodeException(buildWrongSymbolAtPositionMsg()); }
private Point<?> createPoint(SqlServerGeometry nativeGeom, int pntOffset) { PositionSequence<?> positionSequence = nativeGeom.coordinateRange(new IndexRange(pntOffset, pntOffset + 1)); return new Point(positionSequence, nativeGeom.getCoordinateReferenceSystem()); }
private static Point convert(org.postgis.Point geometry) { int d = geometry.dimension; CrsId crs = CrsId.valueOf(geometry.srid); double[] point = new double[d + (geometry.haveMeasure ? 1 : 0)]; int offset = 0; point[offset++] = geometry.x; point[offset++] = geometry.y; if (d == 3) { point[offset++] = geometry.z; } if (geometry.haveMeasure) { point[offset++] = geometry.m; } DimensionalFlag flag = DimensionalFlag.valueOf(d == 3, geometry.haveMeasure); return new Point(PointCollectionFactory.create(point, flag, crs)); }
private static Point convert(org.postgis.Point geometry) { int d = geometry.dimension; CrsId crs = CrsId.valueOf(geometry.srid); double[] point = new double[d + (geometry.haveMeasure ? 1 : 0)]; int offset = 0; point[offset++] = geometry.x; point[offset++] = geometry.y; if (d == 3) { point[offset++] = geometry.z; } if (geometry.haveMeasure) { point[offset++] = geometry.m; } DimensionalFlag flag = DimensionalFlag.valueOf(d == 3, geometry.haveMeasure); return new Point(PointCollectionFactory.create(point, flag, crs)); }
@Override @SuppressWarnings("unchecked") Geometry<?> internalDecode(SDOGeometry sdoGeom) { CoordinateReferenceSystem<?> crs = getCoordinateReferenceSystem(sdoGeom); final Double[] ordinates = sdoGeom.getOrdinates().getOrdinateArray(); PositionSequence<? extends Position> positions = convertOrdinateArray(ordinates, sdoGeom, crs); Point[] pnts = new Point[positions.size()]; int i = 0; for (Position p : positions) { pnts[i++] = new Point(p, crs); } return new MultiPoint(pnts); } }
private static Point convertPoint(JGeometry geometry) { CrsId crs = CrsId.valueOf(geometry.getSRID()); double[] point = geometry.getPoint(); int dimensions = geometry.getDimensions(); boolean measured = geometry.isLRSGeometry(); DimensionalFlag flag = DimensionalFlag.valueOf(dimensions > (measured ? 3 : 2), measured); return new Point(PointCollectionFactory.create(point, flag, crs)); }
private static Point convertPoint(JGeometry geometry) { CrsId crs = CrsId.valueOf(geometry.getSRID()); double[] point = geometry.getPoint(); int dimensions = geometry.getDimensions(); boolean measured = geometry.isLRSGeometry(); DimensionalFlag flag = DimensionalFlag.valueOf(dimensions > (measured ? 3 : 2), measured); return new Point(PointCollectionFactory.create(point, flag, crs)); }
@Override public <P extends C2D> Geometry<P> difference(final Geometry<P> geometry, final Geometry<P> other) { checkCompatibleCRS(geometry, other); if (geometry.isEmpty()) return new Point<P>(geometry.getCoordinateReferenceSystem()); if (other.isEmpty()) return geometry; checkNotGeometryCollection(geometry); checkNotGeometryCollection(other); org.locationtech.jts.geom.Geometry difference = SnapIfNeededOverlayOp.overlayOp(JTS.to(geometry), JTS.to(other), OverlayOp.DIFFERENCE); return JTS.from(difference, geometry.getCoordinateReferenceSystem()); }
@Override public <P extends C2D> Geometry<P> intersection(final Geometry<P> geometry, final Geometry<P> other) { checkCompatibleCRS(geometry, other); if (geometry.isEmpty() || other.isEmpty()) return new Point<P>(geometry.getCoordinateReferenceSystem()); checkNotGeometryCollection(geometry); checkNotGeometryCollection(other); org.locationtech.jts.geom.Geometry intersection = SnapIfNeededOverlayOp.overlayOp(JTS.to(geometry), JTS.to(other), OverlayOp.INTERSECTION); return JTS.from(intersection, geometry.getCoordinateReferenceSystem()); }
@Override @SuppressWarnings("unchecked") protected Geometry<?> internalDecode(SDOGeometry nativeGeom) { CoordinateReferenceSystem<? extends Position> crs = getCoordinateReferenceSystem(nativeGeom); Double[] ordinates; if (nativeGeom.getPoint() != null) { if (nativeGeom.getDimension() == 2) { ordinates = new Double[]{nativeGeom.getPoint().x, nativeGeom.getPoint().y}; } else { ordinates = new Double[]{nativeGeom.getPoint().x, nativeGeom.getPoint().y, nativeGeom.getPoint().z}; } } else { ordinates = nativeGeom.getOrdinates().getOrdinateArray(); } return new Point(convertOrdinateArray(ordinates, nativeGeom, crs), crs); }