Skip to content

Commit c4c5929

Browse files
author
peng.li24
committed
fix: mark all GeometryCollection methods inline to prevent ODR violations
1 parent 1587dda commit c4c5929

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

shapely/geometry/geometrycollection.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ class GeometryCollection {
9494
namespace shapely {
9595
namespace geometry {
9696

97-
GeometryCollection::GeometryCollection() {
97+
inline GeometryCollection::GeometryCollection() {
9898
factory_ = geos::geom::GeometryFactory::create();
9999
geos_coll_ = factory_->createGeometryCollection();
100100
}
101101

102-
void GeometryCollection::add_geometry(std::unique_ptr<geos::geom::Geometry> geom) {
102+
inline void GeometryCollection::add_geometry(std::unique_ptr<geos::geom::Geometry> geom) {
103103
if (!geom) return;
104104
std::vector<std::unique_ptr<geos::geom::Geometry>> geoms;
105105
for (size_t i = 0; i < geos_coll_->getNumGeometries(); ++i)
@@ -108,15 +108,15 @@ void GeometryCollection::add_geometry(std::unique_ptr<geos::geom::Geometry> geom
108108
geos_coll_ = factory_->createGeometryCollection(std::move(geoms));
109109
}
110110

111-
size_t GeometryCollection::num_geometries() const { return geos_coll_->getNumGeometries(); }
111+
inline size_t GeometryCollection::num_geometries() const { return geos_coll_->getNumGeometries(); }
112112

113-
const geos::geom::Geometry* GeometryCollection::geometry_n(size_t i) const {
113+
inline const geos::geom::Geometry* GeometryCollection::geometry_n(size_t i) const {
114114
return geos_coll_->getGeometryN(i);
115115
}
116116

117117
// -- Predicates (delegate to GEOS) -------------------------------------------
118118
#define GC_PRED(METHOD, GEOS_FN) \
119-
bool GeometryCollection::METHOD(const GeometryCollection& o) const { return detail::GEOS_FN(geos_coll_.get(), o.geos_coll_.get()); }
119+
inline bool GeometryCollection::METHOD(const GeometryCollection& o) const { return detail::GEOS_FN(geos_coll_.get(), o.geos_coll_.get()); }
120120
GC_PRED(contains, geos_contains)
121121
GC_PRED(within, geos_within)
122122
GC_PRED(disjoint, geos_disjoint)
@@ -125,25 +125,25 @@ GC_PRED(touches, geos_touches)
125125
GC_PRED(equals, geos_equals)
126126
#undef GC_PRED
127127

128-
bool GeometryCollection::equals_exact(const GeometryCollection& o, double tol) const {
128+
inline bool GeometryCollection::equals_exact(const GeometryCollection& o, double tol) const {
129129
return detail::geos_equals_exact(geos_coll_.get(), o.geos_coll_.get(), tol);
130130
}
131-
bool GeometryCollection::intersects(const GeometryCollection& o) const {
131+
inline bool GeometryCollection::intersects(const GeometryCollection& o) const {
132132
return geos_coll_->intersects(o.geos_coll_.get());
133133
}
134-
std::string GeometryCollection::relate(const GeometryCollection& o) const {
134+
inline std::string GeometryCollection::relate(const GeometryCollection& o) const {
135135
return detail::geos_relate(geos_coll_.get(), o.geos_coll_.get());
136136
}
137-
bool GeometryCollection::relate_pattern(const GeometryCollection& o, const std::string& p) const {
137+
inline bool GeometryCollection::relate_pattern(const GeometryCollection& o, const std::string& p) const {
138138
return detail::geos_relate_pattern(geos_coll_.get(), o.geos_coll_.get(), p);
139139
}
140-
double GeometryCollection::hausdorff_distance(const GeometryCollection& o) const {
140+
inline double GeometryCollection::hausdorff_distance(const GeometryCollection& o) const {
141141
return detail::geos_hausdorff_distance(geos_coll_.get(), o.geos_coll_.get());
142142
}
143143

144144
// -- Constructive operations -----------------------------------------------
145145
#define GC_CONSTRUCT(OP, GEOS_FN) \
146-
GeometryCollection GeometryCollection::OP(const GeometryCollection& o) const { \
146+
inline GeometryCollection GeometryCollection::OP(const GeometryCollection& o) const { \
147147
auto res = detail::GEOS_FN(geos_coll_.get(), o.geos_coll_.get()); \
148148
GeometryCollection r; \
149149
if (res && !res->isEmpty()) { \
@@ -158,7 +158,7 @@ GC_CONSTRUCT(union_op, geos_union)
158158
GC_CONSTRUCT(symmetric_difference, geos_sym_difference)
159159
#undef GC_CONSTRUCT
160160

161-
GeometryCollection GeometryCollection::simplify(double tol) const {
161+
inline GeometryCollection GeometryCollection::simplify(double tol) const {
162162
auto res = detail::geos_simplify(geos_coll_.get(), tol);
163163
GeometryCollection r;
164164
if (res && !res->isEmpty()) {
@@ -169,22 +169,22 @@ GeometryCollection GeometryCollection::simplify(double tol) const {
169169
}
170170

171171
// -- Accessors ---------------------------------------------------------------
172-
std::string GeometryCollection::wkt() const { return detail::geos_to_wkt(geos_coll_.get()); }
173-
std::string GeometryCollection::wkb_hex() const { return detail::geos_to_wkb_hex(geos_coll_.get()); }
174-
std::string GeometryCollection::type() const { return "GeometryCollection"; }
175-
std::string GeometryCollection::geom_type() const { return detail::geos_geom_type(geos_coll_.get()); }
176-
bool GeometryCollection::has_z() const { return detail::geos_has_z(geos_coll_.get()); }
172+
inline std::string GeometryCollection::wkt() const { return detail::geos_to_wkt(geos_coll_.get()); }
173+
inline std::string GeometryCollection::wkb_hex() const { return detail::geos_to_wkb_hex(geos_coll_.get()); }
174+
inline std::string GeometryCollection::type() const { return "GeometryCollection"; }
175+
inline std::string GeometryCollection::geom_type() const { return detail::geos_geom_type(geos_coll_.get()); }
176+
inline bool GeometryCollection::has_z() const { return detail::geos_has_z(geos_coll_.get()); }
177177

178178
// -- Properties ---------------------------------------------------------------
179-
bool GeometryCollection::is_empty() const { return detail::geos_is_empty(geos_coll_.get()); }
180-
bool GeometryCollection::is_simple() const { return detail::geos_is_simple(geos_coll_.get()); }
181-
bool GeometryCollection::is_valid() const { return detail::geos_is_valid(geos_coll_.get()); }
182-
double GeometryCollection::area() const { return geos_coll_->getArea(); }
183-
double GeometryCollection::length() const { return geos_coll_->getLength(); }
184-
std::vector<double> GeometryCollection::bounds() const { return detail::geos_bounds(geos_coll_.get()); }
179+
inline bool GeometryCollection::is_empty() const { return detail::geos_is_empty(geos_coll_.get()); }
180+
inline bool GeometryCollection::is_simple() const { return detail::geos_is_simple(geos_coll_.get()); }
181+
inline bool GeometryCollection::is_valid() const { return detail::geos_is_valid(geos_coll_.get()); }
182+
inline double GeometryCollection::area() const { return geos_coll_->getArea(); }
183+
inline double GeometryCollection::length() const { return geos_coll_->getLength(); }
184+
inline std::vector<double> GeometryCollection::bounds() const { return detail::geos_bounds(geos_coll_.get()); }
185185

186186
// -- Topology ------------------------------------------------------------------
187-
GeometryCollection GeometryCollection::convex_hull() const {
187+
inline GeometryCollection GeometryCollection::convex_hull() const {
188188
auto res = detail::geos_convex_hull(geos_coll_.get());
189189
GeometryCollection r;
190190
if (res && !res->isEmpty()) {
@@ -194,7 +194,7 @@ GeometryCollection GeometryCollection::convex_hull() const {
194194
return r;
195195
}
196196

197-
GeometryCollection GeometryCollection::buffer(double distance) const {
197+
inline GeometryCollection GeometryCollection::buffer(double distance) const {
198198
auto buf = geos_coll_->buffer(distance, 16);
199199
GeometryCollection r;
200200
if (buf && !buf->isEmpty()) {
@@ -204,7 +204,7 @@ GeometryCollection GeometryCollection::buffer(double distance) const {
204204
return r;
205205
}
206206

207-
void GeometryCollection::normalize() { geos_coll_->normalize(); }
207+
inline void GeometryCollection::normalize() { geos_coll_->normalize(); }
208208

209209
} // namespace geometry
210210
} // namespace shapely

0 commit comments

Comments
 (0)