Class Extents

java.lang.Object
org.opengis.cite.geomatics.Extents

public class Extents extends Object
Provides utility methods to create or operate on envelope representations.
  • Method Details

    • calculateEnvelope

      public static Envelope calculateEnvelope(NodeList geomNodes) throws jakarta.xml.bind.JAXBException
      Calculates the envelope that covers the given collection of GML geometry elements.
      Parameters:
      geomNodes - A NodeList containing GML geometry elements; it is assumed these all refer to the same CRS.
      Returns:
      An Envelope object representing the overall spatial extent (MBR) of the geometries.
      Throws:
      jakarta.xml.bind.JAXBException - If a node cannot be unmarshalled to a geometry object.
    • calculateEnvelopeUsingSingleGeometry

      public static Envelope calculateEnvelopeUsingSingleGeometry(NodeList geomNodes) throws jakarta.xml.bind.JAXBException
      Calculates the envelope using single GML geometry element.
      Parameters:
      geomNodes - A NodeList containing GML geometry elements; it is assumed these all refer to the same CRS.
      Returns:
      An Envelope object representing the overall spatial extent (MBR) of the geometries.
      Throws:
      jakarta.xml.bind.JAXBException - If a node cannot be unmarshalled to a geometry object.
    • envelopeAsGML

      public static Document envelopeAsGML(Envelope envelope)
      Generates a standard GML representation (gml:Envelope) of an Envelope object. Ordinates are rounded down to 2 decimal places.
      Parameters:
      envelope - An Envelope defining a bounding rectangle (or prism).
      Returns:
      A DOM Document with gml:Envelope as the document element.
    • envelopeAsPolygon

      public static Polygon envelopeAsPolygon(Envelope envelope)
      Creates a JTS Polygon having the same extent as the given envelope.
      Parameters:
      envelope - An Envelope defining a bounding rectangle.
      Returns:
      A Polygon with the relevant CoordinateReferenceSystem set as a user data object.
    • coalesceBoundingBoxes

      public static Envelope coalesceBoundingBoxes(List<Node> bboxNodes) throws FactoryException, TransformException
      Coalesces a sequence of bounding boxes so as to create an envelope that covers all of them. The resulting envelope will use the same CRS as the first bounding box in the list; the remaining bounding boxes will be transformed to this CRS if necessary.
      Parameters:
      bboxNodes - A list of elements representing common bounding boxes (ows:BoundingBox, ows:WGS84BoundingBox, or gml:Envelope).
      Returns:
      An Envelope encompassing the total extent of the given bounding boxes.
      Throws:
      FactoryException - If an unrecognized CRS reference is encountered or a corresponding CoordinateReferenceSystem cannot be constructed.
      TransformException - If an attempt to perform a coordinate transformation fails for some reason.
    • createEnvelope

      public static Envelope createEnvelope(Node envelopeNode) throws FactoryException
      Creates an Envelope from the given XML representation of a spatial extent (ows:BoundingBox, ows:WGS84BoundingBox, or gml:Envelope).
      Parameters:
      envelopeNode - A DOM Node (Document or Element) representing a spatial envelope.
      Returns:
      An envelope defining a spatial extent in some coordinate reference system.
      Throws:
      FactoryException - If an unrecognized CRS reference is encountered or a corresponding CoordinateReferenceSystem cannot be constructed for some reason.
    • envelopeToString

      public static String envelopeToString(Envelope envelope)
      Returns a String representation of a bounding box suitable for use as a query parameter value (KVP syntax). The value consists of a comma-separated sequence of data items as indicated below:
       LowerCorner coordinate 1
       LowerCorner coordinate 2
       LowerCorner coordinate N
       ...
       UpperCorner coordinate 1
       UpperCorner coordinate 2
       UpperCorner coordinate N
       crs URI (optional - default "urn:ogc:def:crs:OGC:1.3:CRS84")
       
      Examples:
      49.25,-123.1,50.0,-122.5,urn:ogc:def:crs:EPSG::4326
      472944,5363287,516011,5456383,urn:ogc:def:crs:EPSG::32610
      -123.1,49.25,-122.5,50.0

      Note: The colon character (":") is allowed in the query component of a URI and thus does not need to be escaped. See RFC 3986, sec. 3.4.

      Parameters:
      envelope - An envelope specifying a geographic extent.
      Returns:
      A String suitable for use as a query parameter value (KVP syntax).
      See Also:
    • antipodalEnvelope

      public static Envelope antipodalEnvelope(Envelope envelope)
      Returns an envelope that is diametrically opposite to the specified envelope. The resulting envelope uses the CRS with EPSG code 4326 ("WGS 84").
      Parameters:
      envelope - An envelope (rectangle or cuboid).
      Returns:
      A new Envelope that is located on the opposite side of the earth.
    • getAntipode

      public static double[] getAntipode(double[] coordTuple)
      Returns the antipode of the specified coordinate tuple. The antipode of the point (φ, θ) is (-φ, θ ± 180).
      Parameters:
      coordTuple - An array containing a sequence of coordinate values.
      Returns:
      A new array representing the antipodal position.