private static void loadCRS() throws IOException { BufferedReader reader = createReader(); try { String line = reader.readLine(); CrsWktDecoder decoder = new CrsWktDecoder(); while (line != null) { addDefinition(line, decoder); line = reader.readLine(); } } finally { reader.close(); } }
/** * returns the <code>CoordinateReferenceSystem</code> for the specified EPSG code. * * @param epsgCode the EPSG code * @param fallback the coordinate * @return the <code>CoordinateReferenceSystem</code> corresponding to the specified EPSG code, or null if * no such system is registered. */ public static CoordinateReferenceSystem<?> getCoordinateReferenceSystemForEPSG(int epsgCode, CoordinateReferenceSystem<?> fallback) { return getCoordinateReferenceSystem(CrsId.valueOf(epsgCode), fallback); }
@Override protected <P extends Position> CoordinateReferenceSystem<P> readCrs(ByteBuffer byteBuffer, int typeCode, CoordinateReferenceSystem<P> crs) { // if a CRS is already specified, ignore this value if (crs != null) return crs; CoordinateReferenceSystem crsDeclared = CrsRegistry.getCoordinateReferenceSystemForEPSG(srid, CoordinateReferenceSystems.PROJECTED_2D_METER); return (CoordinateReferenceSystem<P>)crsDeclared; }
/** * Returns the registered coordinate reference system, or when unavailable in the registry, create a new Geographic 2D system and register * this on-the-fly. * * @param epsgCode the code to look up * @return a CoordinateReferenceSystem with the specified epsg code */ public static CoordinateReferenceSystem<?> ifAbsentReturnGeographic2D(int epsgCode) { return computeIfAbsent(CrsId.valueOf(epsgCode), key -> CoordinateReferenceSystems.mkGeographic(key, AngularUnit.RADIAN)); }
/** * 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); }
/** * Returns the registered coordinate reference system, or when unavailable in the registry, create a new Projected 2D system and register * this on-the-fly. * * @param epsgCode the code to look up * @return a CoordinateReferenceSystem with the specified epsg code */ public static CoordinateReferenceSystem<?> ifAbsentReturnProjected2D(int epsgCode) { return computeIfAbsent(CrsId.valueOf(epsgCode), key -> CoordinateReferenceSystems.mkProjected(key, LinearUnit.METER)); }
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; }
@SuppressWarnings("unchecked") protected static <T extends Position> CoordinateReferenceSystem<T> getCrs(Geometry<T>[] geometries) { if (geometries == null || geometries.length == 0) { return (CoordinateReferenceSystem<T>)CrsRegistry.getCoordinateReferenceSystemForEPSG(-1, CoordinateReferenceSystems.PROJECTED_2D_METER); } return geometries[0].getCoordinateReferenceSystem(); }
public static CoordinateReferenceSystem<?> mkCoordinateReferenceSystem( int epsgCode, LinearUnit verticalUnit, LinearUnit measureUnit) { return mkCoordinateReferenceSystem( CrsRegistry.getCoordinateReferenceSystemForEPSG(epsgCode, PROJECTED_2D_METER), verticalUnit, measureUnit ); }
/** * The instance fields wktString and crsId are initialized prior to decoding. For postgis EWKT that entails * extracting the SRID prefix (if any) from the WKT string. * * @param wkt the WKT representation */ private <P extends Position> void prepare(String wkt, CoordinateReferenceSystem<P> crs) { Matcher matcher = SRID_RE.matcher(wkt); if (matcher.find()) { int srid = Integer.parseInt(matcher.group(1)); this.crs = crs != null? crs : CrsRegistry.getCoordinateReferenceSystemForEPSG(srid, CoordinateReferenceSystems.PROJECTED_2D_METER); wktString = wkt.substring(matcher.end()); } else { this.crs = crs != null ? crs : CoordinateReferenceSystems.PROJECTED_2D_METER; wktString = wkt; } }
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; }
@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; }