/** * 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); }
/** * 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)); }
@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 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 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 <P extends Position> LinearRing<P> readRing(ByteBuffer byteBuffer, CoordinateReferenceSystem<P> crs) { int numPoints = byteBuffer.getInt(); PositionSequence<P> ps = readPositions(numPoints, byteBuffer, crs); try { return new LinearRing<P>(ps, crs); } catch (IllegalArgumentException e) { throw new WkbDecodeException(e); } }
/** * Returns the exterior boundary of this <code>Polygon</code>. * * @return a <code>LinearRing</code> representing the exterior boundary of this <code>Polygon</code>. */ public LinearRing<P> getExteriorRing() { return this.isEmpty() ? new LinearRing<P>(getPositions(), getCoordinateReferenceSystem()) : this.rings[0]; }
private <P extends Position> LinearRing<P> decodeLinearRingText(CoordinateReferenceSystem<P> crs) { try { WktPointSequenceToken<P> token = decodePointSequence(crs); if (token == null) throw new WktDecodeException("No Linear Ring when expected"); return new LinearRing<P>(token.getPositions(), token.getCoordinateReferenceSystem()); } catch (IllegalArgumentException ex) { throw new WktDecodeException(ex.getMessage()); } }
final LinearRing lr = new LinearRing(cs, crs); holes.addLast(lr); } else { shell = null; shell = new LinearRing(cs, crs); holes = new LinkedList<LinearRing>();
@SuppressWarnings("unchecked") private static <P extends Position> org.geolatte.geom.Polygon<P> from(Polygon jtsGeometry, CoordinateReferenceSystem<P> crs) { if (jtsGeometry.isEmpty()) { return new org.geolatte.geom.Polygon<P>(crs); } org.geolatte.geom.LinearRing<P>[] rings = new org.geolatte.geom.LinearRing[jtsGeometry.getNumInteriorRing() + 1]; org.geolatte.geom.LineString<P> extRing = from(jtsGeometry.getExteriorRing(), crs); rings[0] = new org.geolatte.geom.LinearRing(extRing.getPositions(), extRing.getCoordinateReferenceSystem()); for (int i = 1; i < rings.length; i++) { org.geolatte.geom.LineString intRing = from(jtsGeometry.getInteriorRingN(i - 1), crs); rings[i] = new org.geolatte.geom.LinearRing(intRing); } return new org.geolatte.geom.Polygon(rings); }
private static Polygon convertPolygon(JGeometry geometry) { CrsId crs = CrsId.valueOf(geometry.getSRID()); int dimensions = geometry.getDimensions(); boolean measured = geometry.isLRSGeometry(); DimensionalFlag flag = DimensionalFlag.valueOf(dimensions > (measured ? 3 : 2), measured); Object[] elements = geometry.getOrdinatesOfElements(); LinearRing[] rings = new LinearRing[elements.length]; for (int i = 0; i < elements.length; i++) { PointSequence points = PointCollectionFactory.create((double[]) elements[i], flag, crs); rings[i] = new LinearRing(points); } return new Polygon(rings); }
private static Polygon convertPolygon(JGeometry geometry) { CrsId crs = CrsId.valueOf(geometry.getSRID()); int dimensions = geometry.getDimensions(); boolean measured = geometry.isLRSGeometry(); DimensionalFlag flag = DimensionalFlag.valueOf(dimensions > (measured ? 3 : 2), measured); Object[] elements = geometry.getOrdinatesOfElements(); LinearRing[] rings = new LinearRing[elements.length]; for (int i = 0; i < elements.length; i++) { PointSequence points = PointCollectionFactory.create((double[]) elements[i], flag, crs); rings[i] = new LinearRing(points); } return new Polygon(rings); }
@Override @SuppressWarnings("unchecked") Geometry<?> internalDecode(SDOGeometry sdoGeom) { CoordinateReferenceSystem crs = getCoordinateReferenceSystem(sdoGeom); LinearRing shell = null; final LinearRing[] rings = new LinearRing[sdoGeom.getNumElements()]; final ElemInfo info = sdoGeom.getInfo(); int i = 0; int idxInteriorRings = 1; while (i < info.getSize()) { PositionSequence cs = null; int numCompounds = 0; if (info.getElementType(i).isCompound()) { numCompounds = info.getNumCompounds(i); cs = add(cs, getCompoundCSeq(i + 1, i + numCompounds, sdoGeom)); } else { cs = add(cs, getElementCSeq(i, sdoGeom, false, crs)); } if (info.getElementType(i).isInteriorRing()) { rings[idxInteriorRings] = new LinearRing(cs, crs); idxInteriorRings++; } else { rings[0] = new LinearRing(cs, crs); } i += 1 + numCompounds; } return new Polygon(rings); } }