GEOS  3.11.0beta2
BasicSegmentString.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2009 Sandro Santilli <strk@kbt.io>
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  * Last port: noding/BasicSegmentString.java rev. 1.1 (JTS-1.9)
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 #include <geos/noding/BasicSegmentString.h>
23 #include <geos/noding/Octant.h>
24 #include <geos/noding/SegmentString.h> // for inheritance
25 #include <geos/geom/CoordinateSequence.h> // for inlines (size())
26 
27 
28 #include <vector>
29 
30 // Forward declarations
31 
32 namespace geos {
33 namespace noding { // geos.noding
34 
44 class GEOS_DLL BasicSegmentString : public SegmentString {
45 
46 public:
47 
54  const void* newContext)
55  :
56  SegmentString(newContext),
57  pts(newPts)
58  {}
59 
60  ~BasicSegmentString() override
61  {}
62 
63  // see dox in SegmentString.h
64  size_t
65  size() const override
66  {
67  return pts->size();
68  }
69 
70  // see dox in SegmentString.h
71  const geom::Coordinate& getCoordinate(std::size_t i) const override
72  {
73  return pts->getAt(i);
74  };
75 
78  {
79  return pts;
80  };
81 
82  // see dox in SegmentString.h
83  bool isClosed() const override
84  {
85  return pts->getAt(0) == pts->getAt(size() - 1);
86  };
87 
88  // see dox in SegmentString.h
89  std::ostream& print(std::ostream& os) const override;
90 
98  int getSegmentOctant(std::size_t index) const
99  {
100  if(index >= size() - 1) {
101  return -1;
102  }
103  return Octant::octant(getCoordinate(index), getCoordinate(index + 1));
104  };
105 
106 private:
107 
109 
110  // Declare type as noncopyable
111  BasicSegmentString(const BasicSegmentString& other) = delete;
112  BasicSegmentString& operator=(const BasicSegmentString& rhs) = delete;
113 
114 };
115 
116 } // namespace geos.noding
117 } // namespace geos
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
virtual const Coordinate & getAt(std::size_t i) const =0
Returns a read-only reference to Coordinate at position i.
Represents a list of contiguous line segments, and supports noding the segments.
Definition: BasicSegmentString.h:44
int getSegmentOctant(std::size_t index) const
Gets the octant of the segment starting at vertex index.
Definition: BasicSegmentString.h:98
BasicSegmentString(geom::CoordinateSequence *newPts, const void *newContext)
Construct a BasicSegmentString.
Definition: BasicSegmentString.h:53
geom::CoordinateSequence * getCoordinates() const override
Definition: BasicSegmentString.h:77
static int octant(double dx, double dy)
An interface for classes which represent a sequence of contiguous line segments.
Definition: SegmentString.h:45
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25