Coverage Report

Created: 2026-05-30 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/s2geometry/src/s2/s2polyline_measures.cc
Line
Count
Source
1
// Copyright 2018 Google Inc. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS-IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
//
15
16
// Author: ericv@google.com (Eric Veach)
17
18
#include "s2/s2polyline_measures.h"
19
20
#include "absl/types/span.h"
21
#include "s2/s1angle.h"
22
#include "s2/s2centroids.h"
23
#include "s2/s2point.h"
24
#include "s2/s2point_span.h"
25
26
namespace S2 {
27
28
0
S1Angle GetLength(S2PointSpan polyline) {
29
0
  S1Angle length;
30
0
  for (size_t i = 1; i < polyline.size(); ++i) {
31
0
    length += S1Angle(polyline[i - 1], polyline[i]);
32
0
  }
33
0
  return length;
34
0
}
35
36
0
S2Point GetCentroid(S2PointSpan polyline) {
37
0
  S2Point centroid;
38
0
  for (size_t i = 1; i < polyline.size(); ++i) {
39
0
    centroid += S2::TrueCentroid(polyline[i - 1], polyline[i]);
40
0
  }
41
0
  return centroid;
42
0
}
43
44
}  // namespace S2