Skip to content

Commit

Permalink
Reformat files for curved geometry classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed Apr 15, 2024
1 parent d9bee63 commit f30a751
Show file tree
Hide file tree
Showing 14 changed files with 633 additions and 614 deletions.
37 changes: 23 additions & 14 deletions include/geos/geom/CircularString.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,49 @@ class GEOS_DLL CircularString : public SimpleCurve {

GeometryTypeId getGeometryTypeId() const override;

CircularString* cloneImpl() const override
double getLength() const override
{
return new CircularString(*this);
throw util::UnsupportedOperationException("Cannot calculate length of CircularString");
}

CircularString* reverseImpl() const override;

int
getSortIndex() const override
bool hasCurvedComponents() const override
{
return SORTINDEX_LINESTRING;
};

double getLength() const override {
throw util::UnsupportedOperationException("Cannot calculate length of CircularString");
return true;
}

bool hasCurvedComponents() const override {
return true;
std::unique_ptr<CircularString> reverse() const
{
return std::unique_ptr<CircularString>(reverseImpl());
}

protected:

/// \brief
/// Constructs a CircularString taking ownership the
/// given CoordinateSequence.
CircularString(std::unique_ptr<CoordinateSequence> && pts,
CircularString(std::unique_ptr<CoordinateSequence>&& pts,
const GeometryFactory& newFactory);

CircularString* cloneImpl() const override
{
return new CircularString(*this);
}

void geometryChangedAction() override
{
envelope = computeEnvelopeInternal(false);
}

int
getSortIndex() const override
{
return SORTINDEX_LINESTRING;
};

CircularString* reverseImpl() const override;

void validateConstruction();

};


Expand Down
82 changes: 42 additions & 40 deletions include/geos/geom/CompoundCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,91 +24,93 @@ namespace geom {
class GEOS_DLL CompoundCurve : public Curve {
friend class GeometryFactory;


public:
using Curve::apply_ro;
using Curve::apply_rw;

CompoundCurve(const CompoundCurve&);

CompoundCurve& operator=(const CompoundCurve&);

std::unique_ptr<CoordinateSequence> getCoordinates() const override;

const CoordinateXY* getCoordinate() const override;
void apply_ro(CoordinateFilter* filter) const override;

uint8_t getCoordinateDimension() const override;
void apply_ro(CoordinateSequenceFilter& filter) const override;

bool hasZ() const override;
void apply_rw(CoordinateSequenceFilter& filter) override;

bool hasM() const override;
void apply_rw(const CoordinateFilter* filter) override;

bool isEmpty() const override;
int compareToSameClass(const Geometry* geom) const override;

bool isClosed() const override;
std::unique_ptr<CompoundCurve> clone() const;

std::size_t getNumCurves() const;
CompoundCurve* cloneImpl() const override;

const SimpleCurve* getCurveN(std::size_t) const;
bool equalsExact(const Geometry* other, double tolerance = 0)
const override;

std::size_t getNumPoints() const override;
bool equalsIdentical(const Geometry* other) const override;

std::unique_ptr<Geometry> getBoundary() const override;

std::string getGeometryType() const override;
const CoordinateXY* getCoordinate() const override;

GeometryTypeId getGeometryTypeId() const override;
std::unique_ptr<CoordinateSequence> getCoordinates() const override;

bool equalsExact(const Geometry* other, double tolerance = 0)
const override;
uint8_t getCoordinateDimension() const override;

bool equalsIdentical(const Geometry* other) const override;
/// Returns the nth section of the CompoundCurve
const SimpleCurve* getCurveN(std::size_t) const;

const Envelope* getEnvelopeInternal() const override
{
return &envelope;
}

std::unique_ptr<CompoundCurve> clone() const;
std::string getGeometryType() const override;

CompoundCurve* cloneImpl() const override;
GeometryTypeId getGeometryTypeId() const override;

std::unique_ptr<CompoundCurve> reverse() const;
double getLength() const override;

CompoundCurve* reverseImpl() const override;
/// Returns the number of sections in the CompoundCurve
std::size_t getNumCurves() const;

double getLength() const override;
std::size_t getNumPoints() const override;

using Curve::apply_ro;
using Curve::apply_rw;
bool hasCurvedComponents() const override;

void apply_rw(const CoordinateFilter* filter) override;
bool hasM() const override;

void apply_ro(CoordinateFilter* filter) const override;
bool hasZ() const override;

void apply_rw(CoordinateSequenceFilter& filter) override;
bool isClosed() const override;

void apply_ro(CoordinateSequenceFilter& filter) const override;
bool isEmpty() const override;

void normalize() override;

int compareToSameClass(const Geometry* geom) const override;

bool hasCurvedComponents() const override;
std::unique_ptr<CompoundCurve> reverse() const;

protected:
/// Construct a CompoundCurve, taking ownership of the
/// provided CoordinateSequence
CompoundCurve(std::vector<std::unique_ptr<SimpleCurve>>&&,
const GeometryFactory&);

int getSortIndex() const override
{
return SORTINDEX_COMPOUNDCURVE;
}
CompoundCurve(const CompoundCurve&);

CompoundCurve& operator=(const CompoundCurve&);

Envelope computeEnvelopeInternal() const;

void geometryChangedAction() override
{
envelope = computeEnvelopeInternal();
}

Envelope computeEnvelopeInternal() const;
int getSortIndex() const override
{
return SORTINDEX_COMPOUNDCURVE;
}

CompoundCurve* reverseImpl() const override;

private:
std::vector<std::unique_ptr<SimpleCurve>> curves;
Expand Down
2 changes: 2 additions & 0 deletions include/geos/geom/Curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class GEOS_DLL Curve : public Geometry {
return isClosed() ? Dimension::False : 0;
}

/// Returns true if the first and last coordinate in the Curve are the same
virtual bool isClosed() const = 0;

/// Returns true if the curve is closed and simple
bool isRing() const;

using Geometry::apply_ro;
Expand Down
32 changes: 17 additions & 15 deletions include/geos/geom/MultiCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,13 @@ class GEOS_DLL MultiCurve : public GeometryCollection {
public:
~MultiCurve() override = default;

/// Returns line dimension (1)
Dimension::DimensionType getDimension() const override;

bool hasDimension(Dimension::DimensionType d) const override
std::unique_ptr<MultiCurve> clone() const
{
return d == Dimension::L;
}
return std::unique_ptr<MultiCurve>(cloneImpl());
};

bool isDimensionStrict(Dimension::DimensionType d) const override
{
return d == Dimension::L;
}
/// Returns a (possibly empty) [MultiPoint](@ref geom::MultiPoint)
std::unique_ptr<Geometry> getBoundary() const override;

/**
* \brief
Expand All @@ -46,21 +41,28 @@ class GEOS_DLL MultiCurve : public GeometryCollection {
*/
int getBoundaryDimension() const override;

/// Returns a (possibly empty) [MultiPoint](@ref geom::MultiPoint)
std::unique_ptr<Geometry> getBoundary() const override;
/// Returns line dimension (1)
Dimension::DimensionType getDimension() const override;

const Curve* getGeometryN(std::size_t n) const override;

std::string getGeometryType() const override;

GeometryTypeId getGeometryTypeId() const override;

bool hasDimension(Dimension::DimensionType d) const override
{
return d == Dimension::L;
}

/// Returns true if the MultiCurve is not empty, and every included
/// Curve is also closed.
bool isClosed() const;

std::unique_ptr<MultiCurve> clone() const
bool isDimensionStrict(Dimension::DimensionType d) const override
{
return std::unique_ptr<MultiCurve>(cloneImpl());
};
return d == Dimension::L;
}

/**
* Creates a MultiCurve in the reverse
Expand Down
38 changes: 19 additions & 19 deletions include/geos/geom/MultiSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,10 @@ class GEOS_DLL MultiSurface : public GeometryCollection {

~MultiSurface() override;

/// Returns surface dimension (2)
Dimension::DimensionType getDimension() const override;

bool hasDimension(Dimension::DimensionType d) const override
{
return d == Dimension::A;
}

bool isDimensionStrict(Dimension::DimensionType d) const override
std::unique_ptr<MultiSurface> clone() const
{
return d == Dimension::A;
}

/// Returns 1 (MultiSurface boundary is MultiCurve)
int getBoundaryDimension() const override;
return std::unique_ptr<MultiSurface>(cloneImpl());
};

/** \brief
* Computes the boundary of this geometry
Expand All @@ -50,14 +39,25 @@ class GEOS_DLL MultiSurface : public GeometryCollection {
*/
std::unique_ptr<Geometry> getBoundary() const override;

/// Returns 1 (MultiSurface boundary is MultiCurve)
int getBoundaryDimension() const override;

/// Returns surface dimension (2)
Dimension::DimensionType getDimension() const override;

std::string getGeometryType() const override;

GeometryTypeId getGeometryTypeId() const override;

std::unique_ptr<MultiSurface> clone() const
bool hasDimension(Dimension::DimensionType d) const override
{
return std::unique_ptr<MultiSurface>(cloneImpl());
};
return d == Dimension::A;
}

bool isDimensionStrict(Dimension::DimensionType d) const override
{
return d == Dimension::A;
}

std::unique_ptr<MultiSurface> reverse() const
{
Expand All @@ -81,14 +81,14 @@ class GEOS_DLL MultiSurface : public GeometryCollection {
return new MultiSurface(*this);
}

MultiSurface* reverseImpl() const override;

int
getSortIndex() const override
{
return SORTINDEX_MULTISURFACE;
};

MultiSurface* reverseImpl() const override;

};
}
}
Loading

0 comments on commit f30a751

Please sign in to comment.