GEOS  3.9.0dev
Point.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  * Copyright (C) 2005 2006 Refractions Research Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: geom/Point.java r320 (JTS-1.12)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_GEOS_POINT_H
22 #define GEOS_GEOS_POINT_H
23 
24 #include <geos/export.h>
25 #include <geos/geom/Geometry.h> // for inheritance
26 #include <geos/geom/CoordinateSequence.h> // for proper use of unique_ptr<>
27 #include <geos/geom/FixedSizeCoordinateSequence.h>
28 #include <geos/geom/Envelope.h> // for proper use of unique_ptr<>
29 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
30 
31 #include <geos/inline.h>
32 
33 #include <string>
34 #include <vector>
35 #include <memory> // for unique_ptr
36 
37 #ifdef _MSC_VER
38 #pragma warning(push)
39 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
40 #endif
41 
42 // Forward declarations
43 namespace geos {
44 namespace geom { // geos::geom
45 class Coordinate;
46 class CoordinateArraySequence;
47 class CoordinateFilter;
48 class CoordinateSequenceFilter;
49 class GeometryComponentFilter;
50 class GeometryFilter;
51 }
52 }
53 
54 namespace geos {
55 namespace geom { // geos::geom
56 
66 class GEOS_DLL Point : public Geometry {
67 
68 public:
69 
70  friend class GeometryFactory;
71 
73  typedef std::vector<const Point*> ConstVect;
74 
75  ~Point() override = default;
76 
83  std::unique_ptr<Geometry>
84  clone() const override
85  {
86  return std::unique_ptr<Geometry>(new Point(*this));
87  }
88 
89  std::unique_ptr<CoordinateSequence> getCoordinates(void) const override;
90 
91  const CoordinateSequence* getCoordinatesRO() const;
92 
93  size_t getNumPoints() const override;
94  bool isEmpty() const override;
95  bool isSimple() const override;
96 
98  Dimension::DimensionType getDimension() const override;
99 
101  int getCoordinateDimension() const override;
102 
104  int getBoundaryDimension() const override;
105 
114  std::unique_ptr<Geometry> getBoundary() const override;
115 
116  double getX() const;
117  double getY() const;
118  double getZ() const;
119  const Coordinate* getCoordinate() const override;
120  std::string getGeometryType() const override;
121  GeometryTypeId getGeometryTypeId() const override;
122  void apply_ro(CoordinateFilter* filter) const override;
123  void apply_rw(const CoordinateFilter* filter) override;
124  void apply_ro(GeometryFilter* filter) const override;
125  void apply_rw(GeometryFilter* filter) override;
126  void apply_rw(GeometryComponentFilter* filter) override;
127  void apply_ro(GeometryComponentFilter* filter) const override;
128  void apply_rw(CoordinateSequenceFilter& filter) override;
129  void apply_ro(CoordinateSequenceFilter& filter) const override;
130 
131  bool equalsExact(const Geometry* other, double tolerance = 0) const override;
132 
133  void
134  normalize(void) override
135  {
136  // a Point is always in normalized form
137  }
138 
139  std::unique_ptr<Geometry>
140  reverse() const override
141  {
142  return clone();
143  }
144 
145 protected:
146 
159  Point(CoordinateSequence* newCoords, const GeometryFactory* newFactory);
160 
161  Point(const Coordinate& c, const GeometryFactory* newFactory);
162 
163  Point(const Point& p);
164 
165  Envelope::Ptr computeEnvelopeInternal() const override;
166 
167  int compareToSameClass(const Geometry* p) const override;
168 
169  int
170  getSortIndex() const override
171  {
172  return SORTINDEX_POINT;
173  };
174 
175 private:
176 
180  FixedSizeCoordinateSequence<1> coordinates;
181 
182  bool empty2d;
183  bool empty3d;
184 };
185 
186 } // namespace geos::geom
187 } // namespace geos
188 
189 //#ifdef GEOS_INLINE
190 //# include "geos/geom/Point.inl"
191 //#endif
192 
193 #ifdef _MSC_VER
194 #pragma warning(pop)
195 #endif
196 
197 #endif // ndef GEOS_GEOS_POINT_H
198 
std::unique_ptr< Geometry > reverse() const override
Computes a new geometry which has all component coordinate sequences in reverse order (opposite orien...
Definition: Point.h:140
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
std::vector< const Point * > ConstVect
A vector of const Point pointers.
Definition: Point.h:73
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition: CoordinateSequenceFilter.h:57
GeometryTypeId
Geometry types.
Definition: Geometry.h:75
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:43
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
void normalize(void) override
Definition: Point.h:134
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
std::unique_ptr< Geometry > clone() const override
Definition: Point.h:84
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Definition: Point.h:66
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43