Skip to content

Commit

Permalink
Set maximum zoom for feature limit
Browse files Browse the repository at this point in the history
  • Loading branch information
systemed committed Oct 4, 2023
1 parent 0ea137f commit 05c3cda
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/shared_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct LayerDef {
uint combinePolygonsBelow;
bool sortZOrderAscending;
uint featureLimit;
uint featureLimitBelow;
std::string source;
std::vector<std::string> sourceColumns;
bool allSourceColumns;
Expand All @@ -47,7 +48,7 @@ class LayerDefinition {
uint addLayer(std::string name, uint minzoom, uint maxzoom,
uint simplifyBelow, double simplifyLevel, double simplifyLength, double simplifyRatio,
uint filterBelow, double filterArea, uint combinePolygonsBelow, bool sortZOrderAscending,
uint featureLimit,
uint featureLimit, uint featureLimitBelow,
const std::string &source,
const std::vector<std::string> &sourceColumns,
bool allSourceColumns,
Expand Down
7 changes: 4 additions & 3 deletions src/shared_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SharedData::~SharedData() { }
uint LayerDefinition::addLayer(string name, uint minzoom, uint maxzoom,
uint simplifyBelow, double simplifyLevel, double simplifyLength, double simplifyRatio,
uint filterBelow, double filterArea, uint combinePolygonsBelow, bool sortZOrderAscending,
uint featureLimit,
uint featureLimit, uint featureLimitBelow,
const std::string &source,
const std::vector<std::string> &sourceColumns,
bool allSourceColumns,
Expand All @@ -30,7 +30,7 @@ uint LayerDefinition::addLayer(string name, uint minzoom, uint maxzoom,

bool isWriteTo = !writeTo.empty();
LayerDef layer = { name, minzoom, maxzoom, simplifyBelow, simplifyLevel, simplifyLength, simplifyRatio,
filterBelow, filterArea, combinePolygonsBelow, sortZOrderAscending, featureLimit,
filterBelow, filterArea, combinePolygonsBelow, sortZOrderAscending, featureLimit, featureLimitBelow,
source, sourceColumns, allSourceColumns, indexed, indexName,
std::map<std::string,uint>(), isWriteTo };
layers.push_back(layer);
Expand Down Expand Up @@ -205,6 +205,7 @@ void Config::readConfig(rapidjson::Document &jsonConfig, bool &hasClippingBox, B
double filterArea = it->value.HasMember("filter_area" ) ? it->value["filter_area" ].GetDouble() : 0.5;
int combinePolyBelow=it->value.HasMember("combine_polygons_below") ? it->value["combine_polygons_below"].GetInt() : 0;
int featureLimit = it->value.HasMember("feature_limit" ) ? it->value["feature_limit" ].GetInt() : 0;
int featureLimitBelow= it->value.HasMember("feature_limit_below") ? it->value["feature_limit_below"].GetInt() : (maxZoom+1);
bool sortZOrderAscending = it->value.HasMember("z_order_ascending") ? it->value["z_order_ascending"].GetBool() : (featureLimit==0);
string source = it->value.HasMember("source") ? it->value["source"].GetString() : "";
vector<string> sourceColumns;
Expand All @@ -225,7 +226,7 @@ void Config::readConfig(rapidjson::Document &jsonConfig, bool &hasClippingBox, B

layers.addLayer(layerName, minZoom, maxZoom,
simplifyBelow, simplifyLevel, simplifyLength, simplifyRatio,
filterBelow, filterArea, combinePolyBelow, sortZOrderAscending, featureLimit,
filterBelow, filterArea, combinePolyBelow, sortZOrderAscending, featureLimit, featureLimitBelow,
source, sourceColumns, allSourceColumns, indexed, indexName,
writeTo);

Expand Down
2 changes: 1 addition & 1 deletion src/tile_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void ProcessLayer(SourceList const &sources, AttributeStore const &attributeStor
// Loop through output objects
auto ooListSameLayer = GetObjectsAtSubLayer(data[i], layerNum);
auto end = ooListSameLayer.second;
if (ld.featureLimit > 0 && end-ooListSameLayer.first > ld.featureLimit) end = ooListSameLayer.first+ld.featureLimit;
if (ld.featureLimit>0 && end-ooListSameLayer.first>ld.featureLimit && zoom<ld.featureLimitBelow) end = ooListSameLayer.first+ld.featureLimit;
ProcessObjects(sources[i], attributeStore,
ooListSameLayer.first, end, sharedData,
simplifyLevel, filterArea, zoom < ld.combinePolygonsBelow, zoom, bbox, vtLayer, keyList, valueList);
Expand Down

0 comments on commit 05c3cda

Please sign in to comment.