Skip to content

Add support for modifying relations based on object metadata#16

Open
acannistra wants to merge 17 commits intomasterfrom
tony/fixup-relations
Open

Add support for modifying relations based on object metadata#16
acannistra wants to merge 17 commits intomasterfrom
tony/fixup-relations

Conversation

@acannistra
Copy link
Contributor

@acannistra acannistra commented Jun 26, 2021

Adding activity classification to the pre-import pipeline (https://github.com/trailbehind/USFSConflation/pull/32) has revealed that we will sometimes need to ensure that new OSM objects added during conflation are also added to relations.

This PR implements the ability to include newly-created OSM objects into existing Relations. We do this by looking for a special Tag name prefix (currently _member_of_). These tags should contain as their Values the ID of a relation that the objects should be added to.

After creating a mapping from ID -> Relation, we lookup the relations referenced in the _member_of Tags and add the OSM object that has that tag to the corresponding relation in the aforementioned mapping. We also keep track of the modified relations.

Once all objects are processed, we output a list of modified Relation objects and create a <modify> tag for them in the changefile.

This feature is disabled by default and can be enabled with the --modify_relations flag.

I haven't tested this fully yet.

@acannistra acannistra added this to the v.0.1.1 milestone Jun 26, 2021
@acannistra acannistra requested a review from JesseCrocker June 26, 2021 01:01
@acannistra acannistra changed the base branch from master to tony/hotfix/typo June 28, 2021 23:03
Base automatically changed from tony/hotfix/typo to master July 7, 2021 17:50
Copy link

@JesseCrocker JesseCrocker left a comment

Choose a reason for hiding this comment

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

Looked over code, LGTM

@acannistra
Copy link
Contributor Author

acannistra commented Aug 9, 2021

We're not going to do this anymore. Perhaps we will merge this later on, but it's not going to be in this version.

@acannistra acannistra closed this Aug 9, 2021
@acannistra acannistra reopened this Aug 9, 2021
@acannistra
Copy link
Contributor Author

Putting some docs here in case we get back to this:

Relation Management
====================

This module provides support for modifying Relations. It supports a few use-cases. 

1. A <create> tag will be created, and some objects within it need to be 
   added to relations that already exist. In this case, <modify> tags are 
   created that modify the Relations in question. 
2. more later probably

It is important to note that this module is STATEFUL. It should probably be a class. 
If you need to clear the relations DB and modified relations list, you can use _reset().

Insertion in to Existing Relations
-----------------------------------

In order to insert an object into an existing relation a particular schema 
of the input data is required. In particular, any object that is to be inserted
into a Relation must contain a Tag with a user-specifiable Key
and a Value that represents a comma-separated list of the IDs of 
Relations that the object should be inserted into. 

The default Tag Key that is used is `_member_of`. (To use another, pass it as
the `relation_tag` argument to `get_modified_relations_for_object`). 

`modify_relations_with_object` is responsible for modifying a local
database of Relations with by objects to them, as specified in the object itself. 

Before running `modify_relations_with_object`, a local database of
Relations must be generated. This is done by providing a list of 
Relation IDs to `get_relations`. This is an expensive operation, 
so should be done as infrequently as possible (likely just once).

The list of IDs provided to `get_relations` should represent all relations
that need to be inserted into. 

After processing objects is complete, call get_modified_relations 
to obtain a list of modified relations that can then be used to create
<modify> tags in a changefile. 

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