Loading TOC...

geo.equals

geo.equals(
   region-1 as cts.region,
   region-2 as cts.region,
   [options as String[]]
) as Boolean

Summary

Compares geospatial regions to see if they fulfill the 'equals' DE-9IM relation.

Parameters
region-1 The first geospatial region to compare. This region is the left operand of equals.
region-2 The second geospatial region to compare. This region is the right operand of equals.
options Options to this operation. The default is (). Available options:
"coordinate-system=string"
Use the given coordinate system. Valid values are:
wgs84
The WGS84 coordinate system with degrees as the angular unit.
wgs84/radians
The WGS84 coordinate system with radians as the angular unit.
wgs84/double
The WGS84 coordinate system at double precision with degrees as the angular unit.
wgs84/radians/double
The WGS84 coordinate system at double precision with radians as the angular unit.
etrs89
The ETRS89 coordinate system.
etrs89/double
The ETRS89 coordinate system at double precision.
raw
The raw (unmapped) coordinate system.
raw/double
The raw coordinate system at double precision.
"precision=value"
Use the coordinate system at the given precision. Allowed values: float and double.
"units=value"
Measure distance, radii of circles, and tolerance in the specified units. Allowed values: miles (default), km, feet, meters.
"tolerance=distance"
Tolerance is the largest allowable variation in geometry calculations. If the distance between two points is less than tolerance, then the two points are considered equal. For the raw coordinate system, use the units of the coordinates. For geographic coordinate systems, use the units specified by the units option.

Usage Notes

This function determines whether the two regions R1=region-1 and R2=region-2 satisfy the relationship R1 equals R2.

The operations are defined by the Dimensionally Extended nine-Intersection Model (DE-9IM) of spatial relations.

The value of the precision option takes precedence over that implied by the governing coordinate system name, including the value of the coordinate-system option. For example, if the governing coordinate system is "wgs84/double" and the precision option is "float", then the operation uses single precision. If region-1 or region-2 is a column, the column's coordinate system will take precedence over the coordinate-system option. If both region-1 and region-2 are columns, the query will run unoptimized. Queries with one region column and a region literal will be optimized.

See Also

Example

const r1 = cts.polygon('POLYGON((-122.427520751953 37.6555576956251,-122.459106445313 37.5658069549294,-122.289505004883 37.5946477878735,-122.427520751953 37.6555576956251))');
const r2 = cts.polygon('POLYGON((-122.427520751953 37.6555576956251,-122.459106445313 37.5658069549294,-122.289505004883 37.5946477878735,-122.427520751953 37.6555576956251))');
geo.equals(r2,r1,['coordinate-system=wgs84','precision=double'])

// returns true
  

Example

// Optic example using the Value Processing Function op.geo.equals()
const op = require('/MarkLogic/optic');
var pointLit =
    `POINT(-92.837486 34.438328)`
const result=op.fromView('buildings', 'builds')
               .where(op.geo.equals(op.col('interiorPoint'),pointLit))
               .select([op.col('name'), op.col('geoid')])
               .orderBy('geoid')
               .result()
result;
// ==>
// rows representing names and geoids where the 'interiorPoint' column is EQUAL to pointLit
  

Example

'use strict';
// SQL example using the ST_Equals function
const literal = 
  {"pointLit": 
      `POINT(-92.837486 34.438328)`}

var result = xdmp.sql('select * from builds where ST_Equals(interiorPoint,@pointLit) order by geoid limit 20', null, literal);

result;
// ==>
// returns rows whose 'interiorPoint' column match the DE-9IM relationship EQUALS with the provided WKT polygon
  

Example

'use strict';
const op = require('/MarkLogic/optic');
// GeoSPARQL example using geof:sfEquals()
var literal = 
{
  interiorPoint: 
    'POINT(-92.837486 34.438328)'
}

var query = 
`
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geoml: <http://marklogic.com/geospatial#>
PREFIX cts: <http://marklogic.com/cts#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
 
SELECT *
WHERE { ?s my:hasExactGeometry ?o
  FILTER geof:sfEquals(?o, ?interiorPoint, 'coordinate-system=wgs84')
}
ORDER BY ?s`

sem.sparql(query,literal)
// ==>
// rows representing geometries in a triple's object in the wgs84 coordinate system
// that fulfill the EQUALS DE-9IM relation with the WKT point 'interiorPoint', ordered by subject
  

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