Package org.opengis.cite.geomatics.gml
Class GmlUtils
java.lang.Object
org.opengis.cite.geomatics.gml.GmlUtils
Provides utility methods for processing representations of GML elements.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A NamespaceContext that only recognizes the conventional "gml" namespace prefix.static class
A NamespaceContext that provides the in-scope namespace bindings for a given DOM Node. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic LineString
buildLineString
(org.geotoolkit.gml.xml.Curve gmlCurve) Creates a JTS LineString geometry from a GML Curve geometry.static boolean
Checks forAbstractSurfacePatchTypes
in geometry nodesstatic Geometry
computeConvexHull
(org.geotoolkit.gml.xml.AbstractGeometry gmlGeom) Calculates the planar convex hull of the given GML geometry element.static Element
convertToMultiType
(Node geomNode) Convert Surface or Curve geometry to MultiSurface or MultiCurve.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.static String
findCRSReference
(Element geom) Returns the value of the srsName attribute for the given geometry element.static TemporalGeometricPrimitive
gmlToTemporalGeometricPrimitive
(Element gmlTime) Creates a TemporalGeometricPrimitive instance from a GML temporal value representation.static Element
handleAbstractSurfacePatch
(Node geomNode) Rewrites a geometry Node that contain AbstractSurfacePatch elements.static boolean
hasChildElement
(Element elem, String namespace, String localName) Checks if a DOM Element has a child element with the given qualified name.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.static double
lengthInMeters
(org.geotoolkit.gml.xml.v321.LengthType length) Converts the given length measurement to meters.static int
minCurveSegmentLength
(String segmentTypeName) Indicates the minimum number of direct positions required to specify a GML curve segment.static void
setSrsNameOnCollectionMembers
(Node... geometryNodes) Sets the srsName attribute on all members of a GML geometry collection if it is specified for the collection.static org.geotoolkit.gml.xml.AbstractGeometry
unmarshalGMLGeometry
(URI uriRef) Deserializes an XML resource into a GML geometry representation.static org.geotoolkit.gml.xml.AbstractGeometry
unmarshalGMLGeometry
(Source source) Deserializes an XML source into a GML geometry representation.
-
Field Details
-
SRS_NAME
- See Also:
-
GML_NS
- See Also:
-
TOTAL_ARC_POINTS
static final int TOTAL_ARC_POINTSTotal number of arc points to be computed (including end points).- See Also:
-
-
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 byTOTAL_ARC_POINTS
; the approximation improves as the number of points increases. The calculated positions are added to the given list as JTSCoordinate
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
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 aLineString
or aPoint
.
-
setSrsNameOnCollectionMembers
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
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
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:- the nearest ancestor geometry (aggregate) that has the srsName attribute, or
- 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
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
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
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
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
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
Checks forAbstractSurfacePatchTypes
in geometry nodes- Parameters:
node
- The geometry node- Returns:
- true, if the geometry node contains a
AbstractSurfacePatchTypes
, otherwise false
-