GEOS  3.13.0dev
LinkedLine.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2021 Paul Ramsey <pramsey@cleverelephant.ca>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************/
14 
15 #pragma once
16 
17 // #include <geos/geom/Coordinate.h>
18 
19 #include <geos/export.h>
20 
21 #include <vector>
22 #include <memory>
23 
24 
25 namespace geos {
26 namespace geom {
27 class Coordinate;
28 class CoordinateSequence;
29 }
30 }
31 
34 
35 
36 namespace geos {
37 namespace simplify { // geos::simplify
38 
39 class LinkedLine
40 {
41 
42 public:
43 
44  LinkedLine(const CoordinateSequence& pts);
45 
46  bool isRing() const;
47  bool isCorner(std::size_t i) const;
48 
49  std::size_t size() const;
50  std::size_t next(std::size_t i) const;
51  std::size_t prev(std::size_t i) const;
52 
53  const Coordinate& getCoordinate(std::size_t index) const;
54  const Coordinate& prevCoordinate(std::size_t index) const;
55  const Coordinate& nextCoordinate(std::size_t index) const;
56 
57  bool hasCoordinate(std::size_t index) const;
58 
59  void remove(std::size_t index);
60 
61  std::unique_ptr<CoordinateSequence> getCoordinates() const;
62 
63 
64 private:
65 
66  // Members
67  const CoordinateSequence& m_coord;
68  bool m_isRing;
69  std::size_t m_size;
70  std::vector<std::size_t> m_next;
71  std::vector<std::size_t> m_prev;
72 
73  void createNextLinks(std::size_t size);
74 
75  void createPrevLinks(std::size_t size);
76 
77 
78 }; // LinkedLine
79 
80 GEOS_DLL std::ostream& operator<< (std::ostream& os, const LinkedLine& ll);
81 
82 
83 } // geos::simplify
84 } // geos
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:216
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25