Class GmlUtils

java.lang.Object
org.opengis.cite.geomatics.gml.GmlUtils

public class GmlUtils extends Object
Provides utility methods for processing representations of GML elements.
  • Field Details

  • Constructor Details

    • GmlUtils

      public GmlUtils()
  • Method Details

    • inferPointsOnArc

      public static void inferPointsOnArc(org.geotoolkit.gml.xml.AbstractCurveSegment segment, CoordinateReferenceSystem crs, List<Coordinate> coordList)
      Computes the positions of at least three points on a curve segment representing an arc: the two end points and one or more intermediate points. The total number of points on the arc is specified by TOTAL_ARC_POINTS; the approximation improves as the number of points increases. The calculated positions are added to the given list as JTS Coordinate objects.
      Parameters:
      segment - A curve segment representing an arc (gml:ArcByCenterPoint or an allowable substitution).
      crs - The CRS used by the curve to which this segment belongs.
      coordList - The collection to which the coordinates will be added.
    • computeConvexHull

      public static Geometry computeConvexHull(org.geotoolkit.gml.xml.AbstractGeometry gmlGeom)
      Calculates the planar convex hull of the given GML geometry element. The convex hull is the smallest convex geometry that contains the input geometry.
      Parameters:
      gmlGeom - A GML geometry element.
      Returns:
      A JTS Geometry object. This will be a Polygon if the hull contains 3 or more points; fewer points will produce a LineString or a Point.
    • setSrsNameOnCollectionMembers

      public static void setSrsNameOnCollectionMembers(Node... geometryNodes)
      Sets the srsName attribute on all members of a GML geometry collection if it is specified for the collection. If a geometry member already has a srsName attribute it is left as is.
      Parameters:
      geometryNodes - A sequence of GML geometry elements.
      See Also:
      • "ISO 19136, cl. 10.1.3.2: SRSReferenceGroup"
    • lengthInMeters

      public static double lengthInMeters(org.geotoolkit.gml.xml.v321.LengthType length)
      Converts the given length measurement to meters. The unit of measurement is identified by its symbol or by URI reference (containing the symbol in the fragment part). Common units of length are shown in the following table. Standard SI prefix symbols may also be used to specify decimal multiples and submultiples of the unit of length (e.g. km).
      Units of length
      Unit Symbol(s) Length /m
      meter m 1
      mile mi 1609.34
      nautical mile M, NM, [nmi_i] 1852
      Parameters:
      length - A length measurement.
      Returns:
      The length in meters.
      See Also:
    • extractCoordinatesFromPosList

      public static void extractCoordinatesFromPosList(List<Double> tupleList, int crsDim, List<Coordinate> coords)
      Extracts (2D) coordinates from a sequence of coordinate tuples and adds them to a list.
      Parameters:
      tupleList - A sequence of coordinate tuples within the same coordinate reference system (CRS).
      crsDim - The dimension of the CRS.
      coords - The list to which the coordinates will be added.
    • minCurveSegmentLength

      public static int minCurveSegmentLength(String segmentTypeName)
      Indicates the minimum number of direct positions required to specify a GML curve segment. The value depends on the type of curve segment, but falls in the range 1-3.
      Parameters:
      segmentTypeName - The local name of element representing a the curve segment.
      Returns:
      An integer value > 0.
    • findCRSReference

      public static String findCRSReference(Element geom)
      Returns the value of the srsName attribute for the given geometry element. If a geometry element does not explicitly carry the srsName attribute, then it shall be inherited from either:
      1. the nearest ancestor geometry (aggregate) that has the srsName attribute, or
      2. the gml:boundedBy/gml:Envelope element in the containing feature instance.

      As a side effect, an implicit CRS reference will be added to the element using the inherited srsName value.

      Parameters:
      geom - An Element representing a GML geometry object.
      Returns:
      A String denoting a CRS reference (an absolute URI value), or an empty string if no reference was found.
      See Also:
      • "ISO 19136, cl. 9.10, 10.1.3.2"
    • hasChildElement

      public static boolean hasChildElement(Element elem, String namespace, String localName)
      Checks if a DOM Element has a child element with the given qualified name.
      Parameters:
      elem - A DOM Element.
      namespace - A namespace name (absolute URI).
      localName - A String representing the local name of an element.
      Returns:
      true if one or more matching child elements are present; false otherwise.
    • unmarshalGMLGeometry

      public static org.geotoolkit.gml.xml.AbstractGeometry unmarshalGMLGeometry(URI uriRef) throws jakarta.xml.bind.JAXBException
      Deserializes an XML resource into a GML geometry representation.
      Parameters:
      uriRef - An absolute URI that specifies the location of the resource.
      Returns:
      A GML geometry object.
      Throws:
      jakarta.xml.bind.JAXBException - If any unexpected errors occur while unmarshalling.
    • unmarshalGMLGeometry

      public static org.geotoolkit.gml.xml.AbstractGeometry unmarshalGMLGeometry(Source source) throws jakarta.xml.bind.JAXBException
      Deserializes an XML source into a GML geometry representation.
      Parameters:
      source - The source to read from (providers are only required to support SAXSource, DOMSource, and StreamSource).
      Returns:
      A GML geometry object.
      Throws:
      jakarta.xml.bind.JAXBException - If any unexpected errors occur while unmarshalling.
    • buildLineString

      public static LineString buildLineString(org.geotoolkit.gml.xml.Curve gmlCurve)
      Creates a JTS LineString geometry from a GML Curve geometry. Some points may be inferred if not given explicitly (e.g. on arc-based segments).
      Parameters:
      gmlCurve - A GML curve.
      Returns:
      A LineString, or null if one could not be constructed.
    • gmlToTemporalGeometricPrimitive

      public static TemporalGeometricPrimitive gmlToTemporalGeometricPrimitive(Element gmlTime)
      Creates a TemporalGeometricPrimitive instance from a GML temporal value representation.
      Parameters:
      gmlTime - A gml:TimeInstant or gml:TimePeriod element.
      Returns:
      A TemporalGeometricPrimitive object (instant or period).
    • convertToMultiType

      public static Element convertToMultiType(Node geomNode)
      Convert Surface or Curve geometry to MultiSurface or MultiCurve.
      Parameters:
      geomNode - Element with Surface/Curve details.
      Returns:
      Element Returns converted element to Multi geometry type.
    • handleAbstractSurfacePatch

      public static Element handleAbstractSurfacePatch(Node geomNode)
      Rewrites a geometry Node that contain AbstractSurfacePatch elements. See https://github.com/opengeospatial/ets-wfs20/issues/260
      Parameters:
      geomNode - a geometry Node containing AbstractSurfacePatch elements.
      Returns:
      The rewritten geometry Node.
    • checkForAbstractSurfacePatchTypes

      public static boolean checkForAbstractSurfacePatchTypes(Node node)
      Checks for AbstractSurfacePatchTypes in geometry nodes
      Parameters:
      node - The geometry node
      Returns:
      true, if the geometry node contains a AbstractSurfacePatchTypes, otherwise false