@@ -41,7 +41,7 @@ If `weights` is passed, the weighted sum will be returned.
41
41
"""
42
42
function coordsum (points; weights= nothing )
43
43
values = _coordsum (points, weights)
44
- fromvalues (first (points), values)
44
+ _fromvalues (first (points), values)
45
45
end
46
46
47
47
"""
@@ -57,25 +57,43 @@ function coordmean(points; weights=nothing)
57
57
sum (weights)
58
58
end
59
59
values = _coordsum (points, weights) ./ den
60
- fromvalues (first (points), values)
60
+ _fromvalues (first (points), values)
61
61
end
62
62
63
- function tovalues (p)
63
+ """
64
+ coordround(point, r=RoundNearest; digits=0, base=10)
65
+ coordround(point, r=RoundNearest; sigdigits=0)
66
+
67
+ Round the coordinates of a `point` to specified presicion.
68
+ """
69
+ function coordround (point:: Point , r:: RoundingMode = RoundNearest; kwargs... )
70
+ c = coords (point)
71
+ x = CoordRefSystems. values (c)
72
+ x′ = round .(eltype (x), x, r; kwargs... )
73
+ c′ = CoordRefSystems. constructor (c)(x′... )
74
+ Point (c′)
75
+ end
76
+
77
+ # -----------------
78
+ # HELPER FUNCTIONS
79
+ # -----------------
80
+
81
+ function _tovalues (p)
64
82
CRS = _basecrs (manifold (p))
65
83
c = convert (CRS, coords (p))
66
84
CoordRefSystems. values (c)
67
85
end
68
86
69
- function fromvalues (g, values)
87
+ function _fromvalues (g, values)
70
88
CRS = _basecrs (manifold (g))
71
89
withcrs (g, values, CRS)
72
90
end
73
91
74
92
function _coordsum (points, weights)
75
93
if isnothing (weights)
76
- mapreduce (tovalues , .+ , points)
94
+ mapreduce (_tovalues , .+ , points)
77
95
else
78
- mapreduce ((p, w) -> tovalues (p) .* w, .+ , points, weights)
96
+ mapreduce ((p, w) -> _tovalues (p) .* w, .+ , points, weights)
79
97
end
80
98
end
81
99
0 commit comments