mid

Geometric functions mid

syntax

  • mid(polygon_data_item)

definition

mid(polygon_data_item) results in a Point Data item with the middle of the polygon_data_item Argument.

description

The middle of a Polygon is determined by selecting a horizontal scan-line that separates 50% of the area of that polygon above and below that scan-line, and on that scan-line, the 50% percentile of a set of evenly distributed points on that scan-line that are within that polygon.

If the scan-line does not contain any points within the polygon (for example on an hourglass-shaped polygon with a zero-sided waist), other scan-lines are tried until a point is found for which point_in_polygon would result in true.

Since GeoDMS 20.25.0 a polygon with a null vertex results in a null point, as it does for Area, Centroid and Centroid_or_mid: it has no area to divide. Such vertices arise, for instance, when a dpoint polygon with a coordinate outside the int32 range is converted to an ipoint unit in millimetres. Before, mid ended the process with an access violation (0xC0000005) when every vertex of a polygon was null, and resulted in the first vertex of the polygon when only some were.

applies to

implementation details:

image

For more info on SelectRow and GetScanPoint, see:

  • https://github.com/ObjectVision/GeoDMS/blob/v13/rtc/dll/src/geo/SelectPoint.h
  • https://github.com/ObjectVision/GeoDMS/blob/v13/rtc/dll/src/geo/CalcWidth.h