GEOS  3.8.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/Envelope.h> // for proper use of unique_ptr<>
28 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
29 
30 #include <geos/inline.h>
31 
32 #include <string>
33 #include <vector>
34 #include <memory> // for unique_ptr
35 
36 #ifdef _MSC_VER
37 #pragma warning(push)
38 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
39 #endif
40 
41 // Forward declarations
42 namespace geos {
43 namespace geom { // geos::geom
44 class Coordinate;
45 class CoordinateArraySequence;
46 class CoordinateFilter;
47 class CoordinateSequenceFilter;
48 class GeometryComponentFilter;
49 class GeometryFilter;
50 }
51 }
52 
53 namespace geos {
54 namespace geom { // geos::geom
55 
65 class GEOS_DLL Point : public Geometry {
66 
67 public:
68 
69  friend class GeometryFactory;
70 
72  typedef std::vector<const Point*> ConstVect;
73 
74  ~Point() override;
75 
82  std::unique_ptr<Geometry>
83  clone() const override
84  {
85  return std::unique_ptr<Geometry>(new Point(*this));
86  }
87 
88  std::unique_ptr<CoordinateSequence> getCoordinates(void) const override;
89 
90  const CoordinateSequence* getCoordinatesRO() const;
91 
92  size_t getNumPoints() const override;
93  bool isEmpty() const override;
94  bool isSimple() const override;
95 
97  Dimension::DimensionType getDimension() const override;
98 
100  int 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<Geometry>
139  reverse() const override
140  {
141  return clone();
142  }
143 
144 protected:
145 
158  Point(CoordinateSequence* newCoords, const GeometryFactory* newFactory);
159 
160  Point(const Point& p);
161 
162  Envelope::Ptr computeEnvelopeInternal() const override;
163 
164  int compareToSameClass(const Geometry* p) const override;
165 
166  int
167  getSortIndex() const override
168  {
169  return SORTINDEX_POINT;
170  };
171 
172 private:
173 
177  std::unique_ptr<CoordinateSequence> coordinates;
178 };
179 
180 } // namespace geos::geom
181 } // namespace geos
182 
183 //#ifdef GEOS_INLINE
184 //# include "geos/geom/Point.inl"
185 //#endif
186 
187 #ifdef _MSC_VER
188 #pragma warning(pop)
189 #endif
190 
191 #endif // ndef GEOS_GEOS_POINT_H
192 
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:139
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:72
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:66
void normalize(void) override
Converts this Geometry to normal form (or canonical form).
Definition: Point.h:133
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
std::unique_ptr< Geometry > clone() const override
Definition: Point.h:83
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Definition: Point.h:65
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43