Package org.apache.sis.storage.geotiff
Class CRSBuilder
java.lang.Object
org.apache.sis.internal.referencing.ReferencingFactoryContainer
org.apache.sis.storage.geotiff.CRSBuilder
Helper class for building a
CoordinateReferenceSystem
from information found in TIFF tags.
GeoKeys are loaded by GeoKeysLoader
and consumed by this class.- Since:
- 0.8
- Version:
- 1.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean
true
when an exception has been thrown but thisCRSBuilder
already reported a warning, so there is no need for the caller to report a warning again.org.opengis.metadata.spatial.CellGeometry
POINT
ifGeoKeys.RasterType
isGeoCodes.RasterPixelIsPoint
,AREA
if it isGeoCodes.RasterPixelIsArea
, or null if unspecified.(package private) static final int
Index where to store the name of the geodetic CRS, the datum, the ellipsoid and the prime meridian.Suggested value for a general description of the transformation form grid coordinates to "real world" coordinates.(package private) static final int
Index where to store the name of the geodetic CRS, the datum, the ellipsoid and the prime meridian.(package private) static final int
Index where to store the name of the geodetic CRS, the datum, the ellipsoid and the prime meridian.All values found in theGeoKeyDirectory
after the header.private org.opengis.metadata.Identifier
Name of the last object created.private short
Version of the set of keys declared in theGeoKeyDirectory
header.private static final int
Minimal length that a key in a name must have before we compare them to theNAME_KEYS
.private short
Version of the set of keys declared in theGeoKeyDirectory
header.Missing GeoKeys, used for avoiding to report the same warning twice.private static final String[]
Keys that may be used in the value associated toGeoKeys.GeogCitation
.private static final short[][]
Map projection parameters to be considered as aliases.(package private) static final int
Index where to store the name of the geodetic CRS, the datum, the ellipsoid and the prime meridian.private final Reader
The reader for which we will create coordinate reference systems.Fields inherited from class org.apache.sis.internal.referencing.ReferencingFactoryContainer
CRS_FACTORY, CS_FACTORY, DATUM_FACTORY, MT_FACTORY
-
Constructor Summary
ConstructorsConstructorDescriptionCRSBuilder
(Reader reader) Creates a new builder of coordinate reference systems. -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
Updates a mapping from GeoTIFF numerical identifiers to parameter names by adding parameter aliases.org.opengis.referencing.crs.CoordinateReferenceSystem
build
(GeoKeysLoader source) Decodes all the given GeoTIFF keys, then creates a coordinate reference system.private org.opengis.referencing.operation.Conversion
createConversion
(String name, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit, javax.measure.Unit<javax.measure.quantity.Length> linearUnit) Creates a defining conversion from an EPSG code or from user-defined parameters.private org.opengis.referencing.datum.Ellipsoid
createEllipsoid
(String[] names, javax.measure.Unit<javax.measure.quantity.Length> unit) Creates an ellipsoid from an EPSG code or from user-defined parameters.private org.opengis.referencing.crs.GeocentricCRS
Creates a geocentric CRS from user-defined parameters.private org.opengis.referencing.datum.GeodeticDatum
createGeodeticDatum
(String[] names, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit, javax.measure.Unit<javax.measure.quantity.Length> linearUnit) Creates a geodetic datum from an EPSG code or from user-defined parameters.private org.opengis.referencing.crs.GeographicCRS
Creates the main CRS in the case where that CRS is geographic.private org.opengis.referencing.crs.GeographicCRS
createGeographicCRS
(boolean rightHanded, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit) Creates a geographic CRS from an EPSG code or from user-defined parameters.private org.opengis.referencing.datum.PrimeMeridian
createPrimeMeridian
(String[] names, javax.measure.Unit<javax.measure.quantity.Angle> unit) Creates a prime meridian from an EPSG code or from user-defined parameters.private org.opengis.referencing.crs.ProjectedCRS
Creates a projected CRS from an EPSG code or from user-defined parameters.private <Q extends javax.measure.Quantity<Q>>
javax.measure.Unit<Q> createUnit
(short codeKey, short scaleKey, Class<Q> quantity, javax.measure.Unit<Q> defaultValue) Creates units of measurement for projected or geographic coordinate reference systems.private org.opengis.referencing.crs.VerticalCRS
Creates an optional vertical CRS, or returnsnull
if no vertical CRS definition is found.private org.opengis.referencing.datum.VerticalDatum
Creates a vertical datum.private double
getAsDouble
(short key) Removes and returns aGeoKeys
value as a floating point number, orNaN
if none.private int
getAsInteger
(short key) Removes and returns aGeoKeys
value as an integer.private String
getAsString
(short key) Removes and returns aGeoKeys
value as a character string, ornull
if none.private double
getMandatoryDouble
(short key) Removes and returns aGeoKeys
value as a floating point number, or throws an exception if none.private String
getMandatoryString
(short key) Removes and returns aGeoKeys
value as a character string, or throws an exception if none.private static String
getOrDefault
(String[] names, int component) Returns the name at the given index if non-null.private Object
getSingleton
(short key) Removes and returns the value for the given key as a singleton (not an array).private void
invalidValue
(short key, Object value) Reports a warning about an invalid value for the given key.(package private) final String
missingValue
(short key) Reports a warning about missing value for the given key.properties
(Object name) Returns a map with the given name associated to "name".private Short[]
Returns all remaining keys, sorted in increasing order.private org.opengis.referencing.cs.EllipsoidalCS
replaceAngularUnit
(org.opengis.referencing.cs.EllipsoidalCS cs, javax.measure.Unit<javax.measure.quantity.Angle> unit) Returns a coordinate system (CS) with the same axis directions than the given CS but potentially different units.private org.opengis.referencing.cs.CartesianCS
replaceLinearUnit
(org.opengis.referencing.cs.CartesianCS cs, javax.measure.Unit<javax.measure.quantity.Length> unit) Returns a coordinate system (CS) with the same axis directions than the given CS but potentially different units.(package private) static String[]
Splits theGeoKeys.GeogCitation
value into its prime meridian, ellipsoid, datum and CRS name components.final String
toString()
Returns a string representation of the keys and associated values in thisCRSBuilder
.private void
verify
(org.opengis.referencing.crs.GeocentricCRS crs) Verifies if the user-defined CRS created from GeoTIFF values matches the given CRS created from the EPSG geodetic dataset.private void
verify
(org.opengis.referencing.crs.GeographicCRS crs, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit) Verifies if the user-defined CRS created from GeoTIFF values matches the given CRS created from the EPSG geodetic dataset.private void
verify
(org.opengis.referencing.crs.ProjectedCRS crs) Verifies if the user-defined CRS created from GeoTIFF values matches the given CRS created from the EPSG geodetic dataset.private void
verify
(org.opengis.referencing.datum.Ellipsoid ellipsoid, javax.measure.Unit<javax.measure.quantity.Length> unit) Verifies if the user-defined ellipsoid created from GeoTIFF values matches the given ellipsoid created from the EPSG geodetic dataset.private void
verify
(org.opengis.referencing.datum.GeodeticDatum datum, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit, javax.measure.Unit<javax.measure.quantity.Length> linearUnit) Verifies if the user-defined datum created from GeoTIFF values matches the given datum created from the EPSG geodetic dataset.private void
verify
(org.opengis.referencing.datum.PrimeMeridian pm, javax.measure.Unit<javax.measure.quantity.Angle> unit) Verifies if the user-defined prime meridian created from GeoTIFF values matches the given prime meridian created from the EPSG geodetic dataset.private void
verify
(org.opengis.referencing.IdentifiedObject epsg, double expected, short key, javax.measure.Unit<?> unit) Verifies that a value found in the GeoTIFF file is approximately equal to the expected value.private void
verify
(org.opengis.referencing.operation.Conversion projection, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit, javax.measure.Unit<javax.measure.quantity.Length> linearUnit) Verifies if the user-defined conversion created from GeoTIFF values matches the given conversion created from the EPSG geodetic dataset.private void
verifyIdentifier
(org.opengis.referencing.IdentifiedObject parent, org.opengis.referencing.IdentifiedObject epsg, short key) Verifies that the EPSG code found in the GeoTIFF file is equal to the expected value.(package private) final void
Reports a warning with a message built from the given resource keys and arguments.Methods inherited from class org.apache.sis.internal.referencing.ReferencingFactoryContainer
getCoordinateOperationAuthorityFactory, getCoordinateOperationFactory, getCRSAuthorityFactory, getCRSFactory, getCSAuthorityFactory, getCSFactory, getDatumAuthorityFactory, getDatumFactory, getFactory, getMathTransformFactory, getStandardProjectedCS, setFactory
-
Field Details
-
PRIMEM
static final int PRIMEMIndex where to store the name of the geodetic CRS, the datum, the ellipsoid and the prime meridian. The GeoTIFF specification has only one key,GeoKeys.GeogCitation
, for the geographic CRS and its components. But some GeoTIFF files encode the names of all components in the value associated to that key, as in the following example: In such case, we will split the name into the components names to be stored in an array at indices given byGCRS
,DATUM
,ELLIPSOID
andPRIMEM
.- See Also:
-
ELLIPSOID
static final int ELLIPSOIDIndex where to store the name of the geodetic CRS, the datum, the ellipsoid and the prime meridian. The GeoTIFF specification has only one key,GeoKeys.GeogCitation
, for the geographic CRS and its components. But some GeoTIFF files encode the names of all components in the value associated to that key, as in the following example: In such case, we will split the name into the components names to be stored in an array at indices given byGCRS
,DATUM
,ELLIPSOID
andPRIMEM
.- See Also:
-
DATUM
static final int DATUMIndex where to store the name of the geodetic CRS, the datum, the ellipsoid and the prime meridian. The GeoTIFF specification has only one key,GeoKeys.GeogCitation
, for the geographic CRS and its components. But some GeoTIFF files encode the names of all components in the value associated to that key, as in the following example: In such case, we will split the name into the components names to be stored in an array at indices given byGCRS
,DATUM
,ELLIPSOID
andPRIMEM
.- See Also:
-
GCRS
static final int GCRSIndex where to store the name of the geodetic CRS, the datum, the ellipsoid and the prime meridian. The GeoTIFF specification has only one key,GeoKeys.GeogCitation
, for the geographic CRS and its components. But some GeoTIFF files encode the names of all components in the value associated to that key, as in the following example: In such case, we will split the name into the components names to be stored in an array at indices given byGCRS
,DATUM
,ELLIPSOID
andPRIMEM
.- See Also:
-
NAME_KEYS
Keys that may be used in the value associated toGeoKeys.GeogCitation
. For each element in this array at indexi
, thei/2
value is equal to theDATUM
,ELLIPSOID
orPRIMEM
constant for the corresponding type. -
MIN_KEY_LENGTH
private static final int MIN_KEY_LENGTHMinimal length that a key in a name must have before we compare them to theNAME_KEYS
. For example, a value of 5 means thatsplitName(String)
will accept"Ellip"
,"Ellips"
,"Ellipso"
and"Ellipsoi"
as if they were"Ellipsoid"
. This length shall not be greater than the length of the shortest string inNAME_KEYS
.- See Also:
-
reader
The reader for which we will create coordinate reference systems. This is used for reporting warnings. -
majorRevision
private short majorRevisionVersion of the set of keys declared in theGeoKeyDirectory
header. -
minorRevision
private short minorRevisionVersion of the set of keys declared in theGeoKeyDirectory
header. -
geoKeys
All values found in theGeoKeyDirectory
after the header. Each value shall be used at most once. This allow us to remove value after usage, so we can easily detect at the end of the parsing process which GeoTIFF keys were unrecognized or ignored. -
missingGeoKeys
Missing GeoKeys, used for avoiding to report the same warning twice.- See Also:
-
lastName
private org.opengis.metadata.Identifier lastNameName of the last object created. This is used byproperties(Object)
for reusing existing instance if possible. This is useful in GeoTIFF files since the same name is used for different geodetic components, for example the datum and the ellipsoid. -
description
Suggested value for a general description of the transformation form grid coordinates to "real world" coordinates. This is computed byinvalid reference
#build(Vector, Vector, String)
-
cellGeometry
public org.opengis.metadata.spatial.CellGeometry cellGeometryPOINT
ifGeoKeys.RasterType
isGeoCodes.RasterPixelIsPoint
,AREA
if it isGeoCodes.RasterPixelIsArea
, or null if unspecified. This is computed byinvalid reference
#build(Vector, Vector, String)
-
alreadyReported
boolean alreadyReportedtrue
when an exception has been thrown but thisCRSBuilder
already reported a warning, so there is no need for the caller to report a warning again.CRSBuilder
sometimes reports warnings itself when it can provide a better warning message than what the caller can do. -
PARAMETER_ALIASES
private static final short[][] PARAMETER_ALIASESMap projection parameters to be considered as aliases. This table is used for reading GeoTIFF files that are not really well-formed, but for which we can reasonably guess what was the producer intent and which parameters were confused. Seealiases(Map)
for more explanation.
-
-
Constructor Details
-
CRSBuilder
CRSBuilder(Reader reader) Creates a new builder of coordinate reference systems.- Parameters:
reader
- where to report warnings if any.
-
-
Method Details
-
warning
Reports a warning with a message built from the given resource keys and arguments.- Parameters:
key
- one of theResources.Keys
constants.args
- arguments for the log message.- See Also:
-
properties
Returns a map with the given name associated to "name". The given name shall be either an instance ofString
orIdentifier
. This is an helper method for creating geodetic objects withReferencingFactoryContainer.getCRSFactory()
. -
getSingleton
Removes and returns the value for the given key as a singleton (not an array). If the value was an array, a warning is reported and the first element is returned.The given element is removed from the map so that each element is used only once (for example it would be redundant to have the
verify(…)
methods to compare the same values than the ones we used at geodetic object construction time). It also allow us to check whichGeoKeys
were ignored by looking at what is remaining in the map after CRS creation.- Parameters:
key
- the GeoTIFF key for which to get a value.- Returns:
- the singleton value for the given key, or
null
if none.
-
getAsString
Removes and returns aGeoKeys
value as a character string, ornull
if none. Value for the given key should be a sequence of characters. If it is one or more numbers instead, then this method formats those numbers in a comma-separated list. Such sequence of numbers would be unusual, but we do see strange GeoTIFF files in practice.See
getSingleton(short)
for a discussion about why the value is removed from the map.- Parameters:
key
- the GeoTIFF key for which to get a value.- Returns:
- a string representation of the value for the given key, or
null
if the key was not found.
-
getAsInteger
private int getAsInteger(short key) Removes and returns aGeoKeys
value as an integer. This is used for fetching enumeration values. The value returned by this method is typically one of theGeoCodes
values.See
getSingleton(short)
for a discussion about why the value is removed from the map.- Parameters:
key
- the GeoTIFF key for which to get a value.- Returns:
- the integer value for the given key, or
GeoCodes.undefined
if the key was not found. - Throws:
NumberFormatException
- if the value was stored as a string and cannot be parsed.
-
getAsDouble
private double getAsDouble(short key) Removes and returns aGeoKeys
value as a floating point number, orNaN
if none. SeegetSingleton(short)
for a discussion about why the value is removed from the map.- Parameters:
key
- the GeoTIFF key for which to get a value.- Returns:
- the floating point value for the given key, or
Double.NaN
if the key was not found. - Throws:
NumberFormatException
- if the value was stored as a string and cannot be parsed.
-
getMandatoryString
Removes and returns aGeoKeys
value as a character string, or throws an exception if none. A warning is reported before to throw the exception. There is no attempt to provide a good message in the exception since is should be caught byImageFileDirectory
.- Parameters:
key
- the GeoTIFF key for which to get a value.- Returns:
- a string representation of the value for the given key.
- Throws:
NoSuchElementException
- if no value has been found.
-
getMandatoryDouble
private double getMandatoryDouble(short key) Removes and returns aGeoKeys
value as a floating point number, or throws an exception if none. A warning is reported before to throw the exception. There is no attempt to provide a good message in the exception since is should be caught byImageFileDirectory
.- Parameters:
key
- the GeoTIFF key for which to get a value.- Returns:
- the floating point value for the given key.
- Throws:
NoSuchElementException
- if no value has been found.NumberFormatException
- if the value was stored as a string and cannot be parsed.
-
missingValue
Reports a warning about missing value for the given key. The key name is opportunistically returned for building theNoSuchElementException
message, but it is not the main purpose of this method.- See Also:
-
invalidValue
Reports a warning about an invalid value for the given key. -
verify
private void verify(org.opengis.referencing.IdentifiedObject epsg, double expected, short key, javax.measure.Unit<?> unit) Verifies that a value found in the GeoTIFF file is approximately equal to the expected value. This method is invoked when a CRS component is defined both explicitly and by EPSG code, in which case we expect the given value to be equal to the value fetched from the EPSG database. If the values do not match, a warning is reported and the caller should use the EPSG value.- Parameters:
epsg
- the EPSG object, to be used for formatting the warning in case of mismatched values.expected
- the expected value for an object identified by theepsg
code.key
- the GeoTIFF key of the user-defined value to compare with the expected one.unit
- the unit of measurement forexpected
andactual
, ornull
if none.
-
verifyIdentifier
private void verifyIdentifier(org.opengis.referencing.IdentifiedObject parent, org.opengis.referencing.IdentifiedObject epsg, short key) Verifies that the EPSG code found in the GeoTIFF file is equal to the expected value. This method is invoked when a CRS component is defined by an EPSG code, in which case there is no need to specify the EPSG codes of the components, but the file still supply those EPSG codes. If the values do not match, a warning is reported.- Parameters:
parent
- the parent which contains theepsg
objectepsg
- the object created from the EPSG geodetic dataset.key
- the GeoTIFF key for the EPSG code of the givenepsg
object.
-
build
public org.opengis.referencing.crs.CoordinateReferenceSystem build(GeoKeysLoader source) throws org.opengis.util.FactoryException Decodes all the given GeoTIFF keys, then creates a coordinate reference system. An overview of the key directory structure is given in class javadoc. Thedescription
andcellGeometry
fields are set as a side-effect. A warning is emitted if any GeoTIFF tags were ignored.- Parameters:
source
- thekeyDirectory
,numericParameters
andasciiParameters
tags.- Returns:
- the coordinate reference system created from the given GeoTIFF keys, or
null
if undefined. - Throws:
NoSuchElementException
- if a mandatory value is missing.NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.ClassCastException
- if an object defined by an EPSG code is not of the expected type.org.opengis.util.FactoryException
- if an error occurred during objects creation with the factories.
-
remainingKeys
Returns all remaining keys, sorted in increasing order. -
replaceLinearUnit
private org.opengis.referencing.cs.CartesianCS replaceLinearUnit(org.opengis.referencing.cs.CartesianCS cs, javax.measure.Unit<javax.measure.quantity.Length> unit) throws org.opengis.util.FactoryException Returns a coordinate system (CS) with the same axis directions than the given CS but potentially different units. If a coordinate system exists in the EPSG database with the requested characteristics, that CS will be returned in order to have a richer set of metadata (name, minimal and maximal values, etc). Otherwise an CS with an arbitrary name will be returned.- Throws:
org.opengis.util.FactoryException
- See Also:
-
replaceAngularUnit
private org.opengis.referencing.cs.EllipsoidalCS replaceAngularUnit(org.opengis.referencing.cs.EllipsoidalCS cs, javax.measure.Unit<javax.measure.quantity.Angle> unit) throws org.opengis.util.FactoryException Returns a coordinate system (CS) with the same axis directions than the given CS but potentially different units. If a coordinate system exists in the EPSG database with the requested characteristics, that CS will be returned in order to have a richer set of metadata (name, minimal and maximal values, etc). Otherwise an CS with an arbitrary name will be returned.- Throws:
org.opengis.util.FactoryException
- See Also:
-
createUnit
private <Q extends javax.measure.Quantity<Q>> javax.measure.Unit<Q> createUnit(short codeKey, short scaleKey, Class<Q> quantity, javax.measure.Unit<Q> defaultValue) throws org.opengis.util.FactoryException Creates units of measurement for projected or geographic coordinate reference systems. The units may either be specified as a standard EPSG recognized unit, or may be user defined. If the first case (EPSG code), thekeyUser
is ignored. In the second case (user-defined), the unit of measurement is defined by a conversion factor from metre or radian base unit.- Parameters:
codeKey
- theGeoKeys
for a unit of measurement defined by an EPSG code.scaleKey
- theGeoKeys
for a unit of measurement defined by a scale applied on a base unit.quantity
-Length
for a linear unit, orAngle
for an angular unit.defaultValue
- the unit of measurement to return if no value is found in the GeoTIFF file.- Returns:
- the unit of measurement associated to the given
GeoKeys
, or the default value. - Throws:
NoSuchElementException
- ifkeyEPSG
value isGeoCodes.userDefined
and no value is associated tokeyUser
.NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.ClassCastException
- if the unit of measurement identified by the EPSG code is not of the expected quantity.org.opengis.util.FactoryException
-
createPrimeMeridian
private org.opengis.referencing.datum.PrimeMeridian createPrimeMeridian(String[] names, javax.measure.Unit<javax.measure.quantity.Angle> unit) throws org.opengis.util.FactoryException Creates a prime meridian from an EPSG code or from user-defined parameters. The GeoTIFF values used by this method are:- A code given by
GeoKeys.PrimeMeridian
. - If above code is
GeoCodes.userDefined
, then:- a prime meridian value given by
GeoKeys.PrimeMeridianLong
.
- a prime meridian value given by
- Parameters:
names
- the component names to use if the prime meridian is user-defined.unit
- the angular unit of the longitude value relative to Greenwich.- Returns:
- a prime meridian created from the given
Unit
and the above-cited GeoTIFF keys. - Throws:
NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.org.opengis.util.FactoryException
- if an error occurred during objects creation with the factories.
- A code given by
-
verify
private void verify(org.opengis.referencing.datum.PrimeMeridian pm, javax.measure.Unit<javax.measure.quantity.Angle> unit) Verifies if the user-defined prime meridian created from GeoTIFF values matches the given prime meridian created from the EPSG geodetic dataset. This method does not verify the EPSG code.- Parameters:
pm
- the prime meridian created from the EPSG geodetic dataset.unit
- the unit of measurement declared in the GeoTIFF file.
-
createEllipsoid
private org.opengis.referencing.datum.Ellipsoid createEllipsoid(String[] names, javax.measure.Unit<javax.measure.quantity.Length> unit) throws org.opengis.util.FactoryException Creates an ellipsoid from an EPSG code or from user-defined parameters. The GeoTIFF values used by this method are:- A code given by
GeoKeys.Ellipsoid
tag. - If above code is
GeoCodes.userDefined
, then:- a name given by
GeoKeys.GeogCitation
, - a semi major axis value given by
GeoKeys.SemiMajorAxis
, - one of:
- an inverse flattening factor given by
GeoKeys.InvFlattening
, - or a semi major axis value given by
GeoKeys.SemiMinorAxis
.
- an inverse flattening factor given by
- a name given by
- Parameters:
names
- the component names to use if the ellipsoid is user-defined.unit
- the linear unit of the semi-axis lengths.- Returns:
- an ellipsoid created from the given
Unit
and the above-cited GeoTIFF keys. - Throws:
NoSuchElementException
- if a mandatory value is missing.NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.org.opengis.util.FactoryException
- if an error occurred during objects creation with the factories.
- A code given by
-
verify
private void verify(org.opengis.referencing.datum.Ellipsoid ellipsoid, javax.measure.Unit<javax.measure.quantity.Length> unit) Verifies if the user-defined ellipsoid created from GeoTIFF values matches the given ellipsoid created from the EPSG geodetic dataset. This method does not verify the EPSG code.- Parameters:
ellipsoid
- the ellipsoid created from the EPSG geodetic dataset.unit
- the unit of measurement declared in the GeoTIFF file.
-
createGeodeticDatum
private org.opengis.referencing.datum.GeodeticDatum createGeodeticDatum(String[] names, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit, javax.measure.Unit<javax.measure.quantity.Length> linearUnit) throws org.opengis.util.FactoryException Creates a geodetic datum from an EPSG code or from user-defined parameters. The GeoTIFF values used by this method are:- A code given by
GeoKeys.GeodeticDatum
. - If above code is
GeoCodes.userDefined
, then:- a name given by
GeoKeys.GeogCitation
, - all values required by
createPrimeMeridian(String[], Unit)
(optional), - all values required by
createEllipsoid(String[], Unit)
.
- a name given by
- Parameters:
names
- the component names to use if the geodetic datum is user-defined.angularUnit
- the angular unit of the longitude value relative to Greenwich.linearUnit
- the linear unit of the ellipsoid semi-axis lengths.- Throws:
NoSuchElementException
- if a mandatory value is missing.NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.ClassCastException
- if an object defined by an EPSG code is not of the expected type.org.opengis.util.FactoryException
- if an error occurred during objects creation with the factories.- See Also:
- A code given by
-
verify
private void verify(org.opengis.referencing.datum.GeodeticDatum datum, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit, javax.measure.Unit<javax.measure.quantity.Length> linearUnit) Verifies if the user-defined datum created from GeoTIFF values matches the given datum created from the EPSG geodetic dataset. This method does not verify the EPSG code of the given datum.- Parameters:
datum
- the datum created from the EPSG geodetic dataset.angularUnit
- unit of measurement declared in the GeoTIFF file.linearUnit
- unit of measurement declared in the GeoTIFF file.
-
splitName
Splits theGeoKeys.GeogCitation
value into its prime meridian, ellipsoid, datum and CRS name components. This method is intended to parse geographic CRS names written like below: The keywords of both Well Known Text (WKT) version 1 and 2 are accepted as keys for the datum, ellipsoid and prime meridian names. All other keys are presumed to be for the geographic CRS name. If the given string does not contain the pipe ('|'
) separator, then the whole string is presumed to be the geographic CRS name.This method returns an array where component names are stored at index
PRIMEM
,ELLIPSOID
,DATUM
andGCRS
. Any array element can be null if no name were found for that component. -
getOrDefault
Returns the name at the given index if non-null. If that name is null, search for a name in a sister element (e.g. the datum name or the geographic CRS name). If none is found, returnsnull
. -
createGeographicCRS
private org.opengis.referencing.crs.GeographicCRS createGeographicCRS() throws org.opengis.util.FactoryExceptionCreates the main CRS in the case where that CRS is geographic.- Throws:
org.opengis.util.FactoryException
-
createGeographicCRS
private org.opengis.referencing.crs.GeographicCRS createGeographicCRS(boolean rightHanded, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit) throws org.opengis.util.FactoryException Creates a geographic CRS from an EPSG code or from user-defined parameters. The GeoTIFF values used by this method are:- A code given by
GeoKeys.GeographicType
. - If above code is
GeoCodes.userDefined
, then:- a prime meridian value given by
GeoKeys.PrimeMeridianLong
, - a CRS name given by
GeoKeys.GeogCitation
, - a datum definition.
- a prime meridian value given by
- A unit code given by
GeoKeys.AngularUnits
(optional). - A unit scale factor given by
GeoKeys.AngularUnitSize
(optional).
- Parameters:
rightHanded
- whether to force longitude before latitude axis.angularUnit
- the angular unit of the latitude and longitude values.- Throws:
NoSuchElementException
- if a mandatory value is missing.NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.ClassCastException
- if an object defined by an EPSG code is not of the expected type.org.opengis.util.FactoryException
- if an error occurred during objects creation with the factories.- See Also:
- A code given by
-
verify
private void verify(org.opengis.referencing.crs.GeographicCRS crs, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit) throws org.opengis.util.FactoryException Verifies if the user-defined CRS created from GeoTIFF values matches the given CRS created from the EPSG geodetic dataset. This method does not verify the EPSG code of the given CRS.- Parameters:
crs
- the CRS created from the EPSG geodetic dataset.angularUnit
- the angular unit of the latitude and longitude values.- Throws:
org.opengis.util.FactoryException
-
createGeocentricCRS
private org.opengis.referencing.crs.GeocentricCRS createGeocentricCRS() throws org.opengis.util.FactoryExceptionCreates a geocentric CRS from user-defined parameters. The GeoTIFF values used by this method are the same than the ones used bycreateGeographicCRS(…)
.- Throws:
NoSuchElementException
- if a mandatory value is missing.NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.ClassCastException
- if an object defined by an EPSG code is not of the expected type.org.opengis.util.FactoryException
- if an error occurred during objects creation with the factories.- See Also:
-
verify
private void verify(org.opengis.referencing.crs.GeocentricCRS crs) throws org.opengis.util.FactoryException Verifies if the user-defined CRS created from GeoTIFF values matches the given CRS created from the EPSG geodetic dataset. This method does not verify the EPSG code of the given CRS.- Parameters:
crs
- the CRS created from the EPSG geodetic dataset.- Throws:
org.opengis.util.FactoryException
-
aliases
Updates a mapping from GeoTIFF numerical identifiers to parameter names by adding parameter aliases. This method adds to the given map some GeoTIFF keys to be considered synonymous to an existing key. Those "synonymous" parameters are strictly speaking not for the map projection that we are parsing, but it is common to see GeoTIFF files with "wrong" projection parameter codes. For example:- The
"CT_LambertConfConic_1SP"
projection uses a"NatOriginLong"
parameter. - The
"CT_LambertConfConic_2SP"
projection uses a"FalseOriginLong"
parameter.
"NatOriginLong"
parameter used for the"CT_LambertConfConic_2SP"
projection. Semantically those two parameters are for two different things but mathematically they are used in the same way. Those "synonymous" will be invisible to the user; the map projection that (s)he will get uses the names defined in the descriptor (not in the GeoTIFF file). - The
-
createProjectedCRS
private org.opengis.referencing.crs.ProjectedCRS createProjectedCRS() throws org.opengis.util.FactoryExceptionCreates a projected CRS from an EPSG code or from user-defined parameters. Some GeoTIFF values used by this method are:- A code given by
GeoKeys.ProjectedCSType
. - If above code is
GeoCodes.userDefined
, then:- a name given by
GeoKeys.PCSCitation
, - a
CoordinateOperation
given byGeoKeys.Projection
, - an
OperationMethod
given byGeoKeys.CoordTrans
.
- a name given by
- A unit code given by
GeoKeys.LinearUnits
(optional). - A unit scale factor given by
GeoKeys.LinearUnitSize
(optional).
- Throws:
NoSuchElementException
- if a mandatory value is missing.NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.ClassCastException
- if an object defined by an EPSG code is not of the expected type.org.opengis.util.FactoryException
- if an error occurred during objects creation with the factories.- See Also:
- A code given by
-
verify
private void verify(org.opengis.referencing.crs.ProjectedCRS crs) throws org.opengis.util.FactoryException Verifies if the user-defined CRS created from GeoTIFF values matches the given CRS created from the EPSG geodetic dataset. This method does not verify the EPSG code of the given CRS.- Parameters:
crs
- the CRS created from the EPSG geodetic dataset.- Throws:
org.opengis.util.FactoryException
-
createConversion
private org.opengis.referencing.operation.Conversion createConversion(String name, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit, javax.measure.Unit<javax.measure.quantity.Length> linearUnit) throws org.opengis.util.FactoryException Creates a defining conversion from an EPSG code or from user-defined parameters.- Parameters:
angularUnit
- the angular unit of the latitude and longitude values.linearUnit
- the linear unit of easting and northing values.- Throws:
NoSuchElementException
- if a mandatory value is missing.NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.org.opengis.parameter.ParameterNotFoundException
- if the GeoTIFF file defines an unexpected map projection parameter.ClassCastException
- if an object defined by an EPSG code is not of the expected type.org.opengis.util.FactoryException
- if an error occurred during objects creation with the factories.
-
verify
private void verify(org.opengis.referencing.operation.Conversion projection, javax.measure.Unit<javax.measure.quantity.Angle> angularUnit, javax.measure.Unit<javax.measure.quantity.Length> linearUnit) throws org.opengis.util.FactoryException Verifies if the user-defined conversion created from GeoTIFF values matches the given conversion created from the EPSG geodetic dataset. This method does not verify the EPSG code of the given conversion.- Parameters:
projection
- the conversion created from the EPSG geodetic dataset.- Throws:
org.opengis.util.FactoryException
-
createVerticalDatum
private org.opengis.referencing.datum.VerticalDatum createVerticalDatum() throws org.opengis.util.FactoryExceptionCreates a vertical datum.- Throws:
org.opengis.util.FactoryException
-
createVerticalCRS
private org.opengis.referencing.crs.VerticalCRS createVerticalCRS() throws org.opengis.util.FactoryExceptionCreates an optional vertical CRS, or returnsnull
if no vertical CRS definition is found. This method is different from the othercreateFooCRS()
methods in that the vertical CRS may be defined in addition of another CRS. Some GeoTIFF values used by this method are:- A code given by
GeoKeys.VerticalCSType
. - If above code is
GeoCodes.userDefined
, then:- a name given by
GeoKeys.VerticalCitation
, - a
VerticalDatum
given byGeoKeys.VerticalDatum
.
- a name given by
- A unit code given by
GeoKeys.VerticalUnits
(optional).
- Throws:
NoSuchElementException
- if a mandatory value is missing.NumberFormatException
- if a numeric value was stored as a string and cannot be parsed.ClassCastException
- if an object defined by an EPSG code is not of the expected type.org.opengis.util.FactoryException
- if an error occurred during objects creation with the factories.
- A code given by
-
toString
Returns a string representation of the keys and associated values in thisCRSBuilder
.
-