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

Can't filter specified area by trim_osc.py script #10

Open
YuriiNskyi opened this issue Aug 9, 2019 · 4 comments
Open

Can't filter specified area by trim_osc.py script #10

YuriiNskyi opened this issue Aug 9, 2019 · 4 comments

Comments

@YuriiNskyi
Copy link

I have simple world.zip osm changes file, which I want trim by corresponding script, by specifying Andorra's poly file.

Here is my command for that ~/src/regional/trim_osc.py -d gis --user postgres --host localhost --port 5432 --password -p "${WORKOSM_DIR}/andorra.poly" world.osm worldTrimmed.osm.

After executing that command, worldTrimmed.osm is lesser than world.osm, but after checking coordinates in file, I see that there are still coordinates outside Andorra's bounds.

In fact, sample file:

<?xml version='1.0' encoding='UTF-8'?>
<osmChange version="0.6" generator="Osmosis 0.47">
  <modify>
    <node id="60359977" version="3" timestamp="2019-08-09T08:07:49Z" uid="3909835" user="mysampleuser" changeset="73182495" lat="42.776481" lon="9.4764622">
      <tag k="crossing" v="uncontrolled"/>
      <tag k="highway" v="crossing"/>
    </node>
    <node id="60359982" version="5" timestamp="2019-08-09T08:07:49Z" uid="3909835" user="mysampleuser" changeset="73182495" lat="42.494126" lon="1.585888">
      <tag k="crossing" v="controlled"/>
      <tag k="highway" v="crossing"/>
    </node>
  </modify>
</osmChange>

is filtered well, and only node with id 60359982 lasts.

What's wrong with that scenario and how can I fix that?

@Zverik
Copy link
Owner

Zverik commented Aug 9, 2019

There will be coordinates outside: the script does not filter out 100% of these. It keeps ways and relations that refer to nodes inside the area, but are located partly outside, like longer route relations. It keeps everything it cannot tie to a coordinate, like relation changes. So for a result, there would be many objects that lie outside of bounds, but still much less than the entire change file.

@YuriiNskyi
Copy link
Author

@Zverik Rephrasing your answer, am I right that as a result script removes all nodes which lie outside bounds and not connected to nodes which lie inside bounds? Ways and relations are filtered out only if theirs nodes are fully located outside bounds?

@Zverik
Copy link
Owner

Zverik commented Aug 9, 2019

Mostly yes. It also uses the connection to osm2pgsql database to keep all objects that are referenced by or reference objects in the database.

@YuriiNskyi
Copy link
Author

@Zverik ok, rephrasing again, database is used to be source of truth, if any file's object exists in DB, it won't be deleted, without any conditions.

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

No branches or pull requests

2 participants