Is there a simple way to use the geometry attribute with structure lat,lon,lat,lon… and convert these values to vertices? I assume I have to use vertexcreator? But I do not want to define all nodes separate.
Does someone know a smart way to do this in fme ?
Thanks in advance
Best answer by bwn
Agree with @s.jager , there are a couple of ways to do it. One involves RegEx to get a string in WKT format. Another involves using AttributeSplitter to build the values into a list and then separate the “Odd” list index values for Longitude values and the “Even” list index values for Latitude to send these to a VertexCreator → LineBuilder
To build out the original great idea though is to need probably some RegEx, as there are two issues in the raw API string preventing easily building a WKT:
In the raw string the latitude values (Y) are before the longitude values (X). These need to be swapped around for WKT as X Y.
In the raw string, the same delimiter “,” is used between the X Y value-tuple and also between the coordinate pairs. The X,Y value separator in WKT needs to be a space character instead of “,” so only these commas, and not the other commas, need to be replaced with a space character.
Now, below this is not the most precise of RegEx expressions to use in StringReplacer (and there are way more capable RegEx people than me on this forum! 😉), but it should do the job
Sample Data
The core component is then a StringReplacer to transform the string into an inner WKT tuple type format. These swaps the positions of the Y string value (RegEx Group \1) for the X string value (RegEx Group \2) and puts a space character as the separator. If there is a “,” after them (RegEx Group \3) then put that back in as well after the X Y value pair.
This gives on the Output Eg.
From here it is trivial to wrap this inside a WKT LINESTRING(...) and send to a WKT GeometryReplacer
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.
Agree with @s.jager , there are a couple of ways to do it. One involves RegEx to get a string in WKT format. Another involves using AttributeSplitter to build the values into a list and then separate the “Odd” list index values for Longitude values and the “Even” list index values for Latitude to send these to a VertexCreator → LineBuilder
To build out the original great idea though is to need probably some RegEx, as there are two issues in the raw API string preventing easily building a WKT:
In the raw string the latitude values (Y) are before the longitude values (X). These need to be swapped around for WKT as X Y.
In the raw string, the same delimiter “,” is used between the X Y value-tuple and also between the coordinate pairs. The X,Y value separator in WKT needs to be a space character instead of “,” so only these commas, and not the other commas, need to be replaced with a space character.
Now, below this is not the most precise of RegEx expressions to use in StringReplacer (and there are way more capable RegEx people than me on this forum! 😉), but it should do the job
Sample Data
The core component is then a StringReplacer to transform the string into an inner WKT tuple type format. These swaps the positions of the Y string value (RegEx Group \1) for the X string value (RegEx Group \2) and puts a space character as the separator. If there is a “,” after them (RegEx Group \3) then put that back in as well after the X Y value pair.
This gives on the Output Eg.
From here it is trivial to wrap this inside a WKT LINESTRING(...) and send to a WKT GeometryReplacer
It works for me with RegularExpressions to create a wkt geometry and afterwards using GeometryReplacer. Sometimes it is difficult to find the correct syntax of the RegEx.