MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / count_points

Function count_points

nodedb-query/src/geo_functions.rs:428–444  ·  view source on GitHub ↗
(geom: &nodedb_types::geometry::Geometry)

Source from the content-addressed store, hash-verified

426}
427
428fn count_points(geom: &nodedb_types::geometry::Geometry) -> usize {
429 use nodedb_types::geometry::Geometry;
430 match geom {
431 Geometry::Point { .. } => 1,
432 Geometry::LineString { coordinates } => coordinates.len(),
433 Geometry::Polygon { coordinates } => coordinates.iter().map(|r| r.len()).sum(),
434 Geometry::MultiPoint { coordinates } => coordinates.len(),
435 Geometry::MultiLineString { coordinates } => coordinates.iter().map(|ls| ls.len()).sum(),
436 Geometry::MultiPolygon { coordinates } => coordinates
437 .iter()
438 .flat_map(|poly| poly.iter())
439 .map(|ring| ring.len())
440 .sum(),
441 Geometry::GeometryCollection { geometries } => geometries.iter().map(count_points).sum(),
442 _ => 0,
443 }
444}

Callers 1

eval_geo_functionFunction · 0.85

Calls 3

sumMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected