-1

I'm using a python caller in fme to create polygons from points with aixm 4.5 data

Somes of the polygons contains arcs, and theirs direction clockwise (CWA) or anti-clock wise (CCA) matters, I don't know how to handle this.

here's the code I have so far:

import fme
import fmeobjects
from math import hypot
def replaceWithArc(feature):
    coords = feature.getAllCoordinates()
    x0, y0 = coords[0][0], coords[0][1] # coordinates of start of arc
    xc, yc = coords[1][0], coords[1][1] # coordinates of cetner of arc
    x2, y2 = coords[2][0], coords[2][1] # coordinates of end of arc

    vx0, vy0 = (x0 - xc), (y0 - yc) # vector: center -> start
    vx2, vy2 = (x2 - xc), (y2 - yc) # vector: center -> end
    vx1, vy1 = (vx0 + vx2), (vy0 + vy2) # vector: center -> middle
    len = hypot(vx1, vy1) # length of the vector
    radius = (hypot(vx0, vy0) + hypot(vx2, vy2)) * 0.5
    x1, y1 = xc + vx1 / len * radius, yc + vy1 / len * radius # coordinates of middle point on arc

threePoints = (
    fmeobjects.FMEPoint(x0, y0),
    fmeobjects.FMEPoint(x1, y1),
    fmeobjects.FMEPoint(x2, y2)
)
feature.setGeometry(fmeobjects.FMEArc(threePoints))

enter image description here

oph
  • 35
  • 4
  • 1
    Does this answer your question? [How to determine if a list of polygon points are in clockwise order?](https://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order) – Joe Apr 29 '20 at 09:26
  • https://stackoverflow.com/questions/14505565/detect-if-a-set-of-points-in-an-array-that-are-the-vertices-of-a-complex-polygon?noredirect=1&lq=1 – Joe Apr 29 '20 at 09:26
  • I know which features are supposed to be clockwise or anti-clock wise, but I don't know how to create the geometry accordingly – oph Apr 29 '20 at 09:44
  • What does not work with the code? Error? Wrong results? – Joe Apr 29 '20 at 10:19
  • no error, but the output geometry with arcs don't look as expected – oph May 04 '20 at 07:33
  • Could you add an image to the question, maybe of a very simple arc, say a quarter circle, so we can see what happens? – Joe May 04 '20 at 07:48
  • yes, the grey polygon is the expected and red my current result – oph May 05 '20 at 08:49

1 Answers1

0

This looks to me like there is something wrong with the three points. Could you please paste the values?

From the image above it looks slightly asymmetric, but I could be wrong.

Another thing that you could try is to use a different function to initialize FMEArc, e.g.

  • init(twoPoints, bulge)
  • init(centerPoint, rotation, primaryRadius, secondaryRadius, startAngle, sweepAngle, startPoint, endPoint)
Joe
  • 6,758
  • 2
  • 26
  • 47