|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectStatic
IdentifiedObjects
public final class IdentifiedObjects
Utility methods working on arbitrary implementations of the IdentifiedObject
interface.
Note on Spatial Reference System (SRS) identifiers
OGC Web Services have the concept of a Spatial Reference System identifier used to
communicate CRS information between systems. In Well Known Text (WKT)
format, this identifier is declared in the AUTHORITY element.
Examples of Spatial Reference System (SRS) values:
EPSG:4326 - this was understood to mean force XY axis order in
old Web Map Services (WMS). Note that latest WMS specifications require the respect
of axis order as declared in the EPSG database, which is (latitude,
longitude).urn:ogc:def:crs:EPSG:4326 - understood to match the EPSG database axis order
in all cases, no matter the WMS version.AUTO:43200 - without the parameters that are specific to AUTO codes.
CRS,
Envelopes
| referencing/geotk-referencing (download) | View source code for this class |
| Field Summary | |
|---|---|
static GenericName[] |
EMPTY_ALIAS_ARRAY
An empty array of alias. |
static ReferenceIdentifier[] |
EMPTY_IDENTIFIER_ARRAY
An empty array of identifiers. |
static Comparator<IdentifiedObject> |
IDENTIFIER_COMPARATOR
A comparator for sorting identified objects by identifiers. |
static Comparator<IdentifiedObject> |
NAME_COMPARATOR
A comparator for sorting identified objects by name. |
static Comparator<IdentifiedObject> |
REMARKS_COMPARATOR
A comparator for sorting identified objects by remarks. |
| Method Summary | |
|---|---|
static String |
getIdentifier(IdentifiedObject object)
Returns the declared identifier, or null if none. |
static ReferenceIdentifier |
getIdentifier(IdentifiedObject object,
Citation authority)
Returns an identifier for the given object according the given authority. |
static String |
getName(IdentifiedObject info,
Citation authority)
Returns an object name according the given authority. |
static Map<String,?> |
getProperties(IdentifiedObject info)
Returns the informations provided in the specified identified object as a map of properties. |
static Map<String,Object> |
getProperties(IdentifiedObject info,
Citation authority)
Returns the properties to be given to an identified object derived from the specified one. |
static Integer |
lookupEpsgCode(IdentifiedObject object,
boolean fullScan)
Looks up an EPSG code of the given coordinate reference system). |
static String |
lookupIdentifier(Citation authority,
IdentifiedObject object,
boolean fullScan)
Looks up an identifier in the namespace of the given authority, such as EPSG, of the specified CRS. |
static String |
lookupIdentifier(IdentifiedObject object,
boolean fullScan)
Looks up an identifier, such as "EPSG:4326",
of the specified object. |
static boolean |
nameMatches(IdentifiedObject o1,
IdentifiedObject o2)
Returns true if the primary name of an
object matches the primary name or one alias
of the other object. |
static boolean |
nameMatches(IdentifiedObject object,
String name)
Returns true if either the primary name or
at least one alias matches the specified string. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final ReferenceIdentifier[] EMPTY_IDENTIFIER_ARRAY
getIdentifiers().toArray(EMPTY_IDENTIFIER_ARRAY);
IdentifiedObject.getIdentifiers()public static final GenericName[] EMPTY_ALIAS_ARRAY
getAlias().toArray(EMPTY_ALIAS_ARRAY);
IdentifiedObject.getAlias()public static final Comparator<IdentifiedObject> NAME_COMPARATOR
public static final Comparator<IdentifiedObject> IDENTIFIER_COMPARATOR
public static final Comparator<IdentifiedObject> REMARKS_COMPARATOR
| Method Detail |
|---|
public static Map<String,?> getProperties(IdentifiedObject info)
IdentifiedObject
interface, for example NAME_KEY. The values are
obtained by calls to the methods associated to each key, for example
IdentifiedObject.getName() for the NAME_KEY.
info - The identified object to view as a properties map.
public static Map<String,Object> getProperties(IdentifiedObject info,
Citation authority)
getProperties(info)), except for
the following:
This method returns a mutable map. Consequently, callers can add their own identifiers directly to this map if they wish.
info - The identified object to view as a properties map.authority - The new authority for the object to be created, or null if it
is not going to have any declared authority.
public static String getName(IdentifiedObject info,
Citation authority)
If the name or alias implements the ReferenceIdentifier interface,
then this method compares the identifier authority against the specified citation using the
identifierMatches method. If a matching is found, then this method returns the
identifier code of this object.
Otherwise, if the alias implements the GenericName interface, then this method
compares the name scope against the specified citation using the
identifierMatches method. If a matching is found, then this method returns the
name tip of this object.
ReferenceIdentifier and GenericName
interfaces (for example NamedIdentifier). In such cases, the identifier view has
precedence.
info - The object to get the name from, or null.authority - The authority for the name to return, or null for any authority.
null if no name matching the
specified authority was found.AbstractIdentifiedObject.getName(Citation)
public static ReferenceIdentifier getIdentifier(IdentifiedObject object,
Citation authority)
object - The object to get the identifier from, or null.authority - The authority for the identifier to return, or null for
the first identifier regardless its authority.
null if no identifier matching the specified
authority was found.AbstractIdentifiedObject.getIdentifier(Citation)public static String getIdentifier(IdentifiedObject object)
null if none. This method searches for the first
identifier (which is usually the main one) explicitly declared in the IdentifiedObject.
At the opposite of lookupIdentifier,
this method does not verify the identifier validity.
More specifically, this method uses the first non-null element found in
object.getIdentifiers(). If there
is none, then it uses object.getName() -
which is not guaranteed to be a valid identifier.
Recommanded alternatives
getIdentifier(IdentifiedObject, Citation) instead.
object - The identified object, or null.
null.getIdentifier(IdentifiedObject, Citation),
lookupIdentifier(IdentifiedObject, boolean)
public static String lookupIdentifier(IdentifiedObject object,
boolean fullScan)
throws FactoryException
"EPSG:4326",
of the specified object. This method searches in registered factories for an object
approximatively equals to the specified
object. If such an object is found, then its first identifier is returned. Otherwise
this method returns null.
Note that this method checks the identifier validity. If the given object
declares explicitly an identifier, then this method will instantiate an object from the
authority factory using that identifier and compare it with the given object. If the
comparison fails, then this method returns null. Consequently this method may
returns null even if the given object declares explicitly its identifier. If
the declared identifier is wanted unconditionally, use
getIdentifier(IdentifiedObject) instead.
object - The object (usually a coordinate
reference system) whose identifier is to be found, or null.fullScan - If true, an exhaustive full scan against all registered objects
should be performed (may be slow). Otherwise only a fast lookup based on embedded
identifiers and names will be performed.
null if none was found or if the given object was null.
FactoryException - If an unexpected failure occurred during the search.AbstractAuthorityFactory.getIdentifiedObjectFinder(Class),
IdentifiedObjectFinder.findIdentifier(IdentifiedObject)
public static String lookupIdentifier(Citation authority,
IdentifiedObject object,
boolean fullScan)
throws FactoryException
EPSG, of the specified CRS. Invoking this
method is equivalent to invoking
lookupIdentifier(object,
fullScan) except that the search is performed only among the factories of the given
authority.
Identifiers in URN and HTTP namespaces
Note that if the given authority is Citations.URN_OGC or Citations.HTTP_OGC,
then this method behaves as if the code was searched in all authority factories and the
result formatted in a "urn:ogc:def:" or
"http://www.opengis.net/gml/srs/" namespace.
authority - The authority for the code to search.object - The object (usually a coordinate
reference system) whose identifier is to be found, or null.fullScan - If true, an exhaustive full scan against all registered objects
should be performed (may be slow). Otherwise only a fast lookup based on embedded
identifiers and names will be performed.
null if none was found or if the given object was null.
FactoryException - If an unexpected failure occurred during the search.
public static Integer lookupEpsgCode(IdentifiedObject object,
boolean fullScan)
throws FactoryException
lookupIdentifier(EPSG, crs, fullScan) with the returned code parsed as an integer.
object - The object (usually a coordinate
reference system) whose identifier is to be found, or null.fullScan - If true, an exhaustive full scan against all registered objects
should be performed (may be slow). Otherwise only a fast lookup based on embedded
identifiers and names will be performed.
null if none was found or if the given object was null.
FactoryException - If an unexpected failure occurred during the search.
public static boolean nameMatches(IdentifiedObject object,
String name)
true if either the primary name or
at least one alias matches the specified string.
This method performs the search in the following order, regardless of any authority:
object - The object to check.name - The name.
true if the primary name of at least one alias
matches the specified name.AbstractIdentifiedObject.nameMatches(String)
public static boolean nameMatches(IdentifiedObject o1,
IdentifiedObject o2)
true if the primary name of an
object matches the primary name or one alias
of the other object.
o1 - The first object to compare by name.o2 - The second object to compare by name.
true if both objects have a common name.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||