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)
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)
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.