1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// src/ops/measure.rs
//! The length of a polygon, and the area and length of a geometry
//! collection.
//!
//! # The conventions
//!
//! - **A collection's measure is the sum over its elements**. A collection
//! imposes no condition between elements, so overlapping elements count
//! twice, and an element repeated is counted again. Where the areal
//! elements are interior-disjoint, the sum *is* the area of their union.
//! - **The length of a polygon is the length of its whole boundary**, every
//! ring, holes included. [`super::perimeter`] remains the exterior alone.
//!
//! # How the sum *is* formed, and what it guarantees
//!
//! Each **component** of a non-collection element contributes one term: a
//! polygon's [`area`](super::area) or [`polygon_length`], a line's
//! [`length`](super::length). A multipart element contributes one term per
//! part, and a point contributes nothing. The terms are added with
//! [`Accum`], in the order [`GeometryCollection::leaves`] visits them, so
//! the result is deterministic, and a collection of one polygon gives
//! exactly that polygon's own value (`Accum` returns a single term
//! unchanged).
//!
//! **Sign.** Every term is non-negative, and for non-negative terms
//! `Σ|tᵢ|` is the exact sum `T`. `Accum`'s bound then reads
//! `|r − T| ≤ (ε + γ_k²)·T`, which is less than `T` for any `k` with
//! `k·ε < ½`. So `r` is zero if and only if `T` is, that is, **if and only
//! if every term is zero**. (The terms are added, not multiplied, so
//! `Accum`'s product-underflow exception does not arise here.) A valid
//! polygon's area is positive (its exact net area is, and the sign is
//! certified), and every ring or line has a positive length, so a
//! collection's area is zero exactly when it has no non-empty areal element,
//! and its length is zero exactly when it has no linear or areal element.
//! The positivity of a polygon's area rests on `ops/area.rs`'s exactness
//! argument, which assumes its products do not underflow; for coordinates
//! below about `2⁻⁴⁸⁴` in magnitude that assumption can fail.
//!
//! **Magnitude.** For the area, with `bᵢ` each polygon's own bound
//! (`ops/area.rs`) and `aᵢ` its computed area, the error of the sum is at
//! most `Σbᵢ + (ε + γ_k²)·Σaᵢ`. For the length the per-term accuracy is
//! measured, not proven ([`super::edge_length`]: `hypot`'s accuracy is the
//! platform's), so the collection's length is measured too; the composition
//! adds at most `(ε + γ_k²)·Σℓᵢ`.
use crateAccum;
use crate;
use ;
/// The length of a polygon's whole boundary: every edge of every ring,
/// holes included, in one compensated sum.
///
/// [`perimeter`](super::perimeter) is the exterior ring alone. The accuracy
/// is that of [`length`]: a compensated sum of `hypot` edge lengths, measured
/// rather than proven. Positive for every polygon (each ring has at least
/// three distinct vertices).
/// The sum of the areas of a collection's polygons, at every depth: each
/// polygon, alone or a part of a multipolygon, is one term of an [`Accum`]
/// sum. Points and lines contribute no area.
///
/// **Overlapping elements count twice**: a collection imposes no condition
/// between its elements. The module documentation gives the sign argument
/// (zero exactly when there is no polygon) and the bound.
/// The sum of the lengths of a collection's lines and polygon boundaries, at
/// every depth: each line is one term ([`length`]) and each polygon one term
/// ([`polygon_length`], every ring). Points contribute nothing.
///
/// **Overlapping elements count twice.** The module documentation gives the
/// sign argument (zero exactly when there is no line or polygon) and the
/// accuracy, which is measured, not proven.