Skip to main content
Question

Reading Openstreetmap and writing it right back loses tags?


Forum|alt.badge.img+1

I have a set of nodes on this format:

<node lat="56.07686365" lon="12.11483240" id="800000002" changeset="1" timestamp="2017-09-10T20:50:35.826Z" version="1">
  <tag k="ActiveFrom" v="1900-01-01T02:00:00.000000000Z"/>
  <tag k="ActiveTo" v="3000-01-01T01:59:59.000000000Z"/>
  <tag k="ProductionPointCategory" v="4"/>
</node>

When I read them in to the OSM reader as basic nodes, I get a list of tag{}.k and tag{}.v. I want to do some light filtering on this data, mainly checking if they exist in another dataset.

Thereafter, I want to write them back to the same format that they came from. However, if I just connect the reader straight to the writer, it doesn't write out any of the content of the tag-list. I have to expose all the attributes that I want to be written, which seems like a backwards idea since the information is already there in the key-part of the tag-list.

Is there a way to get the writer to write the contents of the tag-list, without me manually exposing the attributes? There will be nodes of different forms, so "hard-coding" this via the attributeExposer isn't optimal.

4 replies

takashi
Contributor
Forum|alt.badge.img+23
  • Contributor
  • January 4, 2018

I'm not sure what is your desired format of the destination"tag-list", but if you need to just concatenate tag names (elements of tag{}.k) with a specific delimiter, the ListConcatenator could do that.


Forum|alt.badge.img+1
  • Author
  • January 8, 2018
takashi wrote:

I'm not sure what is your desired format of the destination"tag-list", but if you need to just concatenate tag names (elements of tag{}.k) with a specific delimiter, the ListConcatenator could do that.

Hi!

 

 

No, I actually need to remove some tags and add some others, so I need to do some relative simple list manipulations - which I've figured out, but then I want to write the tag-list back to the OSM XML format, so it looks like:

 

 

<tag k="keyName" v="value"/>

takashi
Contributor
Forum|alt.badge.img+23
  • Contributor
  • January 8, 2018

Sounds the requirement is to update the XML document. If so, the XMLUpdater or the XMLXQueryUpdater might help you. See these simplified examples (FME 2017.0)

The examples remove a <tag> element having k="ProductionPointCategory" from the source XML (<node> element), and insert a new <tag> element having k="keyName" and v="value".

Source

<node lat="56.07686365" lon="12.11483240" id="800000002" changeset="1" timestamp="2017-09-10T20:50:35.826Z" version="1">  <tag k="ActiveFrom" v="1900-01-01T02:00:00.000000000Z"/>  <tag k="ActiveTo" v="3000-01-01T01:59:59.000000000Z"/>  <tag k="ProductionPointCategory" v="4"/></node>

Result

<node lat="56.07686365" lon="12.11483240" id="800000002" changeset="1" timestamp="2017-09-10T20:50:35.826Z" version="1">  <tag k="ActiveFrom" v="1900-01-01T02:00:00.000000000Z"/>  <tag k="ActiveTo" v="3000-01-01T01:59:59.000000000Z"/>  <tag k="keyName" v="value"/></node>

XMLUpdater Example

0684Q00000ArLf7QAF.png

XMLXQueryUpdater Example

0684Q00000ArLwKQAV.png


gabriel_hirsch
Contributor
Forum|alt.badge.img+11

This one is filed as PR#81352 and since FME 2018.0 b18255 it works to write back tags for nodes/ways/relations.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings