Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't require any Lua functions #770

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/osm_lua_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class OsmLuaProcessing {
// Do we have Lua routines for non-MP relations?
bool canReadRelations();
bool canPostScanRelations();
bool canWriteNodes();
bool canWriteWays();
bool canWriteRelations();

// Shapefile tag remapping
Expand Down Expand Up @@ -264,6 +266,8 @@ class OsmLuaProcessing {
bool supportsRemappingShapefiles;
bool supportsReadingRelations;
bool supportsPostScanRelations;
bool supportsWritingNodes;
bool supportsWritingWays;
bool supportsWritingRelations;
const class ShpMemTiles &shpMemTiles;
class OsmMemTiles &osmMemTiles;
Expand Down
15 changes: 14 additions & 1 deletion src/osm_lua_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ OsmLuaProcessing::OsmLuaProcessing(
supportsRemappingShapefiles = !!luaState["attribute_function"];
supportsReadingRelations = !!luaState["relation_scan_function"];
supportsPostScanRelations = !!luaState["relation_postscan_function"];
supportsWritingNodes = !!luaState["node_function"];
supportsWritingWays = !!luaState["way_function"];
supportsWritingRelations = !!luaState["relation_function"];

// ---- Call init_function of Lua logic
Expand Down Expand Up @@ -272,6 +274,14 @@ bool OsmLuaProcessing::canPostScanRelations() {
return supportsPostScanRelations;
}

bool OsmLuaProcessing::canWriteNodes() {
return supportsWritingNodes;
}

bool OsmLuaProcessing::canWriteWays() {
return supportsWritingWays;
}

bool OsmLuaProcessing::canWriteRelations() {
return supportsWritingRelations;
}
Expand Down Expand Up @@ -1064,7 +1074,10 @@ void OsmLuaProcessing::setRelation(
// Start Lua processing for relation
if (!isNativeMP && !supportsWritingRelations) return;
try {
luaState[isNativeMP ? "way_function" : "relation_function"]();
if (isNativeMP && supportsWritingWays)
luaState["way_function"]();
else if (!isNativeMP && supportsWritingRelations)
luaState["relation_function"]();
} catch(luaProcessingException &e) {
std::cerr << "Lua error on relation " << originalOsmID << std::endl;
exit(1);
Expand Down
4 changes: 2 additions & 2 deletions src/pbf_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool PbfProcessor::ReadNodes(OsmLuaProcessing& output, PbfReader::PrimitiveGroup
}

bool emitted = false;
if (!tags.empty() && nodeKeys.filter(tags)) {
if (output.canWriteNodes() && !tags.empty() && nodeKeys.filter(tags)) {
emitted = output.setNode(static_cast<NodeID>(nodeId), latplon, tags);
}

Expand Down Expand Up @@ -142,7 +142,7 @@ bool PbfProcessor::ReadWays(
if (llVec.empty()) continue;

try {
bool emitted = output.setWay(static_cast<WayID>(pbfWay.id), llVec, tags);
bool emitted = output.canWriteWays() && output.setWay(static_cast<WayID>(pbfWay.id), llVec, tags);

// If we need it for later, store the way's coordinates in the global way store
if (emitted || osmStore.way_is_used(wayId)) {
Expand Down
Loading