GEOS 3.9.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
43namespace geos {
44namespace geom { // geos::geom
45class Coordinate;
46class CoordinateArraySequence;
47class CoordinateFilter;
48class CoordinateSequenceFilter;
49class GeometryComponentFilter;
50class GeometryFilter;
51}
52}
53
54namespace geos {
55namespace geom { // geos::geom
56
66class GEOS_DLL Point : public Geometry {
67
68public:
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
99
101 uint8_t 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;
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
145protected:
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
175private:
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
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:43
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition: CoordinateSequenceFilter.h:57
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Definition: Point.h:66
std::string getGeometryType() const override
Return a string representation of this Geometry type.
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
std::vector< const Point * > ConstVect
A vector of const Point pointers.
Definition: Point.h:73
Point(CoordinateSequence *newCoords, const GeometryFactory *newFactory)
Creates a Point taking ownership of the given CoordinateSequence (must have 1 element)
void apply_ro(CoordinateSequenceFilter &filter) const override
void normalize(void) override
Definition: Point.h:134
Dimension::DimensionType getDimension() const override
Returns point dimension (0)
void apply_rw(CoordinateSequenceFilter &filter) override
std::unique_ptr< Geometry > getBoundary() const override
bool equalsExact(const Geometry *other, double tolerance=0) const override
Returns true iff the two Geometrys are of the same type and their vertices corresponding by index are...
std::unique_ptr< Geometry > clone() const override
Definition: Point.h:84
size_t getNumPoints() const override
Returns the count of this Geometrys vertices.
int getBoundaryDimension() const override
Returns Dimension::False (Point has no boundary)
bool isSimple() const override
Returns false if the Geometry not simple.
std::unique_ptr< CoordinateSequence > getCoordinates(void) const override
Returns this Geometry vertices. Caller takes ownership of the returned object.
bool isEmpty() const override
Returns whether or not the set of points in this Geometry is empty.
uint8_t getCoordinateDimension() const override
Returns coordinate dimension.
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
const Coordinate * getCoordinate() const override
Returns a vertex of this Geometry, or NULL if this is the empty geometry.
GeometryTypeId
Geometry types.
Definition: Geometry.h:75
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26