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

Allow joining external data using tag-transform #52

Merged
merged 2 commits into from
May 5, 2020

Conversation

fwiesweg
Copy link

@fwiesweg fwiesweg commented Jan 5, 2020

Overview

In order to join per-postal-code data from a CSV file, I extended tag-transform to be able to read a row of data from a generic DataSource object and insert this data into the output tag using the new data and source elements along with two new attributes on the tag element in the output section.

Functionality

  • A tag matches a regex pattern, yielding a series of matches
  • A row is selected from the data source (in this case, a CSV file, but it's extendable) according to the matches
  • The cells of this row are now accessible from the templates in the output tag's template

For an example, please refer to the test below: The postal_code field is matched and looked up in the CSV file (column 0). From this, a tag is generated, with its value set to "5000".

Current state

It's basically functional and does not appear to noticeably degrade performance on smaller data sets (tested on[1]) and does nothing if not configured explicitly.

If you're interested in merging this work, I'd appreciate some feedback! I'm not quite sure about formatting/indentation, ./gradlew checkstyleMain checkstyleTest does not seem to catch all issues for some reason. Docs are still missing, too.

[1] https://download.openstreetmap.fr/extracts/europe/germany/nordrhein_westfalen/munster.osm.pbf

@fwiesweg
Copy link
Author

fwiesweg commented Jan 26, 2020

Seems as if my test fails on travis:

org.openstreetmap.osmosis.tagtransform.v0_6.TagTransformTest > testDataSourceTransform FAILED java.lang.AssertionError at TagTransformTest.java:100

It's green on my machine, so I guess it's some encoding issue. If someone could pass me the output files, I'll gladly fix that.

@migurski
Copy link
Collaborator

Hi @fwiesweg, I’d be happy to help. I’m new to helping Brett with this project. What output files would you need, and are these something you can retrieve by running Travis on a fork of this repo?

@fwiesweg
Copy link
Author

fwiesweg commented May 1, 2020

Hi @migurski ! Thanks for the hint, didn't know it was that easy to run travis by myself. The test's green now, turned out I only had to put a version placeholder in the XML ;)

@migurski migurski merged commit 4a706f8 into openstreetmap:master May 5, 2020
@migurski
Copy link
Collaborator

migurski commented May 5, 2020

Thanks so much! When you have a chance, can you extend the TagTransform documentation on the wiki to reflect this new 0.48 version functionality?

@fwiesweg
Copy link
Author

Hi, yes it's on my todo list, might take a week or two but I'll do it ;)

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