/src/geos/src/coverage/VertexRingCounter.cpp
Line | Count | Source |
1 | | /********************************************************************** |
2 | | * |
3 | | * GEOS - Geometry Engine Open Source |
4 | | * http://geos.osgeo.org |
5 | | * |
6 | | * Copyright (C) 2022 Paul Ramsey <pramsey@cleverelephant.ca> |
7 | | * Copyright (c) 2022 Martin Davis. |
8 | | * |
9 | | * This is free software; you can redistribute and/or modify it under |
10 | | * the terms of the GNU Lesser General Public Licence as published |
11 | | * by the Free Software Foundation. |
12 | | * See the COPYING file for more information. |
13 | | * |
14 | | **********************************************************************/ |
15 | | |
16 | | #include <geos/coverage/VertexRingCounter.h> |
17 | | |
18 | | #include <geos/geom/Coordinate.h> |
19 | | #include <geos/geom/CoordinateSequence.h> |
20 | | #include <geos/geom/CoordinateSequenceFilter.h> |
21 | | #include <geos/geom/Geometry.h> |
22 | | |
23 | | |
24 | | using geos::geom::Coordinate; |
25 | | using geos::geom::CoordinateSequence; |
26 | | using geos::geom::CoordinateSequenceFilter; |
27 | | using geos::geom::Geometry; |
28 | | |
29 | | |
30 | | namespace geos { |
31 | | namespace coverage { // geos.coverage |
32 | | |
33 | | /* public static */ |
34 | | void |
35 | | VertexRingCounter::count( |
36 | | const std::vector<const Geometry*>& geoms, |
37 | | std::map<Coordinate, std::size_t>& counts) |
38 | 0 | { |
39 | 0 | VertexRingCounter vertextCounter(counts); |
40 | 0 | for (const Geometry* geom : geoms) { |
41 | 0 | geom->apply_ro(vertextCounter); |
42 | 0 | } |
43 | 0 | } |
44 | | |
45 | | |
46 | | /* public */ |
47 | | void |
48 | | VertexRingCounter::filter_ro(const CoordinateSequence& seq, std::size_t i) |
49 | 0 | { |
50 | | //-- for rings don't double-count duplicate endpoint |
51 | 0 | if (seq.isRing() && i == 0) |
52 | 0 | return; |
53 | | |
54 | 0 | const Coordinate& v = seq.getAt(i); |
55 | 0 | auto search = vertexCounts.find(v); |
56 | 0 | std::size_t count = 0; |
57 | 0 | if (search != vertexCounts.end()) { |
58 | 0 | count = search->second; |
59 | 0 | } |
60 | 0 | count++; |
61 | 0 | vertexCounts[v] = count; |
62 | 0 | } |
63 | | |
64 | | |
65 | | } // geos.coverage |
66 | | } // geos |