Skip to content

Generate <modify> blocks for nodes and add a few tests#2

Draft
lpoujade wants to merge 4 commits into
docentYT:mainfrom
lpoujade:1-generate-modify-blocks-for-nodes
Draft

Generate <modify> blocks for nodes and add a few tests#2
lpoujade wants to merge 4 commits into
docentYT:mainfrom
lpoujade:1-generate-modify-blocks-for-nodes

Conversation

@lpoujade
Copy link
Copy Markdown

@lpoujade lpoujade commented Mar 10, 2026

Hi @docentYT,

As discussed previously, here is a first draft with my changes to handle modifications, and a basic shell script with a few examples.

About objects id: the GeoJSON spec asks for an id property in each feature (not in properties) if there is such an id, and Overpass which seems to use osmtogeojson correctly set this id (also see example/ara_small.osm.geojson wich is an export from Overpass), so if you're ok with this I'll remove the code to handle feature["properties"]["@id"] and instead I will only parse feature["id"].
Also, maybe I could parse the object type from the osm id if present, what do you think ? Or even all available properties which are not tags (eg @user, @version)

I put a basic test script here but if you prefer I can open another pr for this. Maybe it can be better to have an example folder with 1 or 2 simple example, and a test folder with more specific cases. But I'm not sure this simple script will be helpful for more complex scenarios, for example the tests which calls the OSM API may fail simply because someone updated an object

- allow to match features using keys from GeoJSON `feature` object, not
  necessarily from `features["properties"]`
- remove all `@props` from GeoJSON feature properties
- if needed, call OSM API to get all data of reference objects
- basic protection to prevent unwanted overrides
- log: show count of creation/deletion/modifications etc
@docentYT
Copy link
Copy Markdown
Owner

so if you're ok with this I'll remove the code to handle feature["properties"]["@id"] and instead I will only parse feature["id"].

Sure, go ahead.

Also, maybe I could parse the object type from the osm id if present, what do you think ?

I'm not sure if this will work, because from what I can see in the code, currently "LineString" and "Polygon" geometries are supported, and the equivalent of a polygon in OSM could be a Relation, which is not supported due to its complexity and lack of support in geojson.

Or even all available properties which are not tags (eg @user, @Version)

If you feel like doing it and see a use for it, why not?

Comment thread src/osmchange_generator_cli/main.py Outdated
Comment thread src/osmchange_generator_cli/main.py Outdated
stats = {"ignored_updates": [], "modifications": 0}

if update_from_api:
ref = osmApi.elements.get(Node, ref.id)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More optimal solution would be to create list of all id's we have to download and then use one api call https://docentyt.github.io/osm_easy_api/osm_easy_api/api/endpoints/elements.html#Elements_Container.get_query

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way better indeed ! Now objects are downloaded by batch of 100

Comment thread src/osmchange_generator_cli/main.py Outdated
Comment thread test.sh Outdated
- allow to download from api even if --modify=false
- download by batch, not one by one
- simplify comparison between nodes
- add an option to use a custom user agent
- use @properties from geojson as metadata for osm objects
@lpoujade
Copy link
Copy Markdown
Author

I successfully generated a first changeset with theses modifications (opened and uploaded with josm)

I separated --update-from-api from modify options, so now it is possible to compare a geojson against an empty ref file and download nodes data directly from openstreetmap.

I don't know how to do it for now but I'd like to add a "no upload" tag to the generated changeset in case of modifications on objects without downloading full object data from osm, as in can lead to unwanted removal of some attributes if not present in the ref file

@docentYT
Copy link
Copy Markdown
Owner

This pull request is still marked as "work in progress".
You are still working on it, and I should wait until you finish?

@lpoujade
Copy link
Copy Markdown
Author

lpoujade commented Mar 20, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants