Class PROJFormatter
PROJFormattable
objects as PROJ strings. Supported PROJ formattable are normally
IdentifiedObject
as well.
Call toPROJ(PROJFormattable) to get the associated proj String.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends a PROJ-compatible key-value pair to the internal buffer, where the value is a double.void
Appends a PROJ-compatible key-value pair to the internal buffer, where the value is a string.void
append
(Unit<?> unit) Appends the PROJ string representation of the specified unit to the internal buffer.void
append
(GeneralParameterValue parameter) Appends a PROJ string representation of the given parameter to the internal buffer.void
append
(PROJFormattable formattable) void
clear()
Clears the internal state of the formatter to allow for reuse.Retrieves the identifier for a givenIdentifiedObject
.getName
(IdentifiedObject info) Returns the preferred name for the specified object.boolean
boolean
boolean
boolean
toPROJ
(PROJFormattable formattable) That's the main method to get the PROJ String out of aPROJFormattable
.
-
Field Details
-
NO_KEYWORD
- See Also:
-
-
Constructor Details
-
PROJFormatter
public PROJFormatter()Creates a new instance of the PROJFormatter.
-
-
Method Details
-
isProjectedCRS
public boolean isProjectedCRS() -
isDatumProvided
public boolean isDatumProvided() -
isEllipsoidProvided
public boolean isEllipsoidProvided() -
isPrimeMeridianProvided
public boolean isPrimeMeridianProvided() -
append
-
append
Appends a PROJ string representation of the given parameter to the internal buffer.This method is part of a PROJFormatter that converts
GeneralParameterValue
objects (such as parameters for projection operations) into PROJ format strings. It handles both individual parameters and groups of parameters.If the parameter is a
ParameterValueGroup
, the method recursively processes each containedGeneralParameterValue
. For eachParameterValue
, it appends a formatted key-value pair to the buffer, with the key based on the parameter descriptor's name and the value based on the parameter's value, converted to a double if possible.- Parameters:
parameter
- theGeneralParameterValue
to format and append. This may be an individualParameterValue
or a group of parameters in aParameterValueGroup
.- Throws:
ClassCastException
- ifparameter
is not an instance ofParameterValueGroup
orParameterValue
, as only these types are supported.
-
append
public void append(Unit<?> unit) Appends the PROJ string representation of the specified unit to the internal buffer.This method adds the unit symbol to the buffer in a format compatible with PROJ, typically as a `+units=` key-value pair. If the unit's symbol is not available, it uses the unit's string representation instead.
- Parameters:
unit
- theUnit
to format and append. Ifunit
isnull
, nothing is appended to the buffer.Example:
+units=m
-
append
Appends a PROJ-compatible key-value pair to the internal buffer, where the value is a string.This method formats the key and value in the style expected by PROJ. The result format is `+key=value`.
- Parameters:
key
- the key to be appended, representing the parameter name.value
- the value to be appended, represented as a string.Example:
+proj=longlat
-
append
Appends a PROJ-compatible key-value pair to the internal buffer, where the value is a double.This method formats the key and numeric value in a style compatible with PROJ. The result format is `+key=value`, with the value formatted to the appropriate precision using
format(double)
.- Parameters:
key
- the key to be appended, representing the parameter name.number
- the value to be appended, represented as a double.Example:
+rf=299.1528128
-
getName
Returns the preferred name for the specified object. If the specified object contains a name from the preferred authority then this name is returned. Otherwise, it will be added to not parseable list- Parameters:
info
- The object to looks for a preferred name.- Returns:
- The preferred name.
-
getIdentifier
Retrieves the identifier for a givenIdentifiedObject
.- Parameters:
info
- theIdentifiedObject
from which to retrieve an identifier. May benull
, in which case this method returnsnull
.- Returns:
- the
Identifier
with the authorityCitations.PROJ
if found, or the first identifier in the collection if no match withCitations.PROJ
is found. Returnsnull
ifinfo
isnull
or has no identifiers.
-
clear
public void clear()Clears the internal state of the formatter to allow for reuse.This method resets the internal buffer and all tracking flags, preparing the formatter for a new PROJ string generation. It can be used to reuse the same formatter instance for multiple formatting operations.
This is useful when the formatter instance needs to be reused for different projections or coordinate reference systems without creating a new instance each time.
-
toPROJ
That's the main method to get the PROJ String out of aPROJFormattable
.- Parameters:
formattable
- the identified object to be formatted- Returns:
-