/** * Creates a {@code LinearRing} from a {@code PositionSequence} and coordinate reference system * * @param seq the {@code PositionSequence} for the created {@code LinearRing} * @param crs the coordinate reference system for the created {@code LinearRing} * @param <P> the type of {@code Position} * @return a {@code LinearRing} with the specified positions and coordinate reference system */ public static <P extends Position> LinearRing<P> mkLinearRing(PositionSequence<P> seq, CoordinateReferenceSystem<P> crs) { return new LinearRing<P>(seq, crs); }
@Override @SuppressWarnings("unchecked") public <Q extends Position> LinearRing<Q> as(Class<Q> castToType){ checkCast(castToType); return (LinearRing<Q>)this; } }
public LinearRing(LineString<P> lineString) { super(lineString); checkIsClosed(); }
protected void writeRing(LinearRing<P> geom) { output.putUInt(geom.getNumPositions()); writePoints(geom.getPositions(), geom.getCoordinateDimension(), output); }
private void checkLinearRing(LinearRing<P> ring, CoordinateReferenceSystem<P> crs) { if (ring == null) throw new IllegalArgumentException("NULL linear ring is not valid."); if (ring.isEmpty()) throw new IllegalArgumentException("Empty linear ring is not valid."); if (!ring.getCoordinateReferenceSystem().equals(crs)) throw new IllegalArgumentException("Linear ring with different CRS than exterior boundary."); }
private static org.postgis.LinearRing convert(LinearRing linearRing) { org.postgis.Point[] pgPoints = convertPoints(linearRing); org.postgis.LinearRing pgLinearRing = new org.postgis.LinearRing(pgPoints); pgLinearRing.haveMeasure = linearRing.isMeasured(); pgLinearRing.setSrid(linearRing.getSRID()); return pgLinearRing; }
private static JGeometry convert(Polygon geometry) { int srid = geometry.getSRID(); int dim = geometry.getCoordinateDimension(); double[] points = getPoints(geometry.getPoints()); int[] elemInfo = new int[3 + geometry.getNumInteriorRing() * 3]; int offset = 0; int pointOffset = 1; elemInfo[offset++] = pointOffset; elemInfo[offset++] = 1003; // exterior elemInfo[offset++] = 1; pointOffset += geometry.getExteriorRing().getNumPoints() * dim; for (int i = 0; i < geometry.getNumInteriorRing(); i++) { elemInfo[offset++] = pointOffset; elemInfo[offset++] = 2003; elemInfo[offset++] = 1; pointOffset += geometry.getInteriorRingN(i).getNumPoints() * dim; } int gtype = dim * 1000 + (geometry.isMeasured() ? dim : 0) * 100 + GTYPE_POLYGON; return new JGeometry(gtype, srid, elemInfo, points); }
public void visit(Polygon polygon, int parent) { Shape shape = new Shape(); shape.type = POLYGON; shape.figureOffset = figures.size(); shape.parentOffset = parent; shapes.add(shape); // exterior Figure figure = new Figure(); figure.attributes = 2; figure.pointOffset = points.size(); figures.add(figure); for (Point point : polygon.getExteriorRing().getPoints()) { points.add(point); } // interior for (int i = 0; i < polygon.getNumInteriorRing(); i++) { figure = new Figure(); figure.attributes = 0; figure.pointOffset = points.size(); figures.add(figure); for (Point point : polygon.getInteriorRingN(i).getPoints()) { points.add(point); } } }
private static org.postgis.LinearRing convert(LinearRing linearRing) { org.postgis.Point[] pgPoints = convertPoints(linearRing); org.postgis.LinearRing pgLinearRing = new org.postgis.LinearRing(pgPoints); pgLinearRing.haveMeasure = linearRing.isMeasured(); pgLinearRing.setSrid(linearRing.getSRID()); return pgLinearRing; }
private static JGeometry convert(Polygon geometry) { int srid = geometry.getSRID(); int dim = geometry.getCoordinateDimension(); double[] points = getPoints(geometry.getPoints()); int[] elemInfo = new int[3 + geometry.getNumInteriorRing() * 3]; int offset = 0; int pointOffset = 1; elemInfo[offset++] = pointOffset; elemInfo[offset++] = 1003; // exterior elemInfo[offset++] = 1; pointOffset += geometry.getExteriorRing().getNumPoints() * dim; for (int i = 0; i < geometry.getNumInteriorRing(); i++) { elemInfo[offset++] = pointOffset; elemInfo[offset++] = 2003; elemInfo[offset++] = 1; pointOffset += geometry.getInteriorRingN(i).getNumPoints() * dim; } int gtype = dim * 1000 + (geometry.isMeasured() ? dim : 0) * 100 + GTYPE_POLYGON; return new JGeometry(gtype, srid, elemInfo, points); }
public void visit(Polygon polygon, int parent) { Shape shape = new Shape(); shape.type = POLYGON; shape.figureOffset = figures.size(); shape.parentOffset = parent; shapes.add(shape); // exterior Figure figure = new Figure(); figure.attributes = 2; figure.pointOffset = points.size(); figures.add(figure); for (Point point : polygon.getExteriorRing().getPoints()) { points.add(point); } // interior for (int i = 0; i < polygon.getNumInteriorRing(); i++) { figure = new Figure(); figure.attributes = 0; figure.pointOffset = points.size(); figures.add(figure); for (Point point : polygon.getInteriorRingN(i).getPoints()) { points.add(point); } } }
/** * Creates a <code>Polygon</code> with no holes, and having the specified <code>PositionSequence</code> as exterior boundary * * @param positionSequence the <code>PositionSequence</code> representing the exterior boundary * @throws IllegalArgumentException when the specified <code>PositionSequence</code> does not form a * <code>LinearRing</code> (i.e., is empty or not closed). */ @SuppressWarnings("unchecked") public Polygon(PositionSequence<P> positionSequence, CoordinateReferenceSystem<P> crs) { this(new LinearRing<P>(positionSequence, crs)); }
public LinearRing(PositionSequence<P> points, CoordinateReferenceSystem<P> crs) { super(points, crs); checkIsClosed(); }
@Override LinearRing<P> toGeometry(CoordinateReferenceSystem<P> crs) { return new LinearRing<P>(toSeq(crs, positions), crs); } }
/** * Creates a {@code LinearRing} * * @param crs the {@code CoordinateReferenceSystem} for the {@code LinearRing} * @param positions the {@code Position}s for the {@code LinearRing} * @param <P> the {@code Position} type * @return a {@code LinearRing} having the specified {@code Position}s and {@code CoordinateReferenceSystem} */ public static <P extends Position> LinearRing<P> ring(CoordinateReferenceSystem<P> crs, P... positions) { return new LinearRing<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"); }
private LinearRing<?> toLinearRing(SqlServerGeometry nativeGeom, IndexRange range) { PositionSequence<?> positionSequence = nativeGeom.coordinateRange(range); return new LinearRing(positionSequence, nativeGeom.getCoordinateReferenceSystem()); }
private static LinearRing convert(org.postgis.LinearRing geometry) { PointSequence points = convertPoints(geometry.getPoints()); return new LinearRing(points); }
private Polygon decodePolygon(int shapeIdx) { Shape shape = shapes[shapeIdx]; int figureOffset = shape.figureOffset; if (figureOffset <= -1) { return Polygon.createEmpty(); } int figureStopIdx = figures.length - 1; if (shapeIdx < (shapes.length - 1)) { figureStopIdx = shapes[shapeIdx + 1].figureOffset - 1; } List<LinearRing> linearRings = Lists.newArrayList(); for (int i = figureOffset; i <= figureStopIdx; i++) { linearRings.add(new LinearRing(createPoints(i))); } return new Polygon(linearRings.toArray(new LinearRing[0])); }
private static LinearRing convert(org.postgis.LinearRing geometry) { PointSequence points = convertPoints(geometry.getPoints()); return new LinearRing(points); }