roelderickx / ogr2osm

A tool for converting ogr-readable files like shapefiles into .pbf or .osm data
https://pypi.org/project/ogr2osm/
MIT License
59 stars 14 forks source link

Add option to consider elevation when merging nodes #39

Closed Vectorial1024 closed 1 year ago

Vectorial1024 commented 1 year ago

Fixes #36 .

Explainer

The default of "merge all nodes regardless of elevation" is preserved. This PR simply adds an option for the user to choose: whether they want to make nodes with the same (X,Y) but different Z to be considered separate nodes.

This has a basic assumption that the provided node elevation is consistent, as shown below in the examples.


After enabling the --consider-elevation option:

Example 1

If we started with the following candidate nodes:

(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)

Then we will get the resulting unique nodes:

(0, 0)

Example 2

If we started with the following candidate nodes:

(0, 0, 1)
(0, 0, 2)
(0, 0, 1)

Then we will get the resulting unique nodes:

(0, 0, 1)
(0, 0, 2)

Example 3

If we started with the following candidate nodes:

(0, 0) (i.e., elevation data is missing)
(0, 0, 1)
(0, 0, 2)
(0, 0)
(0, 0)
(0, 0, 1)

Then we will get the resulting unique nodes:

(0, 0)
(0, 0, 1)
(0, 0, 2)