Skip to content

Commit 8d372c0

Browse files
authored
IsMultiPolygon Lua method (#810)
1 parent 0d01bc5 commit 8d372c0

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

docs/CONFIGURATION.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ To do that, you use these methods:
151151
* `Attribute(key,value,minzoom)`: add an attribute to the most recently written layer. Argument `minzoom` is optional, use it if you do not want to write the attribute on lower zoom levels.
152152
* `AttributeNumeric(key,value,minzoom)`, `AttributeBoolean(key,value,minzoom)`: for numeric/boolean columns.
153153
* `Id()`: get the OSM ID of the current object.
154+
* `IsClosed()`: returns true if the current object is a closed area.
155+
* `IsMultiPolygon()`: returns true if the current object is a multipolygon.
154156
* `ZOrder(number)`: Set a numeric value (default 0) used to sort features within a layer. Use this feature to ensure a proper rendering order if the rendering engine itself does not support sorting. Sorting is not supported across layers merged with `write_to`. Features with different z-order are not merged if `combine_below` or `combine_polygons_below` is used. Use this in conjunction with `feature_limit` to only write the most important (highest z-order) features within a tile. (Values can be -50,000,000 to 50,000,000 and are lossy, particularly beyond -1000 to 1000.)
155157
* `MinZoom(zoom)`: set the minimum zoom level (0-15) at which this object will be written. Note that the JSON layer configuration minimum still applies (so `:MinZoom(5)` will have no effect if your layer only starts at z6).
156158
* `Length()` and `Area()`: return the length (metres)/area (square metres) of the current object. Requires Boost 1.67+.

include/osm_lua_processing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class OsmLuaProcessing {
143143

144144
// Returns whether it is closed polygon
145145
bool IsClosed() const;
146+
bool IsMultiPolygon() const;
146147

147148
// Returns area
148149
double Area();

src/osm_lua_processing.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ bool rawIntersects(const std::string& layerName) { return osmLuaProcessing->Inte
181181
std::vector<std::string> rawFindCovering(const std::string& layerName) { return osmLuaProcessing->FindCovering(layerName); }
182182
bool rawCoveredBy(const std::string& layerName) { return osmLuaProcessing->CoveredBy(layerName); }
183183
bool rawIsClosed() { return osmLuaProcessing->IsClosed(); }
184+
bool rawIsMultiPolygon() { return osmLuaProcessing->IsMultiPolygon(); }
184185
double rawArea() { return osmLuaProcessing->Area(); }
185186
double rawLength() { return osmLuaProcessing->Length(); }
186187
kaguya::optional<std::vector<double>> rawCentroid(kaguya::VariadicArgType algorithm) { return osmLuaProcessing->Centroid(algorithm); }
@@ -246,6 +247,7 @@ OsmLuaProcessing::OsmLuaProcessing(
246247
luaState["FindCovering"] = &rawFindCovering;
247248
luaState["CoveredBy"] = &rawCoveredBy;
248249
luaState["IsClosed"] = &rawIsClosed;
250+
luaState["IsMultiPolygon"] = &rawIsMultiPolygon;
249251
luaState["Area"] = &rawArea;
250252
luaState["AreaIntersecting"] = &rawAreaIntersecting;
251253
luaState["Length"] = &rawLength;
@@ -475,6 +477,11 @@ bool OsmLuaProcessing::IsClosed() const {
475477
return isClosed;
476478
}
477479

480+
// Return whether it's a multipolygon
481+
bool OsmLuaProcessing::IsMultiPolygon() const {
482+
return isWay && isRelation;
483+
}
484+
478485
void reverse_project(DegPoint& p) {
479486
geom::set<1>(p, latp2lat(geom::get<1>(p)));
480487
}

0 commit comments

Comments
 (0)