Point.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
* Copyright (C) 2001-2002 Vivid Solutions Inc.
* Copyright (C) 2005 2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: geom/Point.java r320 (JTS-1.12)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Geometry.h> // for inheritance
#include <geos/geom/CoordinateSequence.h> // for proper use of unique_ptr<>
#include <geos/geom/Envelope.h> // for proper use of unique_ptr<>
#include <geos/geom/Dimension.h> // for Dimension::DimensionType
#include <string>
#include <vector>
#include <memory> // for unique_ptr
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom { // geos::geom
class Coordinate;
class CoordinateFilter;
class CoordinateSequenceFilter;
class GeometryComponentFilter;
class GeometryFilter;
}
}
namespace geos {
namespace geom { // geos::geom
class GEOS_DLL Point : public Geometry {
public:
friend class GeometryFactory;
typedef std::vector<const Point*> ConstVect;
~Point() override = default;
std::unique_ptr<Point> clone() const
{
return std::unique_ptr<Point>(cloneImpl());
}
std::unique_ptr<CoordinateSequence> getCoordinates(void) const override;
const CoordinateSequence* getCoordinatesRO() const;
std::size_t getNumPoints() const override;
bool isEmpty() const override;
bool isSimple() const override;
Dimension::DimensionType getDimension() const override;
uint8_t getCoordinateDimension() const override;
bool hasM() const override;
bool hasZ() const override;
int getBoundaryDimension() const override;
std::unique_ptr<Geometry> getBoundary() const override;
void setXY(double x, double y) {
if (isEmpty()) {
coordinates.add(x, y);
} else {
CoordinateXY& prev = coordinates.front<CoordinateXY>();
prev.x = x;
prev.y = y;
}
geometryChangedAction();
}
const CoordinateXY* getCoordinate() const override {
return isEmpty() ? nullptr : &coordinates.getAt<CoordinateXY>(0);
}
double getX() const;
double getY() const;
double getZ() const;
double getM() const;
std::string getGeometryType() const override;
GeometryTypeId getGeometryTypeId() const override;
void apply_ro(CoordinateFilter* filter) const override;
void apply_rw(const CoordinateFilter* filter) override;
void apply_ro(GeometryFilter* filter) const override;
void apply_rw(GeometryFilter* filter) override;
void apply_rw(GeometryComponentFilter* filter) override;
void apply_ro(GeometryComponentFilter* filter) const override;
void apply_rw(CoordinateSequenceFilter& filter) override;
void apply_ro(CoordinateSequenceFilter& filter) const override;
bool equalsExact(const Geometry* other, double tolerance = 0) const override;
bool equalsIdentical(const Geometry* other) const override;
void
normalize(void) override
{
// a Point is always in normalized form
}
std::unique_ptr<Point> reverse() const
{
return std::unique_ptr<Point>(reverseImpl());
}
const Envelope* getEnvelopeInternal() const override {
return &envelope;
}
protected:
Point(CoordinateSequence&& newCoords, const GeometryFactory* newFactory);
Point(const Coordinate& c, const GeometryFactory* newFactory);
Point(const CoordinateXY& c, const GeometryFactory* newFactory);
Point(const CoordinateXYM& c, const GeometryFactory* newFactory);
Point(const CoordinateXYZM& c, const GeometryFactory* newFactory);
Point(const Point& p);
Point* cloneImpl() const override { return new Point(*this); }
Point* reverseImpl() const override { return new Point(*this); }
Envelope computeEnvelopeInternal() const;
int compareToSameClass(const Geometry* p) const override;
int
getSortIndex() const override
{
return SORTINDEX_POINT;
};
void geometryChangedAction() override {
envelope = computeEnvelopeInternal();
}
private:
CoordinateSequence coordinates;
Envelope envelope;
};
} // namespace geos::geom
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::geom::CoordinateFilter
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition CoordinateFilter.h:43
geos::geom::CoordinateSequenceFilter
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition CoordinateSequenceFilter.h:56
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Dimension::DimensionType
DimensionType
Definition Dimension.h:29
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::GeometryComponentFilter
Definition GeometryComponentFilter.h:41
geos::geom::GeometryFilter
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition GeometryFilter.h:45
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::Point::getGeometryType
std::string getGeometryType() const override
Return a string representation of this Geometry type.
geos::geom::Point::getCoordinate
const CoordinateXY * getCoordinate() const override
Returns a vertex of this Geometry, or NULL if this is the empty geometry.
Definition Point.h:125
geos::geom::Point::reverseImpl
Point * reverseImpl() const override
Make a geometry with coordinates in reverse order.
Definition Point.h:192
geos::geom::Point::ConstVect
std::vector< const Point * > ConstVect
A vector of const Point pointers.
Definition Point.h:68
geos::geom::Point::clone
std::unique_ptr< Point > clone() const
Definition Point.h:78
geos::geom::Point::cloneImpl
Point * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition Point.h:190
geos::geom::Point::getNumPoints
std::size_t getNumPoints() const override
Returns the count of this Geometrys vertices.
geos::geom::Point::apply_ro
void apply_ro(CoordinateSequenceFilter &filter) const override
geos::geom::Point::Point
Point(CoordinateSequence &&newCoords, const GeometryFactory *newFactory)
Creates a Point taking ownership of the given CoordinateSequence (must have 1 element).
geos::geom::Point::normalize
void normalize(void) override
Definition Point.h:150
geos::geom::Point::getDimension
Dimension::DimensionType getDimension() const override
Returns point dimension (0).
geos::geom::Point::getEnvelopeInternal
const Envelope * getEnvelopeInternal() const override
Returns the minimum and maximum x and y values in this Geometry, or a null Envelope if this Geometry ...
Definition Point.h:160
geos::geom::Point::apply_rw
void apply_rw(CoordinateSequenceFilter &filter) override
geos::geom::Point::getBoundary
std::unique_ptr< Geometry > getBoundary() const override
geos::geom::Point::equalsExact
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...
geos::geom::Point::getBoundaryDimension
int getBoundaryDimension() const override
Returns Dimension::False (Point has no boundary).
geos::geom::Point::geometryChangedAction
void geometryChangedAction() override
Notifies this Geometry that its Coordinates have been changed by an external party.
Definition Point.h:204
geos::geom::Point::equalsIdentical
bool equalsIdentical(const Geometry *other) const override
Returns true if the two geometries are of the same type and their vertices corresponding by index are...
geos::geom::Point::isSimple
bool isSimple() const override
Returns false if the Geometry not simple.
geos::geom::Point::getCoordinates
std::unique_ptr< CoordinateSequence > getCoordinates(void) const override
Returns this Geometry vertices. Caller takes ownership of the returned object.
geos::geom::Point::isEmpty
bool isEmpty() const override
Returns whether or not the set of points in this Geometry is empty.
geos::geom::Point::getCoordinateDimension
uint8_t getCoordinateDimension() const override
Returns coordinate dimension.
geos::geom::Point::getGeometryTypeId
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
geos::geom
Definition Angle.h:26
geos::geom::GeometryTypeId
GeometryTypeId
Geometry types.
Definition Geometry.h:73
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38