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 int
private final StringBuilder
Temporary buffer for formatting node values.private final org.opengis.referencing.crs.CoordinateReferenceSystem
The coordinate reference system, ornull
if none.private final org.opengis.referencing.cs.CoordinateSystem
The coordinate system, ornull
if none.private final Locale
The locale for the texts, numbers (except grid extent) and dates.private final TreeTable.Node
Where to write theGridGeometry
string representation.private TreeTable.Node
The section under the root where to write elements.private final Vocabulary
Localized 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_CRS
andGridGeometry.RESOLUTION
. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendResolution
(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 void
format()
Formats a string representation of the enclosingGridGeometry
instance in the buffer specified at construction time.private boolean
section
(int property, short title, boolean mandatory, boolean cellCenter) Starts a new section for the given property.private void
Appends a node with currentbuffer
content as a single line, then clears the buffer.private void
writeNode
(CharSequence line) Appends a single line as a node in the current section.private void
Appends nodes with currentbuffer
content 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 theGridGeometry
string 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, ornull
if none. -
cs
private final org.opengis.referencing.cs.CoordinateSystem csThe coordinate system, ornull
if 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_CRS
andGridGeometry.RESOLUTION
.
-
-
Method Details
-
format
Formats a string representation of the enclosingGridGeometry
instance 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_CRS
andGridGeometry.RESOLUTION
.title
- theVocabulary
key 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:
true
if 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 currentbuffer
content as a single line, then clears the buffer. -
writeNodes
private void writeNodes()Appends nodes with currentbuffer
content 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
-