Class LocationFormat
java.lang.Object
java.text.Format
org.apache.sis.io.CompoundFormat<T>
org.apache.sis.io.TabularFormat<AbstractLocation>
org.apache.sis.referencing.gazetteer.LocationFormat
- All Implemented Interfaces:
Serializable,Cloneable,Localized
Formats
Location instances in a tabular format.
This format assumes a monospaced font and an encoding supporting drawing box characters (e.g. UTF-8).
Example:
the location identified by "32TNL83" in the military grid reference system
can be represented by the following string formatted using
Locale.ENGLISH:
Limitations
- The current implementation can only format features — parsing is not yet implemented.
LocationFormat, like mostjava.text.Formatsubclasses, is not thread-safe.
- Since:
- 0.8
- Version:
- 0.8
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.Format
Format.Field -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final short[]Vocabulary.Keysconstants for the east, west, south and north bounds, in that order.(package private) static final LocationFormatDefault instance forAbstractLocation.toString().private static final longFor cross-version compatibility.Fields inherited from class org.apache.sis.io.TabularFormat
beforeFill, columnSeparator, fillCharacter, lineSeparator, omitTrailingNulls -
Constructor Summary
ConstructorsConstructorDescriptionLocationFormat(Locale locale, TimeZone timezone) Creates a new format for the given locale. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidappend(TableAppender table, Vocabulary vocabulary, short key, String value) Appends the given value in the given table if it is not null.clone()Returns a clone of this format.protected FormatcreateFormat(Class<?> valueType) Creates the format to use for formatting a latitude, longitude or projected coordinate.voidformat(AbstractLocation location, Appendable toAppendTo) Writes a textual representation of the given location in the given stream or buffer.Returns the type of values formatted by thisFormatinstance.private voidnextColumn(TableAppender table) Moves to the next column.private static org.opengis.referencing.crs.CoordinateReferenceSystemnormalize(org.opengis.referencing.crs.CoordinateReferenceSystem crs) Returns a CRS equivalent to the given one but with (longitude, latitude) or (easting, northing) axis order.parse(CharSequence text, ParsePosition pos) Unsupported operation.private static org.opengis.geometry.DirectPositionposition(org.opengis.geometry.coordinate.Position p) Returns the direct position for the given position, ornullif none.private StringReturns a localized version of the given date, ornullif none.private static StringReturns a localized version of the given international string, ornullif none.private static org.opengis.geometry.DirectPositiontransform(org.opengis.geometry.DirectPosition position, org.opengis.referencing.crs.CoordinateReferenceSystem sourceCRS, org.opengis.referencing.crs.CoordinateReferenceSystem targetCRS) Transforms the given position from the given source to the given target CRS.Methods inherited from class org.apache.sis.io.TabularFormat
getColumnSeparatorMatcher, getColumnSeparatorPattern, getLineSeparator, setColumnSeparatorPattern, setLineSeparatorMethods inherited from class org.apache.sis.io.CompoundFormat
format, getFormat, getLocale, getLocale, getTimeZone, parseObject, parseObjectMethods inherited from class java.text.Format
format, formatToCharacterIterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
INSTANCE
Default instance forAbstractLocation.toString(). Use of this instance must be synchronized onINSTANCE. -
BOUND_KEY
private static final short[] BOUND_KEYVocabulary.Keysconstants for the east, west, south and north bounds, in that order.
-
-
Constructor Details
-
LocationFormat
Creates a new format for the given locale. The given locale can benullorLocale.ROOTif this format shall format "unlocalized" strings.- Parameters:
locale- the locale for the newFormat, ornullforLocale.ROOT.timezone- the timezone, ornullfor UTC.
-
-
Method Details
-
getValueType
Returns the type of values formatted by thisFormatinstance.- Specified by:
getValueTypein classCompoundFormat<AbstractLocation>- Returns:
- the type of values formatted by this
Formatinstance.
-
normalize
private static org.opengis.referencing.crs.CoordinateReferenceSystem normalize(org.opengis.referencing.crs.CoordinateReferenceSystem crs) Returns a CRS equivalent to the given one but with (longitude, latitude) or (easting, northing) axis order. This method does not change the units of measurement. If the given CRS is already normalized, then it is returned unchanged. -
transform
private static org.opengis.geometry.DirectPosition transform(org.opengis.geometry.DirectPosition position, org.opengis.referencing.crs.CoordinateReferenceSystem sourceCRS, org.opengis.referencing.crs.CoordinateReferenceSystem targetCRS) throws org.opengis.util.FactoryException, org.opengis.referencing.operation.TransformException Transforms the given position from the given source to the given target CRS. If the source and target CRS are the same, then this method returns the position unchanged.- Throws:
org.opengis.util.FactoryExceptionorg.opengis.referencing.operation.TransformException
-
position
private static org.opengis.geometry.DirectPosition position(org.opengis.geometry.coordinate.Position p) Returns the direct position for the given position, ornullif none. -
toString
Returns a localized version of the given international string, ornullif none. -
toString
Returns a localized version of the given date, ornullif none. -
format
Writes a textual representation of the given location in the given stream or buffer.Upcoming API change — generalization
in a future SIS version, the type oflocationparameter may be generalized to theorg.opengis.referencing.gazetteer.Locationinterface. This change is pending GeoAPI revision.- Specified by:
formatin classCompoundFormat<AbstractLocation>- Parameters:
location- the location to format.toAppendTo- where to format the location.- Throws:
IOException- if an error occurred while writing to the given appendable.
-
createFormat
Creates the format to use for formatting a latitude, longitude or projected coordinate. This method is invoked byformat(Location, Appendable)when first needed.- Overrides:
createFormatin classCompoundFormat<AbstractLocation>- Parameters:
valueType-Angle.class.Number.classorUnit.class.- Returns:
- a new
AngleFormat,NumberFormatorUnitFormatinstance depending on the argument value.
-
append
private void append(TableAppender table, Vocabulary vocabulary, short key, String value) throws IOException Appends the given value in the given table if it is not null.- Parameters:
table- the table where to append the value.vocabulary- localized resources for the labels.key- key of the label to append.value- value to append, ornullif none.- Throws:
IOException
-
nextColumn
Moves to the next column. -
parse
Unsupported operation.- Specified by:
parsein classCompoundFormat<AbstractLocation>- Parameters:
text- the character sequence for the location to parse.pos- the position where to start the parsing.- Returns:
- the parsed location, or
nullif the text is not recognized. - Throws:
ParseException- if an error occurred while parsing the location.
-
clone
Returns a clone of this format.- Overrides:
clonein classTabularFormat<AbstractLocation>- Returns:
- a clone of this format.
-