Question

Create Geometry from String in an XML

  • 21 April 2017
  • 5 replies
  • 20 views

Badge

Given an XML of the form

<event>
<LineGeometry srid="4326"> x_1,y_1;x_2,y_2;x_3,y_3;....</LineGeometry>
<OtherProperty> foo</OtherProperty>
...
</event>

I would like to create the line geometry for this event.

While there are myriad of examples that match this almost completely, I always got stuck at some point. I mostly got stuck because the number of x/y pairs is not bounded, and so I coudn't find out how to properly split the LineGeometry-string into a list and then create coordinates from it.

I might want to add that I started using FME (2013 SP3) yesterday, so apologies if there is a very simple way for this that I should have seen.


5 replies

Userlevel 2
Badge +12

Extract coords from line:

Badge +22

I would one of the xml tools to extract or flatten the xml, depending on what else you want to do with the feature, such that you end up with an attribute LineGeometry containing just the coordinates. and then convert that to WKT, and replace the geometry.

 

 

 

Badge +16

have a look at the geometryreplacer transformer set to GML.

Tip try to upgrade tour FME ....if possible

Badge +22

have a look at the geometryreplacer transformer set to GML.

Tip try to upgrade tour FME ....if possible

to structure your data as gml you would need to replace the ; with a space

 

and wrap it with the gml tags.

 

<gml:LineString>
<gml:coordinates>x1,y1 x2,y2 x3,y3</gml:coordinates>
</gml:LineString>
Userlevel 2
Badge +17

have a look at the geometryreplacer transformer set to GML.

Tip try to upgrade tour FME ....if possible

If you use GML encoding, replace both , and ; with a space.

 

 

Reply