Function library providing geo processing using Simple Features api API GMLSF format. It uses the GEOS third party library, license LGPL. Version 3.2.2 or above is required.
The data format supported is GML SF profile 0/1. This is a subset of GML, and covers the basic geometries of Point, Line and Surface and collections of those. GMLSF nodes have the namespace "http://www.opengis.net/gml".
Possible GMLSF geometric structures are:
<gml:Point [srsDimension='2|3']?> <gml:pos [srsDimension='2|3']?>double_x double_y </gml:pos> </gml:Point>
<gml:LineString [srsDimension='2|3']?> <gml:posList [srsDimension='2|3']?> double_x1 double_y1 double_x2 double_y2 ... </gml:posList> </gml:LineString>
<gml:Curve [srsDimension='2|3']?> <gml:segments> [<gml:LineStringSegment interpolation="linear" [srsDimension='2|3']?> <gml:posList [srsDimension='2|3']?> double_x1 double_y1 double_x2 double_y2 ... </gml:posList>; <gml:LineStringSegment>]* </gml:segments> </gml:Curve>
<gml:LinearRing [srsDimension='2|3']?> <gml:posList [srsDimension='2|3']?> double_x1 double_y1 double_x2 double_y2 ... </gml:posList> </gml:LinearRing>
<gml:Surface [srsDimension='2|3']?> <gml:patches> [<gml:PolygonPatch [srsDimension='2|3']?> <gml:exterior> <gml:LinearRing> ... </gml:LinearRing> </gml:exterior> <gml:interior> <gml:LinearRing> ... </gml:LinearRing> </gml:interior>]* </gml:PolygonPatch>]* </gml:patches> </gml:Surface>
<gml:Polygon [srsDimension='2|3']?> <gml:exterior> <gml:LinearRing> ... </gml:LinearRing> </gml:exterior> [<gml:interior> <gml:LinearRing> ... </gml:LinearRing> </gml:interior>]* </gml:Polygon>
<gml:MultiPoint [srsDimension='2|3']?> [<gml:Point> ... </gml:Point>]* </gml:MultiPoint>
<gml:MultiCurve [srsDimension='2|3']?> [<gml:LineString> ... </gml:LineString>]* </gml:MultiCurve>
<gml:MultiSurface [srsDimension='2|3']?> [<gml:Polygon> ... </gml:Polygon>]* </gml:MultiSurface>
<gml:MultiGeometry [srsDimension='2|3']?> [<gml:geometryMember> ...one geometry... </gml:geometryMember>]* [<gml:geometryMembers> ...a list of geometries... </gml:geometryMembers>]? </gml:MultiGeometry>
Note: When using gml:posList, it is possible to replace this element with a list of gml:pos.
Note: XLink referencing is not supported.
Note: The srsDimension optional attribute specifies the coordinate dimension. The default value is 2 (for 2D). Another possible value is 3 (for 3D) in which case every point has to have three double values (x, y, z). This is an extension borrowed from GML 3 spec.
The operations made on 3D objects work only on x-y coordinates, the z coordinate is not taken into account. When returning the result, the original z-coordinates of the points are preserved. For computed points, the z-coordinate is interpolated.
The coordinates values have to be in cartesian coordinates, not in polar coordinates. Converting between coordinate systems and doing projections from polar to cartesian is outside the scope of this geo module.
For operations between two geometries, the DE-9IM matrix is used. The DE-9IM matrix is defined like this:
Interior | Boundary | Exterior | |
Interior | dim(intersection of interior1 and interior2) | dim(intersection of interior1 and boundary2) | dim(intersection of interior1 and exterior2) |
Boundary | dim(intersection of boundary1 and interior2) | dim(intersection of boundary1 and boundary2) | dim(intersection of boundary1 and exterior2) |
Exterior | dim(intersection of exterior1 and interior2) | dim(intersection of exterior1 and boundary2) | dim(intersection of exterior1 and exterior2) |
The values in the DE-9IM can be T, F, *, 0, 1, 2.
- T means the intersection gives a non-empty result.
- F means the intersection gives an empty result.
- * means any result.
- 0, 1, 2 gives the expected dimension of the result (point, curve, surface)
Return the dimension of the geo object.
Return the coordinate dimension of the geo object, as specified in the srsDimension attribute.
Only two-dimensional and three-dimensional coordinates are supported.
Return the qname type of geo object.
Returns empty sequence if the geometry is not recognized.
Return the srid URI of geo object.
SRID is contained in the srsName attribute in the geo element, or one of the parents, or in the boundedBy/Envelope element in one of the parents.
This function searches recursively from this element up to the top-most parent.
Return the number of geometries in the collection, or 1 for non-collection.
For gml:Point, gml:LineString, gml:LinearRing, gml:Polygon, return 1.
For gml:Curve and gml:Surface, they are treated as geometric collections.
Return the n-th geometry in the collection.
Return this geometry if it is not a collection.
For gml:Point, gml:LineString, gml:LinearRing, gml:Polygon, return this item if n is zero, otherwise error.
For gml:Curve and gml:Surface, they are treated as geometric collections.
The envelope is the minimum bounding box of this geometry.
Return the Well-known Text Representation of Geometry.
This is defined in the Simple Features spec from OGC.
gml:Curve is represented as MultiLineString.
gml:Surface is represented as MultiPolygon.
Return the Well-known Binary Representation of Geometry.
This is defined in the Simple Features spec from OGC.
gml:Curve is represented as MultiLineString.
gml:Surface is represented as MultiPolygon.
Checks if the argument is empty or not and if it is a valid geometry or not.
A geometry is considered empty if it has no points.
Checks if this geometric object has no anomalous geometric points, such as self intersection or self tangency.
Does not work for gml:Surface and gml:MultiGeometry.
Checks if this geometric object is 2D or 3D, as specified in srsDimension optional attribute.
Checks if this geometric object has measurements.
Measurements is not supported in this geo module, so the function returns false.
A boundary is a set that represents the limit of an geometry.
For a Point or MultiPoint, the boundary is the empty geometry, nothing is returned.
For a LineString, the boundary is the MultiPoint set of start point and end point.
For a LinearRing, the boundary is empty MultiPoint.
For a Curve, it is treated as a MultiCurve.
For a Polygon, the boundary is the MultiCurve set of exterior and interior rings.
For a Surface, the boundary is the MultiCurve set formed from the exterior ring of all patches seen as a single surface and all the interior rings from all patches.
For MultiCurve, the boundary is the MultiPoint set of all start and end points that appear in an odd number of linestrings.
For MultiGeometry, a sequence of boundaries is returned, corresponding to each child geometry.
Checks if the two geometries are equal.
Note: Does not work for gml:Surface and gml:MultiSurface if they have multiple Polygons.
Checks if geometry1 covers geometry2.
It has to fulfill one of these conditions:
- every point of geometry2 is a point of geometry1.
- the DE-9IM Intersection Matrix for the two geometries is T*****FF* or *T****FF* or ***T**FF* or ****T*FF*.
Unlike contains it does not distinguish between points in the boundary and in the interior of geometries.Checks if geometry1 does not touch or intersects geometry2.
It has to fulfill these conditions:
- they have no point in common
- the DE-9IM Intersection Matrix for the two geometries is FF*FF****.
- geometry1 does not intersect geometry2.
Checks if geometry1 intersects geometry2.
This is true if disjoint returns false.
Checks if geometry1 touches geometry2.
Returns true if the DE-9IM intersection matrix for the two geometries is FT*******, F**T***** or F***T****.
Checks if geometry1 crosses geometry2.
That is if the geometries have some but not all interior points in common.
Returns true if the DE-9IM intersection matrix for the two geometries is:
T*T****** (for P/L, P/A, and L/A situations).
T*****T** (for L/P, A/P, and A/L situations).
0******** (for L/L situations).
This applies for situations: P/L, P/A, L/L, L/A, L/P, A/P and A/L.
For other situations it returns false.
Checks if geometry1 is within geometry2.
Returns true if the DE-9IM intersection matrix for the two geometries is T*F**F***.
Checks if geometry1 contains geometry2.
Returns true if within(geometry2, geometry1) is true.
Checks if geometry1 overlaps with geometry2.
Returns true if DE-9IM intersection matrix for the two geometries is T*T***T** (for two points or two surfaces) or * 1*T***T** (for two curves).
Checks if geometry1 relates with geometry2 relative to a DE-9IM matrix.
The DE-9IM matrix is defined like this:
Interior | Boundary | Exterior | |
Interior | dim(intersection of interior1 and interior2) | dim(intersection of interior1 and boundary2) | dim(intersection of interior1 and exterior2) |
Boundary | dim(intersection of boundary1 and interior2) | dim(intersection of boundary1 and boundary2) | dim(intersection of boundary1 and exterior2) |
Exterior | dim(intersection of exterior1 and interior2) | dim(intersection of exterior1 and boundary2) | dim(intersection of exterior1 and exterior2) |
The values in the DE-9IM can be T, F, *, 0, 1, 2 .
- T means the intersection gives a non-empty result.
- F means the intersection gives an empty result.
- * means any result.
- 0, 1, 2 gives the expected dimension of the result (point, curve, surface)
For example, the matrix of "T*T***T**" checks for intersections of interior1 with interior2, interior1 with exterior2 and exterior1 with interior2.
Compute the shortest distance between any two Points in geometry1 and geometry2.
Returns a polygon that represents all Points whose distance from this geometric object is less than or equal to distance.
Returns the smallest convex Polygon that contains all the points in the Geometry.
Actually returns the object of smallest dimension possible (possible Point or LineString).
Returns a geometric object that represents the Point set intersection of geometry1 and geometry2.
For intersection of two polygons interiors, returns a polygon.
If intersection is void, empty sequence is returned.
Returns a geometric object that represents the Point set union of geometry1 and geometry2.
Returns a geometric object that represents the Point set difference of geometry1 and geometry2. Points that are in geometry1 and are not in geometry2.
If difference is empty geometry, empty sequence is returned.
Returns a geometric object that represents the Point set symmetric difference of geometry1 and geometry2. Points that are in geometry1 and are not in geometry2 and points that are in geometry2 and are not in geometry1.
If difference is empty geometry, empty sequence is returned.
Returns the area of this geometry.
Returns zero for Point and Lines.
Returns the length of the lines of this geometry.
Returns zero for Points.
Checks if geometry2 is within a certain distance of geometry1.
Returns a Point that is the mathematical centroid of this geometry.
The result is not guaranteed to be on the surface.
Returns a Point that is interior of this geometry.
If it cannot be inside the geometry, then it will be on the boundary.
Returns the X coordinate of a Point.
Returns the Y coordinate of a Point.
Returns the Z coordinate of a Point, if is 3D.
Should return the Measure of a Point, but is not implemented, because it is not specified in GMLSF.
Returns the start Point of a line.
Returns the end Point of a line.
Checks if the line is closed loop. That is, if the start Point is same with end Point.
For gml:Curve, checks if the start point of the first segment is the same with the last point of the last segment. It also checks that all the segments are connected together, and returns false if they aren't.
For gml:MultiCurve, checks recursively for each LineString.
For gml:Surface, checks if the exterior boundary of each patch touches completely other patches, so the Surface encloses a solid. For this to happen there is a need for 3D objects, and full 3D processing is not supported in GEOS library, so the function always returns false in this case.
Checks if the line is a ring. That is, if the line is closed and simple.
Return the number of Points in a line.
Return the n-th Point in a line.
Return the exterior ring of a Polygon.
Return the number of interior rings of a Polygon.
Return the n-th interior ring of a Polygon.
Return the number of surface patches inside a gml:Surface.
This function has the same effect as num-geometries(), only it is restricted to gml:Surface.
Return the n-th Surface patch of a Surface.
Only polygonal Surfaces are supported, so a gml:PolygonPatch is returned.
The gml:PolygonPatch has the same content as gml:Polygon.
This function has the same effect as geometry-n(), only it is restricted to gml:Surface.
Return the list of PolygonPatches that share a boundary with the given $polygon.
The gml:PolygonPatch has the same content as gml:Polygon.
This function tests the exterior ring of each polygon patch if it overlaps with the exterior ring of the given polygon.