Comments (5)
What do you propose as_linestring()
generate when called on a relation? What would happen if the relation doesn't "fit" into a LineString?
Typically you'd use something like this on a route
relation where the result could be a LineString, but it could also be a MultiLineString. That's why there is only the as_multilinestring()
function for relations. That function also exists for ways, although in that case it will always create a MultiLineString with a single LineString in it. You can then either use that MultiLineString as is or iterate over the geometries in it and work with each LineString. So common code for both ways and relations can just use the as_multilinestring()
function.
See https://osm2pgsql.org/doc/tutorials/switching-from-add-row-to-insert/ for some more infos.
You can also look at the unitable.lua example config to see how you can write code that's mostly shared between nodes, ways, and relations but still handles geometries differently.
And finally: Functions are first-class objects in Lua, you can define your own. For an example see the themepark code.
from osm2pgsql.
What do you propose
as_linestring()
generate when called on a relation? What would happen if the relation doesn't "fit" into a LineString?
I am not suggesting allowing 'as_linestring' in any other processing callback function like the 'process_relation' callback function, instead, I suggest to allow 'process_way' to call helper functions to do a geometry transform, instead of forcing the geometry transform function to be used inside the 'process_way' function itself. This is what Paul's style did, and feels like a natural way of using functions in Lua.
I know you can define functions, in fact, it is exactly the fact that I want to define and use custom functions that is now limited because osm2pgsql performs this check.
If the goal of this check was to prevent users from making mistakes in the Lua code related to the processing callback functions and geometry transforms, it would be better to change the check's logic from:
"'as_linestring' cannot be used in any other function than 'process_way'"
to:
"as_linestring" is forbidden to be used in the 'process_relation' or 'select_relation_members' callback functions
thus allowing its usage in any other function except those two.
Similarly, as to your example of the 'as_multilinestring', this could be limited by:
"'as_multilinestring' is forbidden to be used in the 'process_way' callback function"
allowing it to be used in any other helper function defined by the user.
from osm2pgsql.
I have had a closer look at my style and Paul's work for it, and I really have to come to the conclusion that unless the logic for these checks is changed, I will be unable to upgrade to osm2pgsql v2.0 once it comes out. This is an absolute blocking issue for me.
There is just no way to convert 'add_row' to 'insert' with current logic and the processing needed in my style.
This is especially related to OSM boundary relations, where there is the direct need to insert relation members both in the 'planet_osm_line' and 'planet_osm_polygon' tables in the 'process_relation' callback function. This is related to Paul's nice work to allow de-duplicated OSM boundary relation line members to be used to solve the issue of overlapping boundary relation symbology as based on polygons.
AFAI can tell from the code review now, this part of the code cannot be converted to the new 'insert' function logic with current checks in osm2pgsql, it will fail on the error thrown. This was never a problem with the 'add_row' function.
from osm2pgsql.
Ah, I think there is a misunderstanding here with the wording of the error message. You can call the as_*
geometry creation functions from any function you want as long as that function is ultimately called from the correct osm2pgsql.process_node/way/relation()
function. The issue isn't really about which function it is called from, but that the OSM object you call it on is of the correct type. I'll think about how to improve that error message.
I am pretty sure everything that could be done with add_row()
can be done with insert()
. If you can not get something to work, post a minimal working example here and we can have a look at it.
from osm2pgsql.
I don't think there is any bug here, just a misunderstanding how the geometry conversion functions can/should be used. Converting to discussion.
from osm2pgsql.
Related Issues (20)
- Question: could not extend file "base/361191441/368615606.137": No space left on device
- osm2pgsql should not perform analyze by itself HOT 15
- `object:as_multipolygon()` does not take `object.members` into account. HOT 2
- Some research on middle performance HOT 4
- highway=rest_area treatet as line HOT 2
- free(): invalid size Aborted Core dumped HOT 4
- North America import fails HOT 1
- nlohmann-json is missing from the Alpine build dependencies command
- Error in reprocessing of ways in relation, if osmc_symbols-tag of the relation contains the word 'backslash' HOT 6
- Deprecating -i,--tablespace-index? HOT 5
- Out of bounds tile coordinates produced HOT 3
- When Planet osm data import, way showing 0 and not started HOT 6
- osm2pgsql using too much memory for expire lists HOT 14
- Windows CI broken HOT 2
- cmake on ubuntu 22.04-lts requires libboost-dev, libboost-system-dev, libboost-filesystem-dev to be installed HOT 2
- Replication breakage
- Run update in transaction
- osm2pgsql-replication returns code 0 when output says "Error during diff download" HOT 3
- Flex: call `:get_bbox()` on geometry, not on parameter table (object) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osm2pgsql.