Difference between revisions of "Geo Module"

From BaseX Documentation
Jump to navigation Jump to search
Line 548: Line 548:
  
 
| '''Summary'''
 
| '''Summary'''
| Returns integer value of number of the points in the given line{{Code|$geometry}}. {{Code|$line}} has to be a line, as a geometry, LineString or LinearRing, and MultiLineString.
+
| Returns integer value of number of the points in the given line {{Code|$geometry}}. {{Code|$line}} has to be a line, as a geometry, LineString or LinearRing, and MultiLineString.
 
|-
 
|-
 
| '''Errors'''
 
| '''Errors'''
Line 565: Line 565:
  
 
| '''Summary'''
 
| '''Summary'''
| Returns the Nth point in the given line{{Code|$geometry}}. {{Code|$line}} has to be a single line, as a geometry, LineString or LinearRing.
+
| Returns the Nth point in the given line {{Code|$geometry}}. {{Code|$line}} has to be a single line, as a geometry, LineString or LinearRing.
 
|-
 
|-
 
| '''Errors'''
 
| '''Errors'''
Line 581: Line 581:
  
 
| '''Summary'''
 
| '''Summary'''
| Returns the area of the given geometry{{Code|$geometry}}. For points and line the return value will be zero.
+
| Returns the area of the given geometry {{Code|$geometry}}. For points and line the return value will be zero.
 
|-
 
|-
 
| '''Errors'''
 
| '''Errors'''
 
