Skip to main content

Hi,

I have been trying to create a multi-component polygon consisting of line, linestring and arc. The arc parameter consists of Start/From, Centre, End/To, the Radius in metres as well as the arc direction, clockwise or anti-clockwise. Negative radius indicates anti-clockwise arc.

 

Using the python script posted by @takashi in here, I was able to generate most arc except for some instances. In the sample data, I have included 3 polygons. While ID=47 works fine, the other two polygons (ID=407 and ID=482) failed. I tried the Arc Property Setter method in the same post, unfortunately it yields an undesired gap at end points.

 

I have attached the csv file containing the 3 polygons records and the FME workbench. Any help will be much appreciated.

 

Thanks in advance.

Lawrence

 

Correct output polygons for ID=407 and ID=482 as shown.

Looking at polygon with ID 407, it appears that record 11 has a radius that isn't correct given the start and end and centre points, if you calculate the radius from the centre point then the arc will be created.

Slightly problematic in this case, as the negative radius is indicating whether a clockwise or counterclockwise arc should be created

You could change the python slightly to resolve this, but it's probably worth checking the source data (you also need to change the snapping tolerance)

from fmeobjects import FMEPoint, FMEArc
import math
def createArc(feature):
    x0 = float(feature.getAttribute('fromPointX'))
    y0 = float(feature.getAttribute('fromPointY'))
    x1 = float(feature.getAttribute('toPointX'))
    y1 = float(feature.getAttribute('toPointY'))
    xc = float(feature.getAttribute('centrePointX'))
    yc = float(feature.getAttribute('centrePointY'))
    r = math.sqrt((x0-xc)**2+(y0-yc)**2)
    if float(feature.getAttribute('Radius')) <0:
        r = r*-1
    arc = FMEArc((FMEPoint(x0, y0), FMEPoint(x1, y1)), abs(r), r < 0)
    feature.setGeometry(arc)

0684Q00000ArJP7QAN.png


Looking at polygon with ID 407, it appears that record 11 has a radius that isn't correct given the start and end and centre points, if you calculate the radius from the centre point then the arc will be created.

Slightly problematic in this case, as the negative radius is indicating whether a clockwise or counterclockwise arc should be created

You could change the python slightly to resolve this, but it's probably worth checking the source data (you also need to change the snapping tolerance)

from fmeobjects import FMEPoint, FMEArc
import math
def createArc(feature):
    x0 = float(feature.getAttribute('fromPointX'))
    y0 = float(feature.getAttribute('fromPointY'))
    x1 = float(feature.getAttribute('toPointX'))
    y1 = float(feature.getAttribute('toPointY'))
    xc = float(feature.getAttribute('centrePointX'))
    yc = float(feature.getAttribute('centrePointY'))
    r = math.sqrt((x0-xc)**2+(y0-yc)**2)
    if float(feature.getAttribute('Radius')) <0:
        r = r*-1
    arc = FMEArc((FMEPoint(x0, y0), FMEPoint(x1, y1)), abs(r), r < 0)
    feature.setGeometry(arc)

0684Q00000ArJP7QAN.png

Thanks so much @ebygomm. That works. The radius as published are in nautical miles and may likely be approximate only.test4.csv

Now I encounter another arc that failed using your script but worked using the original from @takashi. Can you explain why? Attached is the polygon data.

Thanks again.


Thanks so much @ebygomm. That works. The radius as published are in nautical miles and may likely be approximate only.test4.csv

Now I encounter another arc that failed using your script but worked using the original from @takashi. Can you explain why? Attached is the polygon data.

Thanks again.

The centre point given is not equidistant from the start and end point so it is not possible to create the arc.
The centre point given is not equidistant from the start and end point so it is not possible to create the arc.

Ok, understood. Now I just need to flag unequal start/end to centre distance in the workflow.


Reply