private <P extends Position> int getPointByteSize(Geometry<P> geom) { return geom.getCoordinateDimension() * ByteBuffer.DOUBLE_SIZE; }
protected <P extends Position> int getLRSDim(Geometry<P> geom) { if (Measured.class.isAssignableFrom(geom.getPositionClass())) { if (geom.getCoordinateDimension() == 3) { return 3; } else { return 4; } } return 0; }
/** * Returns the position at the specified index in the <code>PositionSequence</code> of this <code>Geometry</code>. * * @param index the position in the <code>PositionSequence</code> (first point is at index 0). * @return the position at the specified index in the <code>PositionSequence</code> of this <code>Geometry</code>. */ public P getPositionN(int index) { if (index >= getPositions().size()) { throw new IndexOutOfBoundsException(); } double[] coords = new double[getCoordinateDimension()]; getPositions().getCoordinates(index, coords); return Positions.mkPosition(getCoordinateReferenceSystem(), coords); }
@Override public <P extends Position, G extends Geometry<P>> SDOGeometry encode(G geom) { final int dim = geom.getCoordinateDimension(); final int lrsPos = getLRSDim(geom); SDOGType sdogType = new SDOGType(dim, lrsPos, TypeGeometry.POLYGON); SDOGeometry base = new SDOGeometry(sdogType, geom.getSRID(), null, null, null); Polygon<?> polygon = (Polygon<?>)geom; return addPolygon(base, polygon); }
@Override public <P extends Position, G extends Geometry<P>> SDOGeometry encode(G geom) { final int dim = geom.getCoordinateDimension(); final int lrsPos = getLRSDim(geom); final boolean isLrs = lrsPos > 0; final Double[] ordinates = convertPositionSequence(geom.getPositions()); final ElemInfo info = new ElemInfo(1); info.setElement(0, 1, ElementType.LINE_STRAITH_SEGMENTS, 0); return new SDOGeometry( new SDOGType(dim, lrsPos, TypeGeometry.LINE), geom.getSRID(), null, info, new Ordinates(ordinates)); }
@Override @SuppressWarnings("unchecked") public <P extends Position, G extends Geometry<P>> SDOGeometry encode(G geom) { final int dim = geom.getCoordinateDimension(); final int lrsDim = getLRSDim(geom); final boolean isLrs = (lrsDim != 0); MultiPoint<P> multiPoint = (MultiPoint<P>) geom; final ElemInfo info = new ElemInfo(multiPoint.getNumGeometries()); int oordinatesOffset = 1; Double[] ordinates = new Double[]{}; for (int i = 0; i < multiPoint.getNumGeometries(); i++) { info.setElement(i, oordinatesOffset, ElementType.POINT, 0); ordinates = addOrdinates(ordinates, pointToOrdinates(multiPoint, i)); oordinatesOffset = ordinates.length + 1; } return new SDOGeometry(new SDOGType(dim, lrsDim, TypeGeometry.MULTIPOINT), geom.getSRID(), null, info, new Ordinates(ordinates)); }
@Override public <P extends Position, G extends Geometry<P>> SDOGeometry encode(G geom) { final int dim = geom.getCoordinateDimension(); final int lrsDim = getLRSDim(geom); final boolean isLrs = (lrsDim != 0); final Double[] coord = convertPositionSequence(geom.getPositions()); if (Settings.useSdoPointType() && !isLrs && !geom.isEmpty()) { return new SDOGeometry( new SDOGType(dim, lrsDim, TypeGeometry.POINT), geom.getSRID(), new SDOPoint(coord), null, null ); } final ElemInfo info = new ElemInfo(1); info.setElement(0, 1, ElementType.POINT, 1); return new SDOGeometry( new SDOGType(dim, lrsDim, TypeGeometry.POINT), geom.getSRID(), null, info, new Ordinates(coord) ); }