geo.circlePolygon

```geo.circlePolygon(
circle as cts.circle,
arc-tolerance as Number,
[options as String[]]
) as cts.region```

Summary

Construct a polygon approximating a circle.

Parameters
circle A cts circle that defines the circle to be approximated.
arc-tolerance How far the approximation can be from the actual circle, specified in the same units as the `units` option. Arc-tolerance should be greater than the value of the `tolerance` option.
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.
"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. Tolerance should be smaller than the value of the `arc-tolerance` parameter.

Usage Notes

When approximating the polygon, if the distance between two points is less than `tolerance`, then they are considered to be the same point. The `arc-tolerance` parameter specifies the allowable error in the polygon approximation. That is, the resulting polygon will differ from the provided circle by at most `arc-tolerance`.

The `arc-tolerance` parameter value must be greater than the tolerance, and both `arc-tolerance` and `tolerance` should be expressed in the same units. For example, if the `units` option is set to "km" and you're using a geodetic coordinate system, then `arc-tolerance` and `tolerance` (if specified) should also be in kilometers. The default tolerance is 0.05km (or the equivalent in other units). Use the `tolerance` option to override the default.

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.

It is recommended to use this function for queries, as circle geometry matching cannot be optimized. Convert circles to polygons before passing them in as arguments to your queries to get better performance. A common question to ask is 'what points do I have in my database that are within 10 kilometers of point `A`?' This function provides an optimized path for this query.

Example

```geo.circlePolygon(cts.circle(7,cts.point(10,20)),4, ["tolerance=1"]);

// => A cts.region with the following coordinates:
//    10.10185,20 10.050913,20.088997 9.9490623,20.08897 9.8981495,20
//    9.9490623,19.91103 10.050913,19.911001 10.10185,20
```

Example

```// Optic example using the Value Processing Function op.geo.intersects() and geo.circlePolygon()
// circlePolygonLit is a polygon representing a 10 kilometer radius around Tucson, Arizona, US
const op = require('/MarkLogic/optic');
var circlePolygonLit = geo.circlePolygon(cts.circle(10,cts.point('POINT(-110.97345746274591 32.213051181896034)')),0.01,['tolerance=0.001','units=km'])
const result=op.fromView('buildings', 'builds')
.where(op.geo.intersects(op.col('poly'),circlePolygonLit))
.select([op.col('name'), op.col('geoid')])
.orderBy('geoid')
.result()
result;
// ==>
// rows representing names and geoids where values in the 'poly' column INTERSECT circlePolygonLit
```

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