Loading TOC...

MarkLogic 12 EA 2 Product Documentation
geo:box-polygon

geo:box-polygon(
   $box as cts:box,
   [$options as xs:string*]
) as cts:region

Summary

Construct a polygon from a box.

Parameters
box A cts box that defines the polygon to be approximated.
options Options with which you can customize this operation. The following options are available:
"coordinate-system=value"
Use the given coordinate system. Valid values are wgs84, wgs84/double, etrs89, etrs89/double, raw and raw/double. Defaults to the governing coordinating system.
"precision=value"
Use the coordinate system at the given precision. Allowed values: float and double. Defaults to the precision of the governing coordinate system.

Usage Notes

It is recommended to use this function for queries, as box geometry matching cannot be optimized. Convert boxes to polygons before passing them in as arguments to your queries to get better performance.

See Also

Example

xquery version "1.0-ml";
geo:to-wkt(geo:box-polygon(cts:box('[20.719136043990826,-156.8027533606166,20.934773647078917,-157.06917181764786]'),'coordinate-system=wgs84/double'))

(: =>
   POLYGON((-156.802753360617 20.7191360439908,-156.802753360617 20.9347736470789,-157.069171817648 20.9347736470789,-157.069171817648 20.7191360439908,-156.802753360617 20.7191360439908))
:)

Example

xquery version "1.0-ml";
import module namespace op = 'http://marklogic.com/optic' 
           at 'MarkLogic/optic.xqy';
import module namespace ogeo = 'http://marklogic.com/optic/expression/geo' 
           at 'MarkLogic/optic/optic-geo.xqy';

(: Optic example using the Value Processing Function ogeo:intersects() and geo:box-polygon() :)
(: $boxPolygonLit is a polygon representing a rough box around Tucson, Arizona, US :)
let $boxPolygonLit := geo:box-polygon(cts:box(31.95998068725855,-110.74619309278187,32.42948158439288,-111.22959153028187))
let $plan:= op:from-view('buildings', 'builds')
             =>op:where(ogeo:intersects(op:col('poly'),$boxPolygonLit))
             =>op:select(('name', op:col('geoid')))
             =>op:order-by('geoid')

return $plan=>op:result()

(:
==>
rows representing names and geoids of values in the 'poly' column that INTERSECT boxPolygonLit
:)

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.