GEOS  3.11.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 #pragma once
22 
23 #include <geos/export.h>
24 #include <geos/geom/Geometry.h> // for inheritance
25 #include <geos/geom/CoordinateSequence.h> // for proper use of unique_ptr<>
26 #include <geos/geom/FixedSizeCoordinateSequence.h>
27 #include <geos/geom/Envelope.h> // for proper use of unique_ptr<>
28 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
29 
30 #include <string>
31 #include <vector>
32 #include <memory> // for unique_ptr
33 
34 #ifdef _MSC_VER
35 #pragma warning(push)
36 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
37 #endif
38 
39 // Forward declarations
40 namespace geos {
41 namespace geom { // geos::geom
42 class Coordinate;
43 class CoordinateArraySequence;
44 class CoordinateFilter;
45 class CoordinateSequenceFilter;
46 class GeometryComponentFilter;
47 class GeometryFilter;
48 }
49 }
50 
51 namespace geos {
52 namespace geom { // geos::geom
53 
63 class GEOS_DLL Point : public Geometry {
64 
65 public:
66 
67  friend class GeometryFactory;
68 
70  typedef std::vector<const Point*> ConstVect;
71 
72  ~Point() override = default;
73 
80  std::unique_ptr<Point> clone() const
81  {
82  return std::unique_ptr<Point>(cloneImpl());
83  }
84 
85  std::unique_ptr<CoordinateSequence> getCoordinates(void) const override;
86 
87  const CoordinateSequence* getCoordinatesRO() const;
88 
89  std::size_t getNumPoints() const override;
90  bool isEmpty() const override;
91  bool isSimple() const override;
92 
94  Dimension::DimensionType getDimension() const override;
95 
97  uint8_t getCoordinateDimension() const override;
98 
100  int getBoundaryDimension() const override;
101 
110  std::unique_ptr<Geometry> getBoundary() const override;
111 
112  double getX() const;
113  double getY() const;
114  double getZ() const;
115  const Coordinate* getCoordinate() const override;
116  std::string getGeometryType() const override;
117  GeometryTypeId getGeometryTypeId() const override;
118  void apply_ro(CoordinateFilter* filter) const override;
119  void apply_rw(const CoordinateFilter* filter) override;
120  void apply_ro(GeometryFilter* filter) const override;
121  void apply_rw(GeometryFilter* filter) override;
122  void apply_rw(GeometryComponentFilter* filter) override;
123  void apply_ro(GeometryComponentFilter* filter) const override;
124  void apply_rw(CoordinateSequenceFilter& filter) override;
125  void apply_ro(CoordinateSequenceFilter& filter) const override;
126 
127  bool equalsExact(const Geometry* other, double tolerance = 0) const override;
128 
129  void
130  normalize(void) override
131  {
132  // a Point is always in normalized form
133  }
134 
135  std::unique_ptr<Point> reverse() const
136  {
137  return std::unique_ptr<Point>(reverseImpl());
138  }
139 
140 protected:
141 
154  Point(CoordinateSequence* newCoords, const GeometryFactory* newFactory);
155 
156  Point(const Coordinate& c, const GeometryFactory* newFactory);
157 
158  Point(const Point& p);
159 
160  Point* cloneImpl() const override { return new Point(*this); }
161 
162  Point* reverseImpl() const override { return new Point(*this); }
163 
164  Envelope::Ptr computeEnvelopeInternal() const override;
165 
166  int compareToSameClass(const Geometry* p) const override;
167 
168  int
169  getSortIndex() const override
170  {
171  return SORTINDEX_POINT;
172  };
173 
174 private:
175 
179  FixedSizeCoordinateSequence<1> coordinates;
180 
181  bool empty2d;
182  bool empty3d;
183 };
184 
185 } // namespace geos::geom
186 } // namespace geos
187 
188 
189 #ifdef _MSC_VER
190 #pragma warning(pop)
191 #endif
192 
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:45
Point * reverseImpl() const override
Make a geometry with coordinates in reverse order.
Definition: Point.h:162
std::unique_ptr< Point > clone() const
Definition: Point.h:80
std::vector< const Point * > ConstVect
A vector of const Point pointers.
Definition: Point.h:70
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition: CoordinateSequenceFilter.h:55
GeometryTypeId
Geometry types.
Definition: Geometry.h:73
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:41
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
void normalize(void) override
Definition: Point.h:130
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25
Point * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition: Point.h:160
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
Definition: Point.h:63
DimensionType
Definition: Dimension.h:29
Definition: GeometryComponentFilter.h:41