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 TypeMethodDescriptionvoidAppends a PROJ-compatible key-value pair to the internal buffer, where the value is a double.voidAppends a PROJ-compatible key-value pair to the internal buffer, where the value is a string.voidappend(Unit<?> unit) Appends the PROJ string representation of the specified unit to the internal buffer.voidappend(GeneralParameterValue parameter) Appends a PROJ string representation of the given parameter to the internal buffer.voidappend(PROJFormattable formattable) voidclear()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.booleanbooleanbooleanbooleantoPROJ(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
GeneralParameterValueobjects (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- theGeneralParameterValueto format and append. This may be an individualParameterValueor a group of parameters in aParameterValueGroup.- Throws:
ClassCastException- ifparameteris not an instance ofParameterValueGrouporParameterValue, 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- theUnitto format and append. Ifunitisnull, 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- theIdentifiedObjectfrom which to retrieve an identifier. May benull, in which case this method returnsnull.- Returns:
- the
Identifierwith the authorityCitations.PROJif found, or the first identifier in the collection if no match withCitations.PROJis found. Returnsnullifinfoisnullor 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:
-