Skip to main content

I want to test polylines for closed polylines. Is there a transformer or easy way to do this? I realize that I can extract the points in the polylines with the vertex extractor and turn them into a list with the ListBuilder, but I can't figure out how to compare _list{0}._x with _list{-1}._x. The Tester does not allow _list{-1}._x. There is also no "ListPopper" that I can see.

Thanks

you can also extract the first and last (say x0 y0 and x1 y1) vertices instead of the list option and use the tester.


another option is to pass the lines into the areabuilder without any snapping.

Closed poly lines will be transformed into polygons not closed ones will be rejected.

Hope this helps.


Or use a geometry coercer, closed lines can be coerced into polygons, other lines will be output via the untouched port


Here's using a Tester and a formula entered into the arithmetic editor:

Closing polylines will be output as Passed.

You could also start with a Snapper with a Group By on the OBJECTID (or similar) and a tiny tolerance, if needed.


Or use a geometry coercer, closed lines can be coerced into polygons, other lines will be output via the untouched port

Yes, that was exactly my thought as well. But the issue then is that you've lost the original geometry.

If you want to just do the coordinate comparison you can use two coordinate extractors one to get the start and one to get the end and then compare these two values, e.g.

I've put an idea forward for the coordinate extractor to be able to extract first and last coordinates only which would be useful for situations like this

https://knowledge.safe.com/idea/39951/coordinate-extractor-first-and-last-coordinates-on.html

Although after reading the answer from @david_r it's probably not necessary as I realise you could do this in a single transformer using the syntax suggested


Here's using a Tester and a formula entered into the arithmetic editor:

Closing polylines will be output as Passed.

You could also start with a Snapper with a Group By on the OBJECTID (or similar) and a tiny tolerance, if needed.

Nice one!

 

 


another option is to pass the lines into the areabuilder without any snapping.

Closed poly lines will be transformed into polygons not closed ones will be rejected.

Hope this helps.

Testing for polygons seems to be the simplest solution. Thanks!

 

 


Yes, that was exactly my thought as well. But the issue then is that you've lost the original geometry.
You could always coerce them back to lines again afterwards but the tester solution you've proposed looks better imo

 

 


Here's using a Tester and a formula entered into the arithmetic editor:

Closing polylines will be output as Passed.

You could also start with a Snapper with a Group By on the OBJECTID (or similar) and a tiny tolerance, if needed.

I tried this but could not find @Coordinate in the Arithmetic Editor or anywhere else. I typed it in but all of the polylines failed. Is there another step before I get @Coordinate?

If you want to just do the coordinate comparison you can use two coordinate extractors one to get the start and one to get the end and then compare these two values, e.g.

I've put an idea forward for the coordinate extractor to be able to extract first and last coordinates only which would be useful for situations like this

https://knowledge.safe.com/idea/39951/coordinate-extractor-first-and-last-coordinates-on.html

Although after reading the answer from @david_r it's probably not necessary as I realise you could do this in a single transformer using the syntax suggested

This did work.

 

 


Hi there, why not use the ClosedCurveFilter transformer?


I tried this but could not find @Coordinate in the Arithmetic Editor or anywhere else. I typed it in but all of the polylines failed. Is there another step before I get @Coordinate?
Did you make sure you typed it in in the arithmetic editor rather than the text editor?

 

 


I tried this but could not find @Coordinate in the Arithmetic Editor or anywhere else. I typed it in but all of the polylines failed. Is there another step before I get @Coordinate?
That's correct, you wont find the Coordinate function listed in the arithmetic editor, you have to type it in yourself.

If you want to just do the coordinate comparison you can use two coordinate extractors one to get the start and one to get the end and then compare these two values, e.g.

I've put an idea forward for the coordinate extractor to be able to extract first and last coordinates only which would be useful for situations like this

https://knowledge.safe.com/idea/39951/coordinate-extractor-first-and-last-coordinates-on.html

Although after reading the answer from @david_r it's probably not necessary as I realise you could do this in a single transformer using the syntax suggested

It would be simpler, except my FME 2016.1.3.1 Build 16716 WIN32 doesn't recognize "@Coordinate". The CoordinateExtractor idea does work because you can specify index 0 for the start and index -1 for the end.

 

 


Hi there, why not use the ClosedCurveFilter transformer?

This might be the better answer because it tests not only for beginning and ending coordinates, but any loop in between.

 

 


Hi there, why not use the ClosedCurveFilter transformer?

Agreed, this probably ought to be the best answer. Also works on aggregates.

 

 


Reply