|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectFormattableObject
public class FormattableObject
Base class for objects formattable as Well Known Text (WKT).
Almost every Geotk implementations of referencing objects extend this class,
except AffineTransform2D.
Strict and lenient WKT formatting
Strict WKT formatting is performed by various toWKT(...) methods. Those methods may
fail to format a particular object, in which case a UnformattableObjectException is
thrown. A formatting may fail because an object is too complex for the WKT format capability
(for example an EngineeringCRS
with different unit for different axis), or because only some specific implementations can be
formatted as WKT.
The default toString() implementation is like toWKT() except that no
exception is thrown if the resulting WKT is not compliant with the specification. The
toString() method does not provide control over indentation and other features.
But if such control is desired, it can be obtained by using directly the Formatter
class.
Syntax coloring
A convenience print() method is provided, which is roughly equivalent to
System.out.println(this) except that syntax coloring is automatically applied
if the terminal seems to support the X3.64 standard.
| referencing/geotk-referencing (download) | View source code for this class |
| Field Summary | |
|---|---|
static Citation |
EPSG
Deprecated. Replaced by Convention.EPSG. |
static Citation |
GEOTIFF
Deprecated. Replaced by Convention.GEOTIFF. |
static Citation |
INTERNAL
Deprecated. Replaced by Convention.INTERNAL. |
static Citation |
OGC
Deprecated. Replaced by Convention.OGC. |
static int |
SINGLE_LINE
Deprecated. Moved to WKTFormat.SINGLE_LINE in order to reduce the amount
of declarations in this base class. The raison is that FormattableObject
is extended by a lot of objects, and those rarely-used WKT stuff are distracting. |
| Constructor Summary | |
|---|---|
protected |
FormattableObject()
Default constructor. |
| Method Summary | |
|---|---|
String |
formatWKT(Formatter formatter)
Formats the inner part of a Well Known Text (WKT) element. |
static int |
getDefaultIndentation()
Deprecated. Moved to WKTFormat.getDefaultIndentation(). |
void |
print()
Prints a string representation of this object to the standard output stream. |
static void |
setDefaultIndentation(int indentation)
Deprecated. Moved to WKTFormat.setDefaultIndentation(int). |
String |
toString()
Returns a string representation for this object. |
String |
toWKT()
Returns a Well Known Text (WKT) using the default indentation. |
String |
toWKT(Citation authority,
int indentation)
Deprecated. Replaced by toWKT(Convention, int). |
String |
toWKT(Convention convention,
int indentation)
Returns a Well Known Text (WKT) for this object using the specified convention and indentation. |
String |
toWKT(int indentation)
Deprecated. Replaced by toWKT(Convention, int) with Convention.OGC.
This method will be removed in order to simplify the API. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
@Deprecated public static final int SINGLE_LINE
WKTFormat.SINGLE_LINE in order to reduce the amount
of declarations in this base class. The raison is that FormattableObject
is extended by a lot of objects, and those rarely-used WKT stuff are distracting.toWKT(int) method for formatting the complete
object on a single line.
@Deprecated public static final Citation OGC
Convention.OGC.Citations class, copied here for convenience.
Citations.OGC@Deprecated public static final Citation EPSG
Convention.EPSG.Citations class, copied here for convenience.
Citations.EPSG@Deprecated public static final Citation GEOTIFF
Convention.GEOTIFF.Citations class, copied here for convenience.
Citations.GEOTIFF@Debug @Deprecated public static final Citation INTERNAL
Convention.INTERNAL.authority argument of the toWKT(Citation,int) method.
In the majority of cases, the result will be identical to the one we would get using the
OGC authority. However in the particular case of map projections, the result may be
quite different because of the way Geotk separates the linear from the non-linear parameters.
This citation is used only for debugging purpose.
Formatter.isInternalWKT()| Constructor Detail |
|---|
protected FormattableObject()
| Method Detail |
|---|
@Debug public void print()
X3.64 standard,
then a syntax coloring will be applied.
This is a convenience method for debugging purpose and for console applications.
Note: We don't use the standard error stream (the stream used by the Java logging framework) because it is different than the stream used by the console.
public String toString()
toWKT(), except that no exception is thrown if the string contains
non-standard keywords. For example the WKT specification does not defines any keyword for
coordinate system objects. If this object is an instance of
DefaultCartesianCS, then the WKT will be formatted as
CartesianCS[AXIS["..."], AXIS["..."], etc.].
toString in class Object
public String toWKT()
throws UnformattableObjectException
UnformattableObjectException - If this object can't be formatted as WKT.IdentifiedObject.toWKT()
@Deprecated
public String toWKT(int indentation)
throws UnformattableObjectException
toWKT(Convention, int) with Convention.OGC.
This method will be removed in order to simplify the API.
indentation - The amount of spaces to use in indentation for WKT formatting,
or -1 for formatting the
whole WKT on a single line.
UnformattableObjectException - If this object can't be formatted as WKT.
@Deprecated
public String toWKT(Citation authority,
int indentation)
throws UnformattableObjectException
toWKT(Convention, int).
OGC, but other common
authorities are GEOTIFF and EPSG. The INTERNAL citation
is a special value for debugging map projections.
authority - The authority to prefer when choosing WKT entities names.indentation - The amount of spaces to use in indentation for WKT formatting,
or -1 for formatting the
whole WKT on a single line.
UnformattableObjectException - If this object can't be formatted as WKT.
public String toWKT(Convention convention,
int indentation)
throws UnformattableObjectException
OGC,
but other common conventions are GEOTIFF and
EPSG. The INTERNAL
convention is a special value for debugging map projections.
convention - The convention for choosing WKT entities names.
The default value is OGC.indentation - The amount of spaces to use in indentation for WKT formatting,
or -1 for formatting the
whole WKT on a single line.
UnformattableObjectException - If this object can't be formatted as WKT.public String formatWKT(Formatter formatter)
Formatter.append(Formattable).
Element name and authority code shall not be formatted here. For example for a GEOGCS
element, the formatter will invoke this method for completing the WKT at the insertion point
show below:
GEOGCS["WGS 84", AUTHORITY["EPSG","4326"]]
↑
(insertion point)
The default implementation declares that this object produces an invalid WKT.
Subclasses must override this method for proper WKT formatting and should
not invoke super.formatWKT(formatter) if they can
use a valid WKT syntax.
formatWKT in interface Formattableformatter - The formatter to use.
"GEOGCS").toWKT(),
toString()@Deprecated public static int getDefaultIndentation()
WKTFormat.getDefaultIndentation().
setDefaultIndentation(int).
@Deprecated @Configuration public static void setDefaultIndentation(int indentation)
WKTFormat.setDefaultIndentation(int).
indentation - The new default value for indentation.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||