|{{Error|GEO0001|#Errors}} the given element(s) is not recognized as a valid geometry (QName).<br />{{Error|GEO0002|#Errors}} the given element cannot be read by reader for some reason.<br />
 
|{{Error|GEO0001|#Errors}} the given element(s) is not recognized as a valid geometry (QName).<br />{{Error|GEO0002|#Errors}} the given element cannot be read by reader for some reason.<br />
 +
|}
 +
 +
 +
 +
 +
==geo:centroid==
 +
{| width='100%'
 +
|-
 +
| width='90' | '''Signatures'''
 +
|{{Func|geo:centroid|$geometry as element(*)|element(gml:Point)}}
 +
|-
 +
 +
| '''Summary'''
 +
| Returns the mathematical centroid of the given geometry {{Code|$geometry}}, as a gml:Point. Based on the definition, this point is not always on the surface of the geometry {{Code|$geometry}}.
 +
|-
 +
| '''Errors'''
 +
|{{Error|GEO0001|#Errors}} the given element(s) is not recognized as a valid geometry (QName).<br />{{Error|GEO0002|#Errors}} the given element cannot be read by reader for some reason.<br />{{Error|GEO0008|#Errors}} the output object cannot be written as an element by writer for some reason.<br />
 +
|}
 +
 +
 +
 +
 +
==geo:pointOnSurface==
 +
{| width='100%'
 +
|-
 +
| width='90' | '''Signatures'''
 +
|{{Func|geo:pointOnSurface|$geometry as element(*)|element(gml:Point)}}
 +
|-
 +
 +
| '''Summary'''
 +
| Returns an interior point on the given geometry {{Code|$geometry}}, as a gml:Point. It is guaranteed to be on surface. Otherwise, the point may lie on the boundary of the geometry.
 +
|-
 +
| '''Errors'''
 +
|{{Error|GEO0001|#Errors}} the given element(s) is not recognized as a valid geometry (QName).<br />{{Error|GEO0002|#Errors}} the given element cannot be read by reader for some reason.<br />{{Error|GEO0008|#Errors}} the output object cannot be written as an element by writer for some reason.<br />
 +
|}
 +
 +
 +
 +
 +
 +
==geo:exteriorRing==
 +
{| width='100%'
 +
|-
 +
| width='90' | '''Signatures'''
 +
|{{Func|geo:pointOnSurface|$polygon as element(*)|element(gml:LineString)}}
 +
|-
 +
 +
| '''Summary'''
 +
| Returns the outer ring of the given polygon {{Code|$geometry}}, as a gml:LineString.
 +
|-
 +
| '''Errors'''
 +
|{{Error|GEO0001|#Errors}} the given element(s) is not recognized as a valid geometry (QName).<br />{{Error|GEO0002|#Errors}} the given element cannot be read by reader for some reason.<br />{{Error|GEO0003|#Errors}} the given element has to be a polygon. Other geometries are not accepted.<br />{{Error|GEO0008|#Errors}} the output object cannot be written as an element by writer for some reason.<br />
 +
|}
 +
 +
 +
 +
 +
==geo:numInteriorRing==
 +
{| width='100%'
 +
|-
 +
| width='90' | '''Signatures'''
 +
|{{Func|geo:numInteriorRing|$polygon as element(*)|xs:integer}}
 +
|-
 +
 +
| '''Summary'''
 +
| Returns the number of interior rings in the given polygon {{Code|$geometry}}.
 +
|-
 +
| '''Errors'''
 +
|{{Error|GEO0001|#Errors}} the given element(s) is not recognized as a valid geometry (QName).<br />{{Error|GEO0002|#Errors}} the given element cannot be read by reader for some reason.<br />{{Error|GEO0003|#Errors}} the given element has to be a polygon. Other geometries are not accepted.<br />
 +
|}
 +
 +
 +
 +
==geo:interiorRingN==
 +
{| width='100%'
 +
|-
 +
| width='90' | '''Signatures'''
 +
|{{Func|geo:interiorRingN|$polygon as element(*)|element(gml:LineString)}}
 +
|-
 +
 +
| '''Summary'''
 +
| Returns the outer ring of the given polygon {{Code|$geometry}}, as a gml:LineString.
 +
|-
 +
| '''Errors'''
 +
|{{Error|GEO0001|#Errors}} the given element(s) is not recognized as a valid geometry (QName).<br />{{Error|GEO0002|#Errors}} the given element cannot be read by reader for some reason.<br />{{Error|GEO0003|#Errors}} the given element has to be a polygon. Other geometries are not accepted.<br />{{Error|GEO0006|#Errors}} the the input index  of geometry is out of range.<br />{{Error|GEO0008|#Errors}} the output object cannot be written as an element by writer for some reason.<br />
 
|}
 
|}

Revision as of 21:29, 5 January 2013

Geo Module adds the support of ExPath Geo Module for GML 2 to BaseX. Based on JTS, GML 2 queris are parsed and evaluated to show in the BaseX frontend.

General Functions

geo:dimension

Signatures geo:dimension($geometry as element(*)) as xs:integer()
Summary Returns the dimension of the given geometry $geometry.
Errors GEO0001: the given element is not recognized as a valid geometry.
GEO0002: the given element cannot be read by reader for some reason.


geo:geometryType

Signatures geo:geometryType($geometry as element(*)) as xs:QName()?
Summary Returns the name of the geometry type of given geometry $geometry or an empty sequence, if the geometry is not recognized with an error massage .
Errors GEO0001: the given element is not recognized as a valid geometry.
GEO0002: the given element cannot be read by reader for some reason.


geo:envelope

Signatures geo:envelope($geometry as element(*)) as xs:element(gml:Envelope)?
Summary Returns the gml:Envelope of the given geometry $geometry. The envelope is the minimum bounding box of this geometry
Errors GEO0001: the given element is not recognized as a valid geometry.
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.


geo:asText

Signatures geo:asText($geometry as element(*)) as xs:string
Summary Returns the WKT (Well-known Text) representation of the given geometry $geometry. The envelope is the minimum bounding box of this geometry
Errors GEO0001: the given element is not recognized as a valid geometry.
GEO0002: the given element cannot be read by reader for some reason.


geo:asBinary

Signatures geo:asBinary($geometry as element(*)) as xs:base64Binary
Summary Returns the WKB (Well-known Binary) representation of the given geometry $geometry.
Errors GEO0001: the given element is not recognized as a valid geometry.
GEO0002: the given element cannot be read by reader for some reason.


geo:isEmpty

Signatures geo:isEmpty($geometry as element(*)) as xs:boolean
Summary Returns whether the given geometry is empty $geometry.
Errors GEO0001: the given element is not recognized as a valid geometry.
GEO0002: the given element cannot be read by reader for some reason.


geo:isSimple

Signatures geo:isSimple($geometry as element(*)) as xs:boolean
Summary Returns whether the given geometry is simple $geometry and does not have has no anomalous geometric points (ie. the geometry does not self-intersect and does not pass through the same point more than once (may be a ring)).
Errors GEO0001: the given element is not recognized as a valid geometry.
GEO0002: the given element cannot be read by reader for some reason.



geo:boundary

Signatures geo:boundary($geometry as element(*)) as xs:element(*)*
Summary Returns the boundary of the given geometry $geometry, in GML 2. The return value is a sequence of either gml:Point or gml:LinearRing elements as a GeometryCollection object. For a Point or MultiPoint, the boundary is the empty geometry, nothing is returned.
Errors GEO0001: the given element is not recognized as a valid geometry.
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.


Spatial Predicate Functions

geo:isEqual

Signatures geo:isEqual($geometry1 as element(*), $geometry2 as element(*)) as xs:boolean
Summary Returns whether geometry1 $geometry1 is spatially equal to $geometry2 $geometry2.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.


geo:disjoint

Signatures geo:disjoint($geometry1 as element(*), $geometry2 as element(*)) as xs:boolean
Summary Returns whether geometry1 $geometry1 is spatially disjoint from $geometry2 $geometry2 (they have no point in common, they do not intersect each other, and the DE-9IM Intersection Matrix for the two geometries is FF*FF****).
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.


geo:intersects

Signatures geo:intersects($geometry1 as element(*), $geometry2 as element(*)) as xs:boolean
Summary Returns whether geometry1 $geometry1 is spatially intersects $geometry2 $geometry2. This is true if disjoint function of the two geometries returns false.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.


geo:touches

Signatures geo:touches($geometry1 as element(*), $geometry2 as element(*)) as xs:boolean
Summary Returns whether geometry1 $geometry1 is spatially touches $geometry2 $geometry2.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.



geo:crosses

Signatures geo:crosses($geometry1 as element(*), $geometry2 as element(*)) as xs:boolean
Summary Returns whether geometry1 $geometry1 is spatially crosses $geometry2 $geometry2. It means, 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).

Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.



geo:within

Signatures geo:within($geometry1 as element(*), $geometry2 as element(*)) as xs:boolean
Summary Returns whether geometry1 $geometry1 is spatially within $geometry2 $geometry2.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.



geo:contains

Signatures geo:contains($geometry1 as element(*), $geometry2 as element(*)) as xs:boolean
Summary Returns whether geometry1 $geometry1 is spatially contains $geometry2 $geometry2. Returns true if within function of these two geometries also returns true.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.



geo:overlaps

Signatures geo:overlaps($geometry1 as element(*), $geometry2 as element(*)) as xs:boolean
Summary Returns whether geometry1 $geometry1 is spatially overlaps $geometry2 $geometry2.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.



geo:relate

Signatures geo:relate($geometry1 as element(*), $geometry2 as element(*), $intersectionMatrix as xs:string) as xs:boolean
Summary Returns whether relationships between the boundaries, interiors and exteriors of geometry1 $geometry1 and geometry2 $geometry2 match the pattern specified in intersectionMatrix $geometry2, which should have the length of 9 charachters.
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)

Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.


Analysis Functions

geo:distance

Signatures geo:distance($geometry1 as element(*), $geometry2 as element(*)) as xs:double
Summary Returns the shortest distance, in the units of the spatial reference system of geometry1 $geometry1, between the geometries, where that distance is the distance between a point on each of the geometries.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.


geo:buffer

Signatures geo:buffer($geometry as element(*), $distance as xs:double) as xs:double
Summary Returns a sequence of zero or more polygonal geometries representing the buffer by distance $distance of geometry $geometry, in the spatial reference system of $geometry.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.


geo:convexHull

Signatures geo:convexHull($geometry as element(*)) as element(*)
Summary Returns the convex hull geometry of the given geometry $geometry in GML, or the empty sequence. Actually returns the object of smallest dimension possible.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.


geo:intersection

Signatures geo:intersection($geometry1 as element(*), $geometry2 as element(*)) as element(*)?
Summary Returns the intersection geometry of geometry1 $geometry1 with geometry2 $geometry2, in GML or empty sequence if there is no intersection of these geometries.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.



geo:union

Signatures geo:union($geometry1 as element(*), $geometry2 as element(*)) as element(*)
Summary Returns the union geometry of geometry1 $geometry1 with geometry2 $geometry2, in GML.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.


geo:difference

Signatures geo:difference($geometry1 as element(*), $geometry2 as element(*)) as element(*)?
Summary Returns the difference geometry of geometry1 $geometry1 with geometry2 $geometry2, in GML, or empty sequence if the difference is empty, as a set of point in geometry1 $geometry1 and not included in geometry2 $geometry2.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.


geo:symDifference

Signatures geo:symDifference($geometry1 as element(*), $geometry2 as element(*)) as element(*)?
Summary Returns the symmetric difference geometry of geometry1 $geometry1 with geometry2 $geometry2, in GML, or empty sequence if the difference is empty, as a set of point in one of the geometries and not included in the other.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.


Functions Specific to Geometry Type

geo:numGeometries

Signatures
Summary
Errors


geo:geometryN

Signatures geo:geometryN($geometryCollection as element(*), $geoNumber as xs:integer) as element(*)
Summary Returns the Nth geometry in geometry-collection $geometryCollection, in GML. For the geometries which are not a collection, it returns the geometry if geoNumber $geometryCollection is 1.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0006: the the input index of geometry is out of range.
GEO0008: the output object cannot be written as an element by writer for some reason.


geo:x

Signatures geo:x($point as element(*)) as xs:double
Summary Returns the x coordinate of point $point. A point has to have an x coordinate.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.



geo:y

Signatures geo:y($point as element(*)) as xs:double
Summary Returns the y coordinate of point $point. If the point does not have the y coordinate, NaN will be returned.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.



geo:z

Signatures geo:z($point as element(*)) as xs:double
Summary Returns the z coordinate of point $point. If the point does not have the y coordinate, NaN will be returned.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.


geo:length

Signatures geo:length($geometry as element(*)) as xs:double
Summary Returns the length of the line of the geometry $geometry. If the geometry is a point, zero value will be returned.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.



geo:startPoint

Signatures geo:startPoint($line as element(*)) as element(gml:Point)
Summary Returns the starting point of the given line $line. $line has to be a single line, LineString or LinearRing.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0004: the given element has to be a line. Other geometries are not accepted.


geo:endPoint

Signatures geo:endPoint($line as element(*)) as element(gml:Point)
Summary Returns the ending point of the given line $line. $line has to be a single line, LineString or LinearRing.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0004: the given element has to be a line. Other geometries are not accepted.


geo:isClosed

Signatures geo:isClosed($line as element(*)) as xs:boolean
Summary Returns a boolean value that shows the line $line is a closed loop (start point and end point are the same) or not. $line has to be a line, as a geometry, LineString or LinearRing, and MultiLineString.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0004: the given element has to be a line. Other geometries are not accepted.


geo:isRing

Signatures geo:isRing($line as element(*)) as xs:boolean
Summary Returns a boolean value that shows the line $line is a ring (closed loop and single) or not. $line has to be a single line, as a geometry, LineString or LinearRing.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0004: the given element has to be a line. Other geometries are not accepted.



geo:numPoints

Signatures geo:numPoints($line as element(*)) as xs:integer
Summary Returns integer value of number of the points in the given line $geometry. $line has to be a line, as a geometry, LineString or LinearRing, and MultiLineString.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0004: the given element has to be a line. Other geometries are not accepted.



geo:pointN

Signatures geo:pointN($line as element(*)) as element(gml:Point)
Summary Returns the Nth point in the given line $geometry. $line has to be a single line, as a geometry, LineString or LinearRing.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0004: the given element has to be a line. Other geometries are not accepted.


geo:area

Signatures geo:area($geometry as element(*)) as xs:double
Summary Returns the area of the given geometry $geometry. For points and line the return value will be zero.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.



geo:centroid

Signatures geo:centroid($geometry as element(*)) as element(gml:Point)
Summary Returns the mathematical centroid of the given geometry $geometry, as a gml:Point. Based on the definition, this point is not always on the surface of the geometry $geometry.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.



geo:pointOnSurface

Signatures geo:pointOnSurface($geometry as element(*)) as element(gml:Point)
Summary Returns an interior point on the given geometry $geometry, as a gml:Point. It is guaranteed to be on surface. Otherwise, the point may lie on the boundary of the geometry.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0008: the output object cannot be written as an element by writer for some reason.



geo:exteriorRing

Signatures geo:pointOnSurface($polygon as element(*)) as element(gml:LineString)
Summary Returns the outer ring of the given polygon $geometry, as a gml:LineString.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0003: the given element has to be a polygon. Other geometries are not accepted.
GEO0008: the output object cannot be written as an element by writer for some reason.



geo:numInteriorRing

Signatures geo:numInteriorRing($polygon as element(*)) as xs:integer
Summary Returns the number of interior rings in the given polygon $geometry.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0003: the given element has to be a polygon. Other geometries are not accepted.


geo:interiorRingN

Signatures geo:interiorRingN($polygon as element(*)) as element(gml:LineString)
Summary Returns the outer ring of the given polygon $geometry, as a gml:LineString.
Errors GEO0001: the given element(s) is not recognized as a valid geometry (QName).
GEO0002: the given element cannot be read by reader for some reason.
GEO0003: the given element has to be a polygon. Other geometries are not accepted.
GEO0006: the the input index of geometry is out of range.
GEO0008: the output object cannot be written as an element by writer for some reason.