Skip to main content
Solved

Extract the middle coordinate of a three point arc


Forum|alt.badge.img

Hi! I would like to extract the middle coordinate of a three point arc. With the ArcPropertyExtractor I only get start, end and center point coordinates. The mid point does not necessarily be in the middle of the arc, but helps to describe it, together with the start and end point.

Thanks a lot!!

Best answer by takashi

Hi @schulthesskatha, if the arc was made of three points, a PythonCaller with this script extracts the coordinates of the mid-point. Otherwise, the method "getMidPoint()" returns interpolated half way point.

# PythonCaller Script Example
import fmeobjects
def extractMidPointOfArc(feature):
    arc = feature.getGeometry()
    if isinstance(arc, fmeobjects.FMEArc):
        coord = arc.getMidPoint().getXYZ()
        feature.setAttribute('_x', coord[0])
        feature.setAttribute('_y', coord[1])

See the Python FME Objects API Reference (fmeobjects.FMEArc class) to learn more.

View original
Did this help you find an answer to your question?

10 replies

pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • December 21, 2017

Hi,

Have you tried snipper with vertex percentage 50-50 option along with coordinate extractor?


erik_jan
Contributor
Forum|alt.badge.img+18
  • Contributor
  • December 21, 2017

Not sure, but would the CoordinateExtractor with index 1 work?

Index 0 should be start and index 2 should be end point.


Forum|alt.badge.img
pratap wrote:

Hi,

Have you tried snipper with vertex percentage 50-50 option along with coordinate extractor?

That is unfortunately not exactly what I need. That would give me the point exact halfway of the arc. But I need the mid point that describes the form of the arc (see this link under last section "ArcBy3Points"). They explain it, but do not tell, how they calculate it.

 

 


Forum|alt.badge.img
erik_jan wrote:

Not sure, but would the CoordinateExtractor with index 1 work?

Index 0 should be start and index 2 should be end point.

Thanks a lot! Unfortunately that doesn't work. With index 1, the coordinates are 0. For index 0 and -1 both the center point (from the ellipse) are calculated. I find it quite difficult to extract the geometry information (which obviously is somewhere, seen in the attached picture) into an attribute.. Maybe you know more about it?

 

 


takashi
Influencer
  • December 22, 2017
pratap wrote:

Hi,

Have you tried snipper with vertex percentage 50-50 option along with coordinate extractor?

The exact halfway point is also a mid-point. What kind of "mid-point" do you need?

 

 


pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • December 22, 2017

Please provide example to understand better


Forum|alt.badge.img

Hi Takashi. You are right. There are indeed many points describing an arc, also the one exact halfway. In the below example (highligthed in yellow and illustrated in the arc), it is not the midpoint exact halfway, but somewhere between start and end point. Somehow, fme gets this coordinate from the incoming data, but I cannot find, where to extract this information from the IFMEArc geometry. Is this at all possible?


Forum|alt.badge.img
pratap wrote:

Please provide example to understand better

Hi! Attached a screenshot of the problem. You see, the arc has a mid point, which is not exactly half way, but also given in the geometry. And I'd like to extract the coordinates of this red point ("Mid Point") to a new attribute. All I can extract with CoordinateConcatenator is Start, End and Center Point (the last one is the middle of the ellipse).

 

example-fme.png

 

 


takashi
Influencer
  • Best Answer
  • December 22, 2017

Hi @schulthesskatha, if the arc was made of three points, a PythonCaller with this script extracts the coordinates of the mid-point. Otherwise, the method "getMidPoint()" returns interpolated half way point.

# PythonCaller Script Example
import fmeobjects
def extractMidPointOfArc(feature):
    arc = feature.getGeometry()
    if isinstance(arc, fmeobjects.FMEArc):
        coord = arc.getMidPoint().getXYZ()
        feature.setAttribute('_x', coord[0])
        feature.setAttribute('_y', coord[1])

See the Python FME Objects API Reference (fmeobjects.FMEArc class) to learn more.


Forum|alt.badge.img
takashi wrote:

Hi @schulthesskatha, if the arc was made of three points, a PythonCaller with this script extracts the coordinates of the mid-point. Otherwise, the method "getMidPoint()" returns interpolated half way point.

# PythonCaller Script Example
import fmeobjects
def extractMidPointOfArc(feature):
    arc = feature.getGeometry()
    if isinstance(arc, fmeobjects.FMEArc):
        coord = arc.getMidPoint().getXYZ()
        feature.setAttribute('_x', coord[0])
        feature.setAttribute('_y', coord[1])

See the Python FME Objects API Reference (fmeobjects.FMEArc class) to learn more.

Hi Takashi! It worked!! Thanks a lot, I'm very happy :)

 

 


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