Class MilitaryGridReferenceSystem
Object
FormattableObject
AbstractIdentifiedObject
AbstractReferenceSystem
ReferencingByIdentifiers
MilitaryGridReferenceSystem
- All Implemented Interfaces:
Serializable, Formattable, Deprecable, LenientComparable, Printable, IdentifiedObject, ReferenceSystem
The Military Grid Reference System (MGRS).
The MGRS is the geocoordinate standard used by NATO militaries for locating points on the earth.
It is based on the Universal Transverse Mercator (UTM) and the Universal Polar Stereographic (UPS) projections.
Despite its name, MGRS is used not only for military purposes; it is used also for organizing Earth Observation
data in directory trees for example.
should display (locale may vary):
MGRS references are sequences of digits and letters like “4Q FJ 12345 67890” (a reference with 1 metre accuracy), optionally written with reduced resolution as in “4Q FJ 123 678” (a reference with 100 metres accuracy). Those references form a hierarchy of 3 location types:
Grid zone designator (example: “4Q”)
└─100 km square identifier (example: “FJ”)
└─Grid coordinate (example: “12345 67890”)
Conversions between MGRS references and spatial coordinates can be performed by the Coder inner class.
The result of decoding a MGRS reference is an envelope rather than a point, but a representative point can be obtained.
The encoding and decoding processes take in account Norway and Svalbard special cases (they have wider UTM zones for
historical reasons).
Example
The following code:MilitaryGridReferenceSystem system = new MilitaryGridReferenceSystem();
MilitaryGridReferenceSystem.Coder coder = system.createCoder();
Location loc = coder.decode("32TNL83");
System.out.println(loc);
┌─────────────────────────────────────────────────────────────────┐
│ Location type: Grid coordinate │
│ Geographic identifier: 32TNL83 │
│ West bound: 580,000 m — 9°57′00″E │
│ Representative value: 585,000 m — 10°00′36″E │
│ East bound: 590,000 m — 10°04′13″E │
│ South bound: 4,530,000 m — 40°54′58″N │
│ Representative value: 4,535,000 m — 40°57′42″N │
│ North bound: 4,540,000 m — 41°00′27″N │
│ Coordinate reference system: WGS 84 / UTM zone 32N │
│ Administrator: North Atlantic Treaty Organization │
└─────────────────────────────────────────────────────────────────┘
Immutability and thread safety
This class is immutable and thus thread-safe. However, theCoder instances performing conversions between references and coordinates
are not thread-safe; it is recommended to create a new Coder instance for each thread.- Since:
- 0.8
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassConversions between direct positions and references in the Military Grid Reference System (MGRS). -
Field Summary
Fields inherited from class ReferencingByIdentifiers
OVERALL_OWNER_KEY, THEME_KEYFields inherited from class AbstractIdentifiedObject
DEPRECATED_KEY, DOMAINS_KEY, LOCALE_KEYModifier and TypeFieldDescriptionstatic final StringOptional key which can be given to the constructor for specifying the object is deprecated.static final StringKey for the"domains"property to be given to theObjectFactory.createFoo(Map, ...)methods.static final StringOptional key which can be given to the constructor for specifying the locale to use for producing error messages.Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEYFields inherited from interface ReferenceSystem
DOMAIN_OF_VALIDITY_KEY, SCOPE_KEY -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Military Grid Reference System (MGRS) using the default datum.MilitaryGridReferenceSystem(Map<String, ?> properties, CommonCRS datum) Creates a new Military Grid Reference System (MGRS) using the specified datum. -
Method Summary
Modifier and TypeMethodDescriptionReturns a new object performing conversions betweenDirectPositionand MGRS references.Methods inherited from class ReferencingByIdentifiers
equals, formatTo, getLocationTypes, getOverallOwner, getThemeModifier and TypeMethodDescriptionbooleanequals(Object object, ComparisonMode mode) Compares this reference system with the specified object for equality.protected StringFormats a pseudo-Well Known Text (WKT) representation for this object.List<? extends ModifiableLocationType> Description of location type(s) in the spatial reference system.Authority with overall responsibility for the spatial reference system.Property used to characterize the spatial reference system.Methods inherited from class AbstractReferenceSystem
getDomainOfValidity, getScope, getStandardTypeModifier and TypeMethodDescriptionDeprecated.Deprecated.Replaced byAbstractIdentifiedObject.getDomains()as of ISO 19111:2019.Returns the GeoAPI interface that defines the contract of this implementation class.Methods inherited from class AbstractIdentifiedObject
castOrCopy, equals, formatTo, getAlias, getDescription, getDomains, getIdentifiers, getInterface, getName, getRemarks, hashCode, isDeprecated, isHeuristicMatchForNameModifier and TypeMethodDescriptionstatic AbstractIdentifiedObjectcastOrCopy(IdentifiedObject object) Returns a SIS identified object implementation with the values of the given arbitrary implementation.final booleanCompares the specified object with this object for equality.voidFormats the name or identifier of this object using the provider formatter.Returns alternative names by which this object is identified.Returns a narrative explanation of the role of this object.Returns the usage of this CRS-related object.Returns identifiers which references elsewhere the object's defining information.final Class<? extends IdentifiedObject> Deprecated, for removal: This API element is subject to removal in a future version.RenamedAbstractIdentifiedObject.getStandardType()for integration withLenientComparable.getName()Returns the primary name by which this object is identified.Returns comments on or information about this object, including data source information.final intReturns a hash value for this identified object.booleanReturnstrueif this object is deprecated.booleanReturnstrueif either the primary name or at least one alias matches the given string according heuristic rules.Methods inherited from class FormattableObject
print, toString, toString, toWKTModifier and TypeMethodDescriptionvoidprint()Prints a string representation of this object to the standard output stream.Returns a Well Known Text (WKT) or an alternative text representation for this object.toString(Convention convention) Returns a Well Known Text (WKT) for this object using the specified convention.toWKT()Returns a strictly compliant Well Known Text (WKT) using the default convention, symbols and indentation.Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface IdentifiedObject
toWKT
-
Constructor Details
-
MilitaryGridReferenceSystem
public MilitaryGridReferenceSystem()Creates a new Military Grid Reference System (MGRS) using the default datum. The current Apache SIS version uses the WGS84 datum, but this choice may change in the future if there is a need to adapt to new MGRS specifications. -
MilitaryGridReferenceSystem
Creates a new Military Grid Reference System (MGRS) using the specified datum. Only the datums enumerated inCommonCRSare currently supported.- Parameters:
properties- the properties to be given to the reference system.datum- the datum to which to transform coordinates before formatting the MGRS references, ornullfor inferring the datum from the CRS associated with each coordinate.
-
-
Method Details
-
createCoder
Returns a new object performing conversions betweenDirectPositionand MGRS references. The returned object is not thread-safe; a new instance must be created for each thread, or synchronization must be applied by the caller.- Specified by:
createCoderin classReferencingByIdentifiers- Returns:
- a new object performing conversions between
DirectPositionand MGRS references.
-
AbstractIdentifiedObject.getDomains()as of ISO 19111:2019.