CoordinateReferenceSystem<?> getCRS(int srid, boolean hasZValues, boolean hasMValues ) { CoordinateReferenceSystem<?> crs = CrsRegistry.getCoordinateReferenceSystemForEPSG(srid, DEFAULT_CRS); if (hasZValues) { crs = CoordinateReferenceSystems.addVerticalSystem(crs, Unit.METER); } if (hasMValues) { crs = CoordinateReferenceSystems.addLinearSystem(crs, Unit.METER); } return (CoordinateReferenceSystem<?>) crs; }
/** * @inheritDoc */ @Override public <P extends C2D, M extends C2D & Measured> Geometry<M> measureOnLength( final Geometry<P> geometry, final Class<M> positionTypeMarker, final boolean keepBeginMeasure) { if (geometry == null) throw new IllegalArgumentException("Geometry parameter must not be NULL"); if (positionTypeMarker == null) throw new IllegalArgumentException("PositionTypeMarker parameter must not be NULL"); if (geometry.getGeometryType() != GeometryType.LINESTRING && geometry.getGeometryType() != GeometryType.MULTILINESTRING) { throw new IllegalArgumentException("Geometry parameter must be of type LineString or MultiLineString"); } final CoordinateReferenceSystem<P> sourceCRS = geometry.getCoordinateReferenceSystem(); final CoordinateReferenceSystem<M> measuredVariant = !hasMeasureAxis(sourceCRS) ? (CoordinateReferenceSystem<M>) addLinearSystem(sourceCRS, Unit.METER) : (CoordinateReferenceSystem<M>)sourceCRS; if (!measuredVariant.getPositionClass().equals(positionTypeMarker)) { throw new IllegalArgumentException(String.format( "Inconsistent types: measured CRS has position type %s, but positionTypeMarker is %s.", measuredVariant.getPositionClass().getName(), positionTypeMarker.getName())); } return new OnLengthMeasureOp<M>(geometry, measuredVariant, keepBeginMeasure).execute(); }
/** * Returns a {@code CoordinateReferenceSystem} derived from the specified @{code {@link CoordinateReferenceSystem}} * but extended with the specified axis * * @param baseCrs the base Coordinate Reference System * @param verticalUnit the Unit for the Vertical axis (or null if not required) * @param measureUnit the Unit for measures (or null if not required) * @return a {@code CoordinateReferenceSystem} with at least the specified dimension, and using the specified * crs as base */ public static CoordinateReferenceSystem<?> mkCoordinateReferenceSystem( CoordinateReferenceSystem<?> baseCrs, LinearUnit verticalUnit, LinearUnit measureUnit) { CoordinateReferenceSystem<?> result = baseCrs; if (verticalUnit != null && !hasVerticalAxis(baseCrs)) { result = addVerticalSystem(result, verticalUnit); } if (measureUnit != null && !hasMeasureAxis(baseCrs)) { result = addLinearSystem(result, measureUnit); } return result; }
/** * Primary Factory method that converts a JTS geometry into an equivalent geolatte geometry * * @param jtsGeometry the jts geometry to convert * @return an equivalent geolatte geometry * @throws IllegalArgumentException when a null object is passed */ public static org.geolatte.geom.Geometry<?> from(org.locationtech.jts.geom.Geometry jtsGeometry) { if (jtsGeometry == null) { throw new IllegalArgumentException("Null object passed."); } Coordinate testCo = jtsGeometry.getCoordinate(); boolean is3D = !(testCo == null || Double.isNaN(testCo.z)); CoordinateReferenceSystem<?> crs = CrsRegistry.ifAbsentReturnProjected2D(jtsGeometry.getSRID()); if (is3D) { crs = CoordinateReferenceSystems.addVerticalSystem(crs, LinearUnit.METER); } // to translate measure, add Measure as LinearSystem boolean hasM = isMeasuredCoordinate(testCo) && !Double.isNaN(testCo.getM()); if (hasM) { crs = CoordinateReferenceSystems.addLinearSystem(crs, LinearUnit.METER); } return from(jtsGeometry, crs); }
private CoordinateReferenceSystem<?> determineCRS(SDOGeometry nativeGeom) { final int srid = nativeGeom.getSRID(); CoordinateReferenceSystem<?> crs = CrsRegistry.ifAbsentReturnProjected2D(srid); if (getVerticalDimension(nativeGeom) > 0) { crs = CoordinateReferenceSystems.addVerticalSystem(crs, LinearUnit.METER); } if (getLinearReferenceDimension(nativeGeom) > 0) { crs = CoordinateReferenceSystems.addLinearSystem(crs, LinearUnit.METER); } return crs; }
private CoordinateReferenceSystem<?> ensureZM(CoordinateReferenceSystem<?> crs, boolean needZ, boolean needM) { CoordinateReferenceSystem<?> compound = crs; if (needZ && ! hasVerticalAxis(compound)) { compound = addVerticalSystem(compound, Unit.METER); } if (needM && ! hasMeasureAxis(compound)) { compound = addLinearSystem(compound, Unit.METER); } if (forceToCRS && !compound.equals(crs)) { throw new WktDecodeException("WKT inconsistent with specified Coordinate Reference System"); } return compound; }
@Override @SuppressWarnings("unchecked") protected <P extends Position> CoordinateReferenceSystem<P> readCrs(ByteBuffer byteBuffer, int typeCode, CoordinateReferenceSystem<P> crs) { boolean hasM = (typeCode & PostgisWkbTypeMasks.M_FLAG) == PostgisWkbTypeMasks.M_FLAG; boolean hasZ = (typeCode & PostgisWkbTypeMasks.Z_FLAG) == PostgisWkbTypeMasks.Z_FLAG; // if set, just validate if (crs != null) { validateCrs(crs, hasM, hasZ); return crs; } CoordinateReferenceSystem crsDeclared; if (hasSrid(typeCode)) { int srid = byteBuffer.getInt(); crsDeclared = CrsRegistry.getCoordinateReferenceSystemForEPSG(srid, CoordinateReferenceSystems.PROJECTED_2D_METER); } else { crsDeclared = CoordinateReferenceSystems.PROJECTED_2D_METER; } if (hasZ) { crsDeclared = addVerticalSystem(crsDeclared, Unit.METER); } if (hasM) { crsDeclared = addLinearSystem(crsDeclared, Unit.METER); } return (CoordinateReferenceSystem<P>)crsDeclared; }