GeometryCollection.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* 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/GeometryCollection.java rev. 1.41
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Geometry.h> // for inheritance
#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
// Forward declarations
namespace geos {
namespace geom { // geos::geom
class Coordinate;
class CoordinateSequenceFilter;
}
}
namespace geos {
namespace geom { // geos::geom
class GEOS_DLL GeometryCollection : public Geometry {
public:
friend class GeometryFactory;
typedef std::vector<std::unique_ptr<Geometry>>::const_iterator const_iterator;
typedef std::vector<std::unique_ptr<Geometry>>::iterator iterator;
const_iterator begin() const
{
return geometries.begin();
};
const_iterator end() const
{
return geometries.end();
};
std::unique_ptr<GeometryCollection> clone() const
{
return std::unique_ptr<GeometryCollection>(cloneImpl());
}
~GeometryCollection() override = default;
void setSRID(int) override;
std::unique_ptr<CoordinateSequence> getCoordinates() const override;
bool isEmpty() const override;
Dimension::DimensionType getDimension() const override;
bool hasDimension(Dimension::DimensionType d) const override;
bool isDimensionStrict(Dimension::DimensionType d) const override;
uint8_t getCoordinateDimension() const override;
bool hasM() const override;
bool hasZ() const override;
std::unique_ptr<Geometry> getBoundary() const override;
int getBoundaryDimension() const override;
std::size_t getNumPoints() const override;
std::string getGeometryType() const override;
GeometryTypeId getGeometryTypeId() const override;
bool equalsExact(const Geometry* other,
double tolerance = 0) const override;
bool equalsIdentical(const Geometry* other) 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_ro(GeometryComponentFilter* filter) const override;
void apply_rw(GeometryComponentFilter* filter) override;
void apply_rw(CoordinateSequenceFilter& filter) override;
void apply_ro(CoordinateSequenceFilter& filter) const override;
void normalize() override;
const CoordinateXY* getCoordinate() const override;
double getArea() const override;
double getLength() const override;
std::size_t getNumGeometries() const override;
const Geometry* getGeometryN(std::size_t n) const override;
std::vector<std::unique_ptr<Geometry>> releaseGeometries();
std::unique_ptr<GeometryCollection> reverse() const { return std::unique_ptr<GeometryCollection>(reverseImpl()); }
const Envelope* getEnvelopeInternal() const override {
if (envelope.isNull()) {
envelope = computeEnvelopeInternal();
}
return &envelope;
}
protected:
struct CollectionFlags {
bool flagsCalculated;
bool hasPoints;
bool hasLines;
bool hasPolygons;
bool hasM;
bool hasZ;
bool hasCurves;
};
GeometryCollection(const GeometryCollection& gc);
GeometryCollection& operator=(const GeometryCollection& gc);
GeometryCollection(std::vector<std::unique_ptr<Geometry>> && newGeoms, const GeometryFactory& newFactory);
template<typename T>
GeometryCollection(std::vector<std::unique_ptr<T>> && newGeoms, const GeometryFactory& newFactory) :
GeometryCollection(toGeometryArray(std::move(newGeoms)), newFactory) {}
GeometryCollection* cloneImpl() const override { return new GeometryCollection(*this); }
GeometryCollection* reverseImpl() const override;
int
getSortIndex() const override
{
return SORTINDEX_GEOMETRYCOLLECTION;
};
std::vector<std::unique_ptr<Geometry>> geometries;
mutable CollectionFlags flags;
mutable Envelope envelope;
Envelope computeEnvelopeInternal() const;
void geometryChangedAction() override {
envelope.setToNull();
}
int compareToSameClass(const Geometry* gc) const override;
bool hasCurvedComponents() const override;
void setFlags() const;
};
} // namespace geos::geom
} // namespace geos
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::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::GeometryCollection
Represents a collection of heterogeneous Geometry objects.
Definition GeometryCollection.h:51
geos::geom::GeometryCollection::setSRID
void setSRID(int) override
Sets the ID of the Spatial Reference System used by the Geometry.
geos::geom::GeometryCollection::isDimensionStrict
bool isDimensionStrict(Dimension::DimensionType d) const override
Checks whether this Geometry consists only of components having dimension d.
geos::geom::GeometryCollection::GeometryCollection
GeometryCollection(std::vector< std::unique_ptr< T > > &&newGeoms, const GeometryFactory &newFactory)
Convenience constructor to build a GeometryCollection from vector of Geometry subclass pointers.
Definition GeometryCollection.h:235
geos::geom::GeometryCollection::getGeometryType
std::string getGeometryType() const override
Return a string representation of this Geometry type.
geos::geom::GeometryCollection::cloneImpl
GeometryCollection * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition GeometryCollection.h:238
geos::geom::GeometryCollection::getGeometryN
const Geometry * getGeometryN(std::size_t n) const override
Returns a pointer to the nth Geometry in this collection.
geos::geom::GeometryCollection::getCoordinateDimension
uint8_t getCoordinateDimension() const override
Returns coordinate dimension.
geos::geom::GeometryCollection::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::GeometryCollection::clone
std::unique_ptr< GeometryCollection > clone() const
Definition GeometryCollection.h:76
geos::geom::GeometryCollection::apply_ro
void apply_ro(CoordinateSequenceFilter &filter) const override
geos::geom::GeometryCollection::hasCurvedComponents
bool hasCurvedComponents() const override
Returns whether the Geometry contains curved components.
geos::geom::GeometryCollection::geometryChangedAction
void geometryChangedAction() override
Notifies this Geometry that its Coordinates have been changed by an external party.
Definition GeometryCollection.h:254
geos::geom::GeometryCollection::getGeometryTypeId
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
geos::geom::GeometryCollection::releaseGeometries
std::vector< std::unique_ptr< Geometry > > releaseGeometries()
Take ownership of the sub-geometries managed by this GeometryCollection. After releasing the sub-geom...
geos::geom::GeometryCollection::getCoordinates
std::unique_ptr< CoordinateSequence > getCoordinates() const override
Collects all coordinates of all subgeometries into a CoordinateSequence.
geos::geom::GeometryCollection::getArea
double getArea() const override
Returns the total area of this collection.
geos::geom::GeometryCollection::getNumPoints
std::size_t getNumPoints() const override
Returns the count of this Geometrys vertices.
geos::geom::GeometryCollection::hasDimension
bool hasDimension(Dimension::DimensionType d) const override
Checks whether any component of this geometry has dimension d.
geos::geom::GeometryCollection::getCoordinate
const CoordinateXY * getCoordinate() const override
Returns a vertex of this Geometry, or NULL if this is the empty geometry.
geos::geom::GeometryCollection::isEmpty
bool isEmpty() const override
Returns whether or not the set of points in this Geometry is empty.
geos::geom::GeometryCollection::getDimension
Dimension::DimensionType getDimension() const override
Returns the maximum dimension of geometries in this collection (0=point, 1=line, 2=surface).
geos::geom::GeometryCollection::getBoundaryDimension
int getBoundaryDimension() const override
Returns the maximum boundary dimension of geometries in this collection.
geos::geom::GeometryCollection::getLength
double getLength() const override
Returns the total length of this collection.
geos::geom::GeometryCollection::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::GeometryCollection::reverseImpl
GeometryCollection * reverseImpl() const override
Make a geometry with coordinates in reverse order.
geos::geom::GeometryCollection::getBoundary
std::unique_ptr< Geometry > getBoundary() const override
Returns the boundary, or an empty geometry of appropriate dimension if this Geometry is empty.
geos::geom::GeometryCollection::getNumGeometries
std::size_t getNumGeometries() const override
Returns the number of geometries in this collection.
geos::geom::GeometryCollection::GeometryCollection
GeometryCollection(std::vector< std::unique_ptr< Geometry > > &&newGeoms, const GeometryFactory &newFactory)
Construct a GeometryCollection with the given GeometryFactory. Will keep a reference to the factory,...
geos::geom::GeometryCollection::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 GeometryCollection.h:192
geos::geom::GeometryCollection::normalize
void normalize() override
geos::geom::GeometryCollection::reverse
std::unique_ptr< GeometryCollection > reverse() const
Definition GeometryCollection.h:190
geos::geom::GeometryCollection::apply_rw
void apply_rw(CoordinateSequenceFilter &filter) override
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
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