public GeographicToGeocentricConversion(GeographicCoordinateReferenceSystem sourceCRS) { primeMerid = sourceCRS.getPrimeMeridian().getLongitude(); semiMajorAxis = sourceCRS.getDatum().getEllipsoid().getSemiMajorAxis(); double invFlatt = sourceCRS.getDatum().getEllipsoid().getInverseFlattening(); double flatt = 1 / invFlatt; eccentricity2 = (2 - flatt) * flatt; epsilon = eccentricity2 / (1 - eccentricity2); semiMinorAxis = semiMajorAxis * (1 - flatt); }
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; }
/** * 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)); }
/** * 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)); }
/** * Creates a generic geographic coordinate reference system using the specified units of length for coordinates. * <p/> * A generic system is one without a precisely defined datum or ellipsoid. * * @param * @param unit the unit to use for the planar coordinates. * @return a {@code CoordinateReferenceSystem} */ public static GeographicCoordinateReferenceSystem mkGeographic(CrsId srid, AngularUnit unit) { return new Geographic2DCoordinateReferenceSystem(srid, "Generic 2D Geographic", new EllipsoidalCoordinateSystem2D(new GeodeticLatitudeCSAxis("Lat", unit), new GeodeticLongitudeCSAxis ("Lon", unit))); }
public static ProjectedCoordinateReferenceSystem mkProjected(CrsId srid, LinearUnit unit) { return new ProjectedCoordinateReferenceSystem(srid, "Generic 2D Projected", mkGeographic(Unit.DEGREE), Projection.UNKNOWN, new ArrayList<>(), new CartesianCoordinateSystem2D(new StraightLineAxis("X", CoordinateSystemAxisDirection.EAST, unit), new StraightLineAxis("Y", CoordinateSystemAxisDirection.NORTH, unit))); }
public static <P extends Position> boolean hasAxisOrder(CoordinateReferenceSystem<P> crs, int order) { CoordinateSystemAxis[] axes = crs.getCoordinateSystem().getAxes(); for (CoordinateSystemAxis axis : axes) { if (axis.getNormalOrder() == order) { return true; } } return false; }
/** * Creates a 1-Dimensional {@code LinearCoordinateReferenceSystem} * * @param unit the linear unit tot use * @return a {@code LinearCoordinateReferenceSystem} with an M-axis */ public static LinearCoordinateReferenceSystem mkLinear(LinearUnit unit) { return new LinearCoordinateReferenceSystem("measure", new MeasureStraightLineAxis("M", unit)); }
/** * Creates a 1-Dimensional {@code VerticalCoordinateReferenceSystem} * * @param unit the linear unit to use * @return a {@code LinearCoordinateReferenceSystem} with an Z-axis */ public static VerticalCoordinateReferenceSystem mkVertical(LinearUnit unit) { return new VerticalCoordinateReferenceSystem(CrsId.UNDEFINED, "vertical", VerticalDatum .UNKNOWN_VERTICAL_DATUM, new VerticalStraightLineAxis("Z", unit)); }
/** * Returns the coordinate dimension, i.e. the number of axes in this coordinate reference system. * * @return the coordinate dimension */ public int getCoordinateDimension() { return getCoordinateSystem().getCoordinateDimension(); }
/** * Returns the index of the specified axis in this {@code CoordinateReferenceSystem}, or * -1 if it is not an axis of this system. * * @param axis the axis to look up * @return the index of the specified axis in this {@code CoordinateReferenceSystem} */ public int getAxisIndex(CoordinateSystemAxis axis) { return getCoordinateSystem().getAxisIndex(axis); }