Class CustomProjection
java.lang.Object
org.openstreetmap.josm.data.projection.AbstractProjection
org.openstreetmap.josm.data.projection.CustomProjection
- All Implemented Interfaces:
Projecting,Projection
Custom projection.
Inspired by PROJ.4 and Proj4J.
- Since:
- 5072
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumProj4-like projection parameters.(package private) static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringStarting in PROJ 4.8.0, the+axisargument can be used to control the axis orientation of the coordinate system.protected Boundsprotected Stringprivate static final doubleprivate doubleprotected Stringprivate EnumMap<CustomProjection.Polarity,EastNorth> protected Stringpref String that defines the projection -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new emptyCustomProjection.CustomProjection(String pref) Constructs a newCustomProjectionwith given parameters.CustomProjection(String name, String code, String pref) Constructs a newCustomProjectionwith given name, code and parameters. -
Method Summary
Modifier and TypeMethodDescriptiongetEastNorthBoundsBox(ProjectionBounds box, Projection boxProjection) Get a box in east/north space of this projection, that fully contains an east/north box of another projection.Returns The EPSG Code of this CRS.Find lat/lon-box containing all the area of a given rectangle in east/north space.doubleFactor to convert units of east/north coordinates to meters.private static EastNorthgetPointAlong(int i, int n, ProjectionBounds r) private EastNorthgetPole(CustomProjection.Polarity whichPole) Get the bounds of the world.booleanReturn true, if a geographic coordinate reference system is represented.static doubleparseAngle(String angleStr, String parameterName) Convert an angle string to a double valuestatic BoundsparseBounds(String boundsStr) Converts a string to a bounds objectparseDatum(Map<String, String> parameters, Ellipsoid ellps) Gets the datumstatic doubleparseDouble(String doubleStr, String parameterName) static doubleparseDouble(Map<String, String> parameters, String parameterName) parseEllipsoid(Map<String, String> parameters) Gets the ellipsoidparseParameterList(String pref, boolean ignoreUnknownParameter) Parse a parameter list to key=value pairs.parseProjection(Map<String, String> parameters, Ellipsoid ellps) Gets a projection using the given ellipsoidparseToWGS84(String paramList, Ellipsoid ellps) Parsetowgs84parameter.resolveInits(Map<String, String> parameters, boolean ignoreUnknownParameter) Recursive resolution of +init includes.booleanswitchXY()Does this projection natural order of coordinates is North East, instead of East NorthtoCode()Default implementation of toCode().toString()Describe the projection in one or two words.final voidUpdates thisCustomProjectionwith given parameters.Methods inherited from class org.openstreetmap.josm.data.projection.AbstractProjection
convertDegreeMinuteSecond, convertMinuteSecond, eastNorth2latlon, eastNorth2latlonClamped, getBaseProjection, getCentralMeridian, getDatum, getDefaultZoomInPPD, getEllipsoid, getFalseEasting, getFalseNorthing, getProj, getProjectingsForArea, getScaleFactor, getToMeter, getWorldBoundsBoxEastNorth, latlon2eastNorth, visitOutlineMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.data.projection.Projecting
getCacheKey, latlon2eastNorth
-
Field Details
-
METER_PER_UNIT_DEGREE
- See Also:
-
UNITS_TO_METERS
-
PRIME_MERIDANS
-
pref
pref String that defines the projectionnull means fall back mode (Mercator)
-
name
-
code
-
bounds
-
metersPerUnitWMTS
-
axis
Starting in PROJ 4.8.0, the+axisargument can be used to control the axis orientation of the coordinate system. The default orientation is "easting, northing, up" but directions can be flipped, or axes flipped using combinations of the axes in the+axisswitch. The values are:e(Easting),w(Westing),n(Northing),s(Southing),u(Up),d(Down); Examples:+axis=enu(the default easting, northing, elevation),+axis=neu(northing, easting, up; useful for "lat/long" geographic coordinates, or south orientated transverse mercator),+axis=wnu(westing, northing, up - some planetary coordinate systems have "west positive" coordinate systems)See proj4.org
-
LON_LAT_VALUES
-
polesEN
-
-
Constructor Details
-
CustomProjection
public CustomProjection()Constructs a new emptyCustomProjection. -
CustomProjection
Constructs a newCustomProjectionwith given parameters.- Parameters:
pref- String containing projection parameters (ex: "+proj=tmerc +lon_0=-3 +k_0=0.9996 +x_0=500000 +ellps=WGS84 +datum=WGS84 +bounds=-8,-5,2,85")
-
CustomProjection
Constructs a newCustomProjectionwith given name, code and parameters.- Parameters:
name- describe projection in one or two wordscode- unique code for this projection - may be nullpref- the string that defines the custom projection
-
-
Method Details
-
update
Updates thisCustomProjectionwith given parameters.- Parameters:
pref- String containing projection parameters (ex: "+proj=lonlat +ellps=WGS84 +datum=WGS84 +bounds=-180,-90,180,90")- Throws:
ProjectionConfigurationException- ifprefcannot be parsed properly
-
parseParameterList
public static Map<String,String> parseParameterList(String pref, boolean ignoreUnknownParameter) throws ProjectionConfigurationException Parse a parameter list to key=value pairs.- Parameters:
pref- the parameter listignoreUnknownParameter- true, if unknown parameter should not raise exception- Returns:
- parameters map
- Throws:
ProjectionConfigurationException- in case of invalid parameter
-
resolveInits
public static Map<String,String> resolveInits(Map<String, String> parameters, boolean ignoreUnknownParameter) throws ProjectionConfigurationExceptionRecursive resolution of +init includes.- Parameters:
parameters- parameters mapignoreUnknownParameter- true, if unknown parameter should not raise exception- Returns:
- parameters map with +init includes resolved
- Throws:
ProjectionConfigurationException- in case of invalid parameter
-
parseEllipsoid
public Ellipsoid parseEllipsoid(Map<String, String> parameters) throws ProjectionConfigurationExceptionGets the ellipsoid- Parameters:
parameters- The parameters to get the value from- Returns:
- The Ellipsoid as specified with the parameters
- Throws:
ProjectionConfigurationException- in case of invalid parameters
-
parseDatum
public Datum parseDatum(Map<String, String> parameters, Ellipsoid ellps) throws ProjectionConfigurationExceptionGets the datum- Parameters:
parameters- The parameters to get the value fromellps- The ellisoid that was previously computed- Returns:
- The Datum as specified with the parameters
- Throws:
ProjectionConfigurationException- in case of invalid parameters
-
parseToWGS84
public Datum parseToWGS84(String paramList, Ellipsoid ellps) throws ProjectionConfigurationException Parsetowgs84parameter.- Parameters:
paramList- List of parameter arguments (expected: 3 or 7)ellps- ellipsoid- Returns:
- parsed datum (
ThreeParameterDatumorSevenParameterDatum) - Throws:
ProjectionConfigurationException- if the arguments cannot be parsed
-
parseProjection
public Proj parseProjection(Map<String, String> parameters, Ellipsoid ellps) throws ProjectionConfigurationExceptionGets a projection using the given ellipsoid- Parameters:
parameters- Additional parametersellps- TheEllipsoid- Returns:
- The projection
- Throws:
ProjectionConfigurationException- in case of invalid parameters
-
parseBounds
Converts a string to a bounds object- Parameters:
boundsStr- The string as comma separated list of angles.- Returns:
- The bounds.
- Throws:
ProjectionConfigurationException- in case of invalid parameter- See Also:
-
parseDouble
public static double parseDouble(Map<String, String> parameters, String parameterName) throws ProjectionConfigurationException- Throws:
ProjectionConfigurationException
-
parseDouble
public static double parseDouble(String doubleStr, String parameterName) throws ProjectionConfigurationException - Throws:
ProjectionConfigurationException
-
parseAngle
public static double parseAngle(String angleStr, String parameterName) throws ProjectionConfigurationException Convert an angle string to a double value- Parameters:
angleStr- The string. e.g. -1.1 or 50d10'3"parameterName- Only for error message.- Returns:
- The angle value, in degrees.
- Throws:
ProjectionConfigurationException- in case of invalid parameter
-
getEpsgCode
Description copied from class:AbstractProjectionReturns The EPSG Code of this CRS.- Specified by:
getEpsgCodein classAbstractProjection- Returns:
- The EPSG Code of this CRS, null if it doesn't have one.
-
toCode
Description copied from class:AbstractProjectionDefault implementation of toCode(). Should be overridden, if there is no EPSG code for this CRS.- Specified by:
toCodein interfaceProjection- Overrides:
toCodein classAbstractProjection- Returns:
- the projection identifier
-
getWorldBoundsLatLon
Description copied from interface:ProjectionGet the bounds of the world.- Returns:
- the supported lat/lon rectangle for this projection
-
toString
Description copied from interface:ProjectionDescribe the projection in one or two words.- Specified by:
toStringin interfaceProjection- Overrides:
toStringin classObject- Returns:
- the name / description
-
getMetersPerUnit
Factor to convert units of east/north coordinates to meters. When east/north coordinates are in degrees (geographic CRS), the scale at the equator is taken, i.e. 360 degrees corresponds to the length of the equator in meters.- Returns:
- factor to convert units to meter
-
switchXY
Description copied from interface:ProjectionDoes this projection natural order of coordinates is North East, instead of East North- Returns:
- true if natural order of coordinates is North East, false if East North
-
getUnitsToMeters
-
getPrimeMeridians
-
getPointAlong
-
getPole
-
getLatLonBoundsBox
Description copied from interface:ProjectionFind lat/lon-box containing all the area of a given rectangle in east/north space. This is an approximate method. Points outside of the world should be ignored.- Parameters:
r- the rectangle in projected space- Returns:
- minimum lat/lon box, that when projected, covers
pb
-
getEastNorthBoundsBox
Description copied from interface:ProjectionGet a box in east/north space of this projection, that fully contains an east/north box of another projection. Reprojecting a rectangular box from one projection to another may distort/rotate the shape of the box, so in general one needs to walk along the boundary in small steps to get a reliable result. This is an approximate method.- Parameters:
box- the east/north box given in projectionboxProjectionboxProjection- the projection ofbox- Returns:
- an east/north box in this projection, containing the given box
-
isGeographic
Return true, if a geographic coordinate reference system is represented.I.e. if it returns latitude/longitude values rather than Cartesian east/north coordinates on a flat surface.
- Returns:
- true, if it is geographic
- Since:
- 12792
-