A LineBuilder will output Point, Line & Polygon depending on the coordinates supplied
So simply split the string by a space to get coordinate pairs, use a vertex creator to create points and then feed these into a LineBuilder grouping by a unique id of the original feature
Debbi at FME posted my question on my behalf.
I followed Debbi's email from FME, first, use TestFilter to direct one pair (X, Y) coordinate records to port 1, 2 pairs coordinate records to port 2, and those more than 2 pairs coordinate records to port 2.
Second, use AttributeManager to set up a new Output Attribute as:
<gml:Point>
<gml:coordinates>@Value(10TM Point Coordinates)</gml:coordinates>
</gml:Point>
Third, use GeometryReplacer: Geometry Encoding: GML, Geometry Source: the same as the above code snippet.
So far, this works for those one pair coordinate records.
However, I used the same procedure to work on port 2 (2 pairs coordinates) and port 3 (more than 2 pairs). I used following code snippet for port 2 and 3:
<gml:LineString>
<gml:coordinates>@Value(10TM Point Coordinates)</gml:coordinates>
</gml:LineString>
I haven't verified if those lines are correct. At least, some of lines are weird.
I will try those suggestions by egomm, such as use LineBuilder.
Thanks a lot.
It might be a bit complicated, but I think I would try to use a list, because you don't know how many coordinate pairs there will be (OK, you do know, but it's variable for each record).
To handle that - a list of variable length - you would need to use a customer transformer with a loop in it. I would set it up like this:
- An AttributeSplitter first of all, to split the data into coordinate pairs in a list of values
- A ListElementCounter to count the number of coordinate pairs (or you have an attribute already with this)
- An AttributeCreator to create an attribute Loop, whose value is set to 0
- A ListIndexer to fetch the values for list element number <Loop>
- A SubstringExtractor to extract separate x/y values for the string
- A VertexCreator to turn the value into a point
Then you can use a LineBuilder to build the features, knowing that the number of points is handled correctly.
I hope this helps. There is an example of looping transformers in the FME training manual and if you search for loop on this site you should also find some good example.
It might be a bit complicated, but I think I would try to use a list, because you don't know how many coordinate pairs there will be (OK, you do know, but it's variable for each record).
To handle that - a list of variable length - you would need to use a customer transformer with a loop in it. I would set it up like this:
- An AttributeSplitter first of all, to split the data into coordinate pairs in a list of values
- A ListElementCounter to count the number of coordinate pairs (or you have an attribute already with this)
- An AttributeCreator to create an attribute Loop, whose value is set to 0
- A ListIndexer to fetch the values for list element number <Loop>
- A SubstringExtractor to extract separate x/y values for the string
- A VertexCreator to turn the value into a point
Then you can use a LineBuilder to build the features, knowing that the number of points is handled correctly.
I hope this helps. There is an example of looping transformers in the FME training manual and if you search for loop on this site you should also find some good example.
Looping seems overcomplicated when you could just explode the list, create the points and then connect the points?
e.g.
Looping seems overcomplicated when you could just explode the list, create the points and then connect the points?
e.g.
That's true... but when the list is exploded I worry (probably unnecessarily) about the points staying in the same order. When everything stays in a list then I can be sure the order of points is not going to change.
A LineBuilder will output Point, Line & Polygon depending on the coordinates supplied
So simply split the string by a space to get coordinate pairs, use a vertex creator to create points and then feed these into a LineBuilder grouping by a unique id of the original feature
Egomm's approach works perfectly.
Debbi's approach also works perfectly.
The only difference is there are 5 rejected records by using GML. See the attached image.
Thank you both!
That's true... but when the list is exploded I worry (probably unnecessarily) about the points staying in the same order. When everything stays in a list then I can be sure the order of points is not going to change.
"Esrd File Number" is the unique number column in my CSV file. I used "Esrd File Number" as Connection Break Attributes in LineBuilder, which groups the same original record together. In the coordinate list, all coordinates with the same Esrd File Number are connected if coordinate pairs >=2. Yes, the order of coordinates (points) is not changed. Thank you again for your help.
Hello everyone,
I need to create a polygon by excel file row. Each row contains vertex coordinates in this format "-1.1111/11.1111 | -2.2222/22.2222 | -3.3333/33.3333".
I have already tried some transformers but i'm having troubles splitting it to X and Y single values.
Can anyone help me with this?
Thanks
A LineBuilder will output Point, Line & Polygon depending on the coordinates supplied
So simply split the string by a space to get coordinate pairs, use a vertex creator to create points and then feed these into a LineBuilder grouping by a unique id of the original feature
Hello everyone,
I need to create a polygon by excel file row. Each row contains vertex coordinates in this format "-1.1111/11.1111 | -2.2222/22.2222 | -3.3333/33.3333".
I have already tried some transformers but i'm having troubles splitting it to X and Y single values.
Can anyone help me with this?
Thanks
In this case I wouldn't try splitting it but turning it into a WKT string instead and then let the GeometryReplacer deal with it.
A WKT polygon string looks like this:
POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))
So 2 StringReplacers, one to replace / with a space and the other one to replace | with , and then an AttributeManager to wrap it in POLYGON (( and )) should do the trick.
Hello everyone,
I need to create a polygon by excel file row. Each row contains vertex coordinates in this format "-1.1111/11.1111 | -2.2222/22.2222 | -3.3333/33.3333".
I have already tried some transformers but i'm having troubles splitting it to X and Y single values.
Can anyone help me with this?
Thanks
In this case I wouldn't try splitting it but turning it into a WKT string instead and then let the GeometryReplacer deal with it.
A WKT polygon string looks like this:
POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))
So 2 StringReplacers, one to replace / with a space and the other one to replace | with , and then an AttributeManager to wrap it in POLYGON (( and )) should do the trick.