GEOS  3.10.1
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<Point> clone() const
84  {
85  return std::unique_ptr<Point>(cloneImpl());
86  }
87 
88  std::unique_ptr<CoordinateSequence> getCoordinates(void) const override;
89 
90  const CoordinateSequence* getCoordinatesRO() const;
91 
92  std::size_t getNumPoints() const override;
93  bool isEmpty() const override;
94  bool isSimple() const override;
95 
97  Dimension::DimensionType getDimension() const override;
98 
100  uint8_t getCoordinateDimension() const override;
101 
103  int getBoundaryDimension() const override;
104 
113  std::unique_ptr<Geometry> getBoundary() const override;
114 
115  double getX() const;
116  double getY() const;
117  double getZ() const;
118  const Coordinate* getCoordinate() const override;
119  std::string getGeometryType() const override;
120  GeometryTypeId getGeometryTypeId() const override;
121  void apply_ro(CoordinateFilter* filter) const override;
122  void apply_rw(const CoordinateFilter* filter) override;
123  void apply_ro(GeometryFilter* filter) const override;
124  void apply_rw(GeometryFilter* filter) override;
125  void apply_rw(GeometryComponentFilter* filter) override;
126  void apply_ro(GeometryComponentFilter* filter) const override;
127  void apply_rw(CoordinateSequenceFilter& filter) override;
128  void apply_ro(CoordinateSequenceFilter& filter) const override;
129 
130  bool equalsExact(const Geometry* other, double tolerance = 0) const override;
131 
132  void
133  normalize(void) override
134  {
135  // a Point is always in normalized form
136  }
137 
138  std::unique_ptr<Point> reverse() const
139  {
140  return std::unique_ptr<Point>(reverseImpl());
141  }
142 
143 protected:
144 
157  Point(CoordinateSequence* newCoords, const GeometryFactory* newFactory);
158 
159  Point(const Coordinate& c, const GeometryFactory* newFactory);
160 
161  Point(const Point& p);
162 
163  Point* cloneImpl() const override { return new Point(*this); }
164 
165  Point* reverseImpl() const override { return new Point(*this); }
166 
167  Envelope::Ptr computeEnvelopeInternal() const override;
168 
169  int compareToSameClass(const Geometry* p) const override;
170 
171  int
172  getSortIndex() const override
173  {
174  return SORTINDEX_POINT;
175  };
176 
177 private:
178 
182  FixedSizeCoordinateSequence<1> coordinates;
183 
184  bool empty2d;
185  bool empty3d;
186 };
187 
188 } // namespace geos::geom
189 } // namespace geos
190 
191 //#ifdef GEOS_INLINE
192 //# include "geos/geom/Point.inl"
193 //#endif
194 
195 #ifdef _MSC_VER
196 #pragma warning(pop)
197 #endif
198 
199 #endif // ndef GEOS_GEOS_POINT_H
200 
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
Point * reverseImpl() const override
Make a geometry with coordinates in reverse order.
Definition: Point.h:165
std::unique_ptr< Point > clone() const
Definition: Point.h:83
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:133
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26
Point * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition: Point.h:163
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