Question

Reading Openstreetmap and writing it right back loses tags?

  • 4 January 2018
  • 4 replies
  • 2 views

Badge +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

Userlevel 2
Badge +17

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.

Badge +1

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"/>
Userlevel 2
Badge +17

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

Badge +9

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

Reply