Class PROJFormatter


  • public class PROJFormatter
    extends Object
    A Formatter that formats PROJFormattable objects as PROJ strings. Supported PROJ formattable are normally IdentifiedObject as well.

    Call toPROJ(PROJFormattable) to get the associated proj String.

    • Constructor Detail

      • PROJFormatter

        public PROJFormatter()
        Creates a new instance of the PROJFormatter.
    • Method Detail

      • isProjectedCRS

        public boolean isProjectedCRS()
      • isDatumProvided

        public boolean isDatumProvided()
      • isEllipsoidProvided

        public boolean isEllipsoidProvided()
      • isPrimeMeridianProvided

        public boolean isPrimeMeridianProvided()
      • 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 - the Unit to format and append. If unit is null, nothing is appended to the buffer.

        Example:

         +units=m
         
      • append

        public void append​(String key,
                           String value)
        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

        public void append​(String key,
                           double number)
        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

        public String getName​(IdentifiedObject info)
        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

        public Identifier getIdentifier​(IdentifiedObject info)
        Retrieves the identifier for a given IdentifiedObject.
        Parameters:
        info - the IdentifiedObject from which to retrieve an identifier. May be null, in which case this method returns null.
        Returns:
        the Identifier with the authority Citations.PROJ if found, or the first identifier in the collection if no match with Citations.PROJ is found. Returns null if info is null 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

        public String toPROJ​(PROJFormattable formattable)
        That's the main method to get the PROJ String out of a PROJFormattable.
        Parameters:
        formattable - the identified object to be formatted
        Returns: