Skip to main content
Question

Test for Closed Polyline


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

17 replies

itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • February 28, 2017

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


itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • February 28, 2017

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.


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • February 28, 2017

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


david_r
Celebrity
  • February 28, 2017

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.


david_r
Celebrity
  • February 28, 2017
ebygomm wrote:

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.

ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • February 28, 2017

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


itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • February 28, 2017
david_r wrote:

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!

 

 


  • February 28, 2017
itay wrote:

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!

 

 


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • February 28, 2017
david_r wrote:
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

 

 


  • February 28, 2017
david_r wrote:

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?

  • February 28, 2017
ebygomm wrote:

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.

 

 


takashi
Evangelist
  • March 1, 2017

Hi there, why not use the ClosedCurveFilter transformer?


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • March 1, 2017
jimo wrote:
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?

 

 


david_r
Celebrity
  • March 1, 2017
jimo wrote:
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.

  • March 1, 2017
ebygomm wrote:

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.

 

 


  • March 1, 2017
takashi wrote:

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.

 

 


david_r
Celebrity
  • March 1, 2017
takashi wrote:

Hi there, why not use the ClosedCurveFilter transformer?

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

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings