Skip to content

Commit e7eb5a2

Browse files
committed
Reformat files for curved geometry classes
1 parent d9bee63 commit e7eb5a2

18 files changed

+681
-678
lines changed

include/geos/geom/CircularString.h

+23-14
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,49 @@ class GEOS_DLL CircularString : public SimpleCurve {
3535

3636
GeometryTypeId getGeometryTypeId() const override;
3737

38-
CircularString* cloneImpl() const override
38+
double getLength() const override
3939
{
40-
return new CircularString(*this);
40+
throw util::UnsupportedOperationException("Cannot calculate length of CircularString");
4141
}
4242

43-
CircularString* reverseImpl() const override;
44-
45-
int
46-
getSortIndex() const override
43+
bool hasCurvedComponents() const override
4744
{
48-
return SORTINDEX_LINESTRING;
49-
};
50-
51-
double getLength() const override {
52-
throw util::UnsupportedOperationException("Cannot calculate length of CircularString");
45+
return true;
5346
}
5447

55-
bool hasCurvedComponents() const override {
56-
return true;
48+
std::unique_ptr<CircularString> reverse() const
49+
{
50+
return std::unique_ptr<CircularString>(reverseImpl());
5751
}
5852

5953
protected:
6054

6155
/// \brief
6256
/// Constructs a CircularString taking ownership the
6357
/// given CoordinateSequence.
64-
CircularString(std::unique_ptr<CoordinateSequence> && pts,
58+
CircularString(std::unique_ptr<CoordinateSequence>&& pts,
6559
const GeometryFactory& newFactory);
6660

61+
CircularString* cloneImpl() const override
62+
{
63+
return new CircularString(*this);
64+
}
65+
6766
void geometryChangedAction() override
6867
{
6968
envelope = computeEnvelopeInternal(false);
7069
}
7170

71+
int
72+
getSortIndex() const override
73+
{
74+
return SORTINDEX_LINESTRING;
75+
};
76+
77+
CircularString* reverseImpl() const override;
78+
79+
void validateConstruction();
80+
7281
};
7382

7483

include/geos/geom/CompoundCurve.h

+42-40
Original file line numberDiff line numberDiff line change
@@ -24,91 +24,93 @@ namespace geom {
2424
class GEOS_DLL CompoundCurve : public Curve {
2525
friend class GeometryFactory;
2626

27-
2827
public:
28+
using Curve::apply_ro;
29+
using Curve::apply_rw;
2930

30-
CompoundCurve(const CompoundCurve&);
31-
32-
CompoundCurve& operator=(const CompoundCurve&);
33-
34-
std::unique_ptr<CoordinateSequence> getCoordinates() const override;
35-
36-
const CoordinateXY* getCoordinate() const override;
31+
void apply_ro(CoordinateFilter* filter) const override;
3732

38-
uint8_t getCoordinateDimension() const override;
33+
void apply_ro(CoordinateSequenceFilter& filter) const override;
3934

40-
bool hasZ() const override;
35+
void apply_rw(CoordinateSequenceFilter& filter) override;
4136

42-
bool hasM() const override;
37+
void apply_rw(const CoordinateFilter* filter) override;
4338

44-
bool isEmpty() const override;
39+
int compareToSameClass(const Geometry* geom) const override;
4540

46-
bool isClosed() const override;
41+
std::unique_ptr<CompoundCurve> clone() const;
4742

48-
std::size_t getNumCurves() const;
43+
CompoundCurve* cloneImpl() const override;
4944

50-
const SimpleCurve* getCurveN(std::size_t) const;
45+
bool equalsExact(const Geometry* other, double tolerance = 0)
46+
const override;
5147

52-
std::size_t getNumPoints() const override;
48+
bool equalsIdentical(const Geometry* other) const override;
5349

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

56-
std::string getGeometryType() const override;
52+
const CoordinateXY* getCoordinate() const override;
5753

58-
GeometryTypeId getGeometryTypeId() const override;
54+
std::unique_ptr<CoordinateSequence> getCoordinates() const override;
5955

60-
bool equalsExact(const Geometry* other, double tolerance = 0)
61-
const override;
56+
uint8_t getCoordinateDimension() const override;
6257

63-
bool equalsIdentical(const Geometry* other) const override;
58+
/// Returns the nth section of the CompoundCurve
59+
const SimpleCurve* getCurveN(std::size_t) const;
6460

6561
const Envelope* getEnvelopeInternal() const override
6662
{
6763
return &envelope;
6864
}
6965

70-
std::unique_ptr<CompoundCurve> clone() const;
66+
std::string getGeometryType() const override;
7167

72-
CompoundCurve* cloneImpl() const override;
68+
GeometryTypeId getGeometryTypeId() const override;
7369

74-
std::unique_ptr<CompoundCurve> reverse() const;
70+
double getLength() const override;
7571

76-
CompoundCurve* reverseImpl() const override;
72+
/// Returns the number of sections in the CompoundCurve
73+
std::size_t getNumCurves() const;
7774

78-
double getLength() const override;
75+
std::size_t getNumPoints() const override;
7976

80-
using Curve::apply_ro;
81-
using Curve::apply_rw;
77+
bool hasCurvedComponents() const override;
8278

83-
void apply_rw(const CoordinateFilter* filter) override;
79+
bool hasM() const override;
8480

85-
void apply_ro(CoordinateFilter* filter) const override;
81+
bool hasZ() const override;
8682

87-
void apply_rw(CoordinateSequenceFilter& filter) override;
83+
bool isClosed() const override;
8884

89-
void apply_ro(CoordinateSequenceFilter& filter) const override;
85+
bool isEmpty() const override;
9086

9187
void normalize() override;
9288

93-
int compareToSameClass(const Geometry* geom) const override;
94-
95-
bool hasCurvedComponents() const override;
89+
std::unique_ptr<CompoundCurve> reverse() const;
9690

9791
protected:
92+
/// Construct a CompoundCurve, taking ownership of the
93+
/// provided CoordinateSequence
9894
CompoundCurve(std::vector<std::unique_ptr<SimpleCurve>>&&,
9995
const GeometryFactory&);
10096

101-
int getSortIndex() const override
102-
{
103-
return SORTINDEX_COMPOUNDCURVE;
104-
}
97+
CompoundCurve(const CompoundCurve&);
98+
99+
CompoundCurve& operator=(const CompoundCurve&);
100+
101+
Envelope computeEnvelopeInternal() const;
105102

106103
void geometryChangedAction() override
107104
{
108105
envelope = computeEnvelopeInternal();
109106
}
110107

111-
Envelope computeEnvelopeInternal() const;
108+
int getSortIndex() const override
109+
{
110+
return SORTINDEX_COMPOUNDCURVE;
111+
}
112+
113+
CompoundCurve* reverseImpl() const override;
112114

113115
private:
114116
std::vector<std::unique_ptr<SimpleCurve>> curves;

include/geos/geom/Curve.h

+23-17
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,41 @@ namespace geom {
2222
class GEOS_DLL Curve : public Geometry {
2323

2424
public:
25-
/// Returns line dimension (1)
26-
Dimension::DimensionType getDimension() const override
27-
{
28-
return Dimension::L; // line
29-
}
25+
using Geometry::apply_ro;
26+
using Geometry::apply_rw;
27+
28+
void apply_ro(GeometryComponentFilter* filter) const override;
3029

30+
void apply_ro(GeometryFilter* filter) const override;
31+
32+
void apply_rw(GeometryComponentFilter* filter) override;
33+
34+
void apply_rw(GeometryFilter* filter) override;
35+
36+
/**
37+
* \brief
38+
* Returns Dimension::False for a closed Curve,
39+
* 0 otherwise (Curve boundary is a MultiPoint)
40+
*/
3141
int
3242
getBoundaryDimension() const override
3343
{
3444
return isClosed() ? Dimension::False : 0;
3545
}
3646

47+
/// Returns line dimension (1)
48+
Dimension::DimensionType getDimension() const override
49+
{
50+
return Dimension::L; // line
51+
}
52+
53+
/// Returns true if the first and last coordinate in the Curve are the same
3754
virtual bool isClosed() const = 0;
3855

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

41-
using Geometry::apply_ro;
42-
using Geometry::apply_rw;
43-
44-
void apply_rw(GeometryFilter* filter) override;
45-
46-
void apply_ro(GeometryFilter* filter) const override;
47-
48-
void apply_rw(GeometryComponentFilter* filter) override;
49-
50-
void apply_ro(GeometryComponentFilter* filter) const override;
51-
5259
protected:
53-
5460
Curve(const GeometryFactory& factory) : Geometry(&factory) {}
5561

5662
};

include/geos/geom/CurvePolygon.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,31 @@ class GEOS_DLL CurvePolygon : public SurfaceImpl<Curve> {
2525
public:
2626
~CurvePolygon() override = default;
2727

28-
std::unique_ptr<CoordinateSequence> getCoordinates() const override;
28+
double getArea() const override;
2929

30-
int
31-
getSortIndex() const override
32-
{
33-
return SORTINDEX_CURVEPOLYGON;
34-
}
30+
std::unique_ptr<Geometry> getBoundary() const override;
31+
32+
std::unique_ptr<CoordinateSequence> getCoordinates() const override;
3533

3634
std::string getGeometryType() const override;
3735

3836
GeometryTypeId getGeometryTypeId() const override;
3937

40-
std::unique_ptr<Geometry> getBoundary() const override;
38+
bool hasCurvedComponents() const override;
4139

4240
void normalize() override;
4341

44-
double getArea() const override;
45-
46-
bool hasCurvedComponents() const override;
47-
4842
protected:
4943
using SurfaceImpl::SurfaceImpl;
5044

5145
Geometry* cloneImpl() const override;
5246

47+
int
48+
getSortIndex() const override
49+
{
50+
return SORTINDEX_CURVEPOLYGON;
51+
}
52+
5353
Geometry* reverseImpl() const override;
5454
};
5555

include/geos/geom/Geometry.h

+13-9
Original file line numberDiff line numberDiff line change
@@ -946,21 +946,25 @@ class GEOS_DLL Geometry {
946946
while(i < a.size() && j < b.size()) {
947947
const auto& aGeom = *a[i];
948948
const auto& bGeom = *b[j];
949-
int comparison = aGeom.compareTo(&bGeom);
950-
if(comparison != 0) {
951-
return comparison;
952-
}
953-
i++;
954-
j++;
949+
950+
int comparison = aGeom.compareTo(&bGeom);
951+
if(comparison != 0) {
952+
return comparison;
953+
}
954+
955+
i++;
956+
j++;
955957
}
958+
956959
if(i < a.size()) {
957-
return 1;
960+
return 1;
958961
}
962+
959963
if(j < b.size()) {
960-
return -1;
964+
return -1;
961965
}
962-
return 0;
963966

967+
return 0;
964968
}
965969

966970
bool equal(const CoordinateXY& a, const CoordinateXY& b,

include/geos/geom/MultiCurve.h

+17-15
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,13 @@ class GEOS_DLL MultiCurve : public GeometryCollection {
2626
public:
2727
~MultiCurve() override = default;
2828

29-
/// Returns line dimension (1)
30-
Dimension::DimensionType getDimension() const override;
31-
32-
bool hasDimension(Dimension::DimensionType d) const override
29+
std::unique_ptr<MultiCurve> clone() const
3330
{
34-
return d == Dimension::L;
35-
}
31+
return std::unique_ptr<MultiCurve>(cloneImpl());
32+
};
3633

37-
bool isDimensionStrict(Dimension::DimensionType d) const override
38-
{
39-
return d == Dimension::L;
40-
}
34+
/// Returns a (possibly empty) [MultiPoint](@ref geom::MultiPoint)
35+
std::unique_ptr<Geometry> getBoundary() const override;
4136

4237
/**
4338
* \brief
@@ -46,21 +41,28 @@ class GEOS_DLL MultiCurve : public GeometryCollection {
4641
*/
4742
int getBoundaryDimension() const override;
4843

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

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

5449
std::string getGeometryType() const override;
5550

5651
GeometryTypeId getGeometryTypeId() const override;
5752

53+
bool hasDimension(Dimension::DimensionType d) const override
54+
{
55+
return d == Dimension::L;
56+
}
57+
58+
/// Returns true if the MultiCurve is not empty, and every included
59+
/// Curve is also closed.
5860
bool isClosed() const;
5961

60-
std::unique_ptr<MultiCurve> clone() const
62+
bool isDimensionStrict(Dimension::DimensionType d) const override
6163
{
62-
return std::unique_ptr<MultiCurve>(cloneImpl());
63-
};
64+
return d == Dimension::L;
65+
}
6466

6567
/**
6668
* Creates a MultiCurve in the reverse

0 commit comments

Comments
 (0)