GEOS 3.14.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
25namespace geos {
26namespace geom {
27class Coordinate;
28class CoordinateSequence;
29}
30}
31
32namespace geos {
33namespace simplify { // geos::simplify
34
35class LinkedLine
36{
37 using Coordinate = geos::geom::Coordinate;
38 using CoordinateSequence = geos::geom::CoordinateSequence;
39
40public:
41
42 LinkedLine(const CoordinateSequence& pts);
43
44 bool isRing() const;
45 bool isCorner(std::size_t i) const;
46
47 std::size_t size() const;
48 std::size_t next(std::size_t i) const;
49 std::size_t prev(std::size_t i) const;
50
51 const Coordinate& getCoordinate(std::size_t index) const;
52 const Coordinate& prevCoordinate(std::size_t index) const;
53 const Coordinate& nextCoordinate(std::size_t index) const;
54
55 bool hasCoordinate(std::size_t index) const;
56
57 void remove(std::size_t index);
58
59 std::unique_ptr<CoordinateSequence> getCoordinates() const;
60
61
62private:
63
64 // Members
65 const CoordinateSequence& m_coord;
66 bool m_isRing;
67 std::size_t m_size;
68 std::vector<std::size_t> m_next;
69 std::vector<std::size_t> m_prev;
70
71 void createNextLinks(std::size_t size);
72
73 void createPrevLinks(std::size_t size);
74
75
76}; // LinkedLine
77
78GEOS_DLL std::ostream& operator<< (std::ostream& os, const LinkedLine& ll);
79
80
81} // geos::simplify
82} // 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:217
Basic namespace for all GEOS functionalities.
Definition geos.h:39