Geofield Proximity to Polygon

Categories

Component ID

2377125

Component name

Geofield Proximity to Polygon

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

1613

Component created

Component changed

Component body

Geofield Proximity to Polygons for Views

An add-on for the Geofield module to calculate distances from an origin point to polygons and multi-polygons in Views on single-valued and multi-valued Geofields.

Note: if your View only contains Geofield fields that hold single points (as opposed to polygons), then you do not need this module, as Geofield already has built-in proximity fields, filters and sorts for points. It also has a definition for the distance from an origin point to a polygon, but it is different from the rule this module uses.

The module employs the following rule:
if the origin/reference point is inside the polygon or one of the polygons that are part of the multi-polygon or multi-valued field, then zero is returned; otherwise the result is the distance to the closest vertex (corner point).

Automatically converts Geofield proximity fields, filters and sorts to exhibit the above behaviour.

No configuration. Just select as per normal, the Geofield proximity field, filter or sort in your View and the module does the rest.

References

Tip

When you use multi-valued geofields on a map, for example a Leaflet map, under the Multiple Field Settings of the Views UI configuration panel for the field, tick the box Display all values in the same row. When you use mutli-valued geofields in a table and you wish to see distances for each polygon that is part of the geofield, untick that same box.

Suggestions for extensions, roadmap

  • extend module to also include distance calculations to linestrings and multi-linestrings
  • improve algorithm to return distance to closest vertex or edge, whichever is closest
  • point-in-polygon calculation is based on a flat coordinate system of latitude/longitude, but distance calculation takes curvature of the earth into account; address discrepancies that may occur for very wide geometries