Package org.apache.sis.coverage.grid
Class GridGeometry.Formatter
java.lang.Object
org.apache.sis.coverage.grid.GridGeometry.Formatter
- Enclosing class:
- GridGeometry
Helper class for formatting a
GridGeometry instance.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate final StringBuilderTemporary buffer for formatting node values.private final org.opengis.referencing.crs.CoordinateReferenceSystemThe coordinate reference system, ornullif none.private final org.opengis.referencing.cs.CoordinateSystemThe coordinate system, ornullif none.private final LocaleThe locale for the texts, numbers (except grid extent) and dates.private final TreeTable.NodeWhere to write theGridGeometrystring representation.private TreeTable.NodeThe section under the root where to write elements.private final VocabularyLocalized words. -
Constructor Summary
ConstructorsConstructorDescriptionFormatter(Locale locale, Vocabulary vocabulary, int bitmask, TreeTable.Node out) Creates a new formatter for the given combination ofGridGeometry.EXTENT,GridGeometry.ENVELOPE,GridGeometry.CRS,GridGeometry.GRID_TO_CRSandGridGeometry.RESOLUTION. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidappendResolution(Appendable out, NumberFormat nf, double res, int dim) Appends a single value on the resolution line, together with its unit of measurement.(package private) final voidformat()Formats a string representation of the enclosingGridGeometryinstance in the buffer specified at construction time.private booleansection(int property, short title, boolean mandatory, boolean cellCenter) Starts a new section for the given property.private voidAppends a node with currentbuffercontent as a single line, then clears the buffer.private voidwriteNode(CharSequence line) Appends a single line as a node in the current section.private voidAppends nodes with currentbuffercontent as multi-lines text, then clears the buffer.
-
Field Details
-
bitmask
private final int bitmask -
buffer
Temporary buffer for formatting node values. -
root
Where to write theGridGeometrystring representation. -
section
The section under the root where to write elements. This is updated whensection(int, short, boolean, boolean)is invoked. -
vocabulary
Localized words. -
locale
The locale for the texts, numbers (except grid extent) and dates. -
crs
private final org.opengis.referencing.crs.CoordinateReferenceSystem crsThe coordinate reference system, ornullif none. -
cs
private final org.opengis.referencing.cs.CoordinateSystem csThe coordinate system, ornullif none.
-
-
Constructor Details
-
Formatter
Formatter(Locale locale, Vocabulary vocabulary, int bitmask, TreeTable.Node out) Creates a new formatter for the given combination ofGridGeometry.EXTENT,GridGeometry.ENVELOPE,GridGeometry.CRS,GridGeometry.GRID_TO_CRSandGridGeometry.RESOLUTION.
-
-
Method Details
-
format
Formats a string representation of the enclosingGridGeometryinstance in the buffer specified at construction time.- Throws:
IOException
-
section
private boolean section(int property, short title, boolean mandatory, boolean cellCenter) Starts a new section for the given property.- Parameters:
property- one ofGridGeometry.EXTENT,GridGeometry.ENVELOPE,GridGeometry.CRS,GridGeometry.GRID_TO_CRSandGridGeometry.RESOLUTION.title- theVocabularykey for the title to show for this section, if formatted.mandatory- whether to write "undefined" if the property is undefined.cellCenter- whether to add a "origin in cell center" text in the title. This is relevant only for conversion.- Returns:
trueif the caller shall format the value.
-
writeNode
Appends a single line as a node in the current section. -
writeNode
private void writeNode()Appends a node with currentbuffercontent as a single line, then clears the buffer. -
writeNodes
private void writeNodes()Appends nodes with currentbuffercontent as multi-lines text, then clears the buffer. -
appendResolution
private void appendResolution(Appendable out, NumberFormat nf, double res, int dim) throws IOException Appends a single value on the resolution line, together with its unit of measurement.- Parameters:
out- where to write the resolution.nf- number format to use for writing the number.res- the resolution to write, orDouble.NaN.dim- index of the coordinate system axis of the resolution.- Throws:
IOException
-