Select to view content in your preferred language

Elliptic arc segment units

1233
4
Jump to solution
01-06-2022 02:45 AM
Tone
by
Emerging Contributor

Hi,

I need to draw an arc of circle on the map for our app, so I'm using the EllipticArcSegment as defined here : create circular elliptic arc segment

Does this method expect a radius in degrees since I am working with WGS84 as a spatial reference ? I can't really figure out what units it is expecting for length and angles.

 

The problem is that I have the radius in meters and the angles in radians. Is there any way I could convert them into the expected units, or is there another method that I'm missing that can handle meters/radians ?

0 Kudos
1 Solution

Accepted Solutions
MarkBaird
Esri Regular Contributor

Hi @Tone 

The elliptic arc works on radians for the angles and the radius will be the unit of measure used in the spatial reference of the centre point.  So if your centre point is in WGS84 then the radius will be in decimal degrees.

Having a radius measured in decimal degrees is likely to be confusing so my strategy here is as follows:

 - Create the point in WGS 84 

 - Project the point into a projected coordinate system which uses metres as its unit of measure.  Web mercator is a commonly used one, but you might want to use a local coordinate system such as a UTM zone for example.

 - Create the elliptic arc using the projected point, and the radius you pass in will be in metres.  

I've written some basic code to show this in action where I've drawn a 45degree arc (converted to radians) off the East coast of Scotland.

    // set up spatial references
    SpatialReference wgs84 = SpatialReferences.getWgs84();
    SpatialReference webMercator = SpatialReferences.getWebMercator();

    // make a point in lat/long (WGS84)
    Point centrePoint = new Point(-2.5,56, wgs84);

    // project it to a mercator projection where the unit of measure is metres
    Point mercatorPoint = (Point) GeometryEngine.project(centrePoint, webMercator);

    // create an arc segment which is 50Kilometers radius, starting at 90 degrees, the arc angle is 45 degrees clockwise
    EllipticArcSegment arcSegment = EllipticArcSegment.createCircularEllipticArc(mercatorPoint, 50000,Math.toRadians(90), Math.toRadians(-45), webMercator);

    // make a part with the segment
    Part part = new Part(webMercator);
    part.add(arcSegment);

    // create the line from the part
    Polyline line = new Polyline(part);

    // add it to a graphic and graphics overlay to allow us to visualise it
    Graphic arcGraphic = new Graphic(line, lineSymbol);
    graphicsOverlay.getGraphics().add(arcGraphic);

 

The result looks like this:

MarkBaird_0-1641493190648.png

Does this help?

View solution in original post

0 Kudos
4 Replies
MarkBaird
Esri Regular Contributor

Hi @Tone 

The elliptic arc works on radians for the angles and the radius will be the unit of measure used in the spatial reference of the centre point.  So if your centre point is in WGS84 then the radius will be in decimal degrees.

Having a radius measured in decimal degrees is likely to be confusing so my strategy here is as follows:

 - Create the point in WGS 84 

 - Project the point into a projected coordinate system which uses metres as its unit of measure.  Web mercator is a commonly used one, but you might want to use a local coordinate system such as a UTM zone for example.

 - Create the elliptic arc using the projected point, and the radius you pass in will be in metres.  

I've written some basic code to show this in action where I've drawn a 45degree arc (converted to radians) off the East coast of Scotland.

    // set up spatial references
    SpatialReference wgs84 = SpatialReferences.getWgs84();
    SpatialReference webMercator = SpatialReferences.getWebMercator();

    // make a point in lat/long (WGS84)
    Point centrePoint = new Point(-2.5,56, wgs84);

    // project it to a mercator projection where the unit of measure is metres
    Point mercatorPoint = (Point) GeometryEngine.project(centrePoint, webMercator);

    // create an arc segment which is 50Kilometers radius, starting at 90 degrees, the arc angle is 45 degrees clockwise
    EllipticArcSegment arcSegment = EllipticArcSegment.createCircularEllipticArc(mercatorPoint, 50000,Math.toRadians(90), Math.toRadians(-45), webMercator);

    // make a part with the segment
    Part part = new Part(webMercator);
    part.add(arcSegment);

    // create the line from the part
    Polyline line = new Polyline(part);

    // add it to a graphic and graphics overlay to allow us to visualise it
    Graphic arcGraphic = new Graphic(line, lineSymbol);
    graphicsOverlay.getGraphics().add(arcGraphic);

 

The result looks like this:

MarkBaird_0-1641493190648.png

Does this help?

0 Kudos
Tone
by
Emerging Contributor

Perfect, thank you @MarkBaird.

For what it's worth, I think this should be mentioned in the official documentation.

0 Kudos
dasmap
by
New Contributor

MarkBaird, I found some bugs in EllipticArcSegment.createCircularEllipticArc method.

If you use WebMercator in this method and draw Circle (startAngle=centerAngle=0), you result Circle will never have correct Radius. You can ensure if you compare Radius of your drawn Circle with corresponding points lying under your Arc on some other maps (Google Maps, for Example) and measure range to them from Center point.

Perhaps, this is because developers inside of method convert Range in meters to Range in degrees using Latitude degrees instead of Longitude degrees.

So, I don't recommend your way of using EllipticArcSegment.createCircularEllipticArc method with WebMercator spatial reference. It leads to bad result!

Correct way will be to convert Radius in meters to Radius in Degrees(decimal) using mathematical methods, something like calculating geodetic coordinates of Point2 lying on Polar coordinates (azimuth=90deg, range=Radius(m)) from our Center of Arc radius. Then, Radius(in degrees) should be caltulated as Math.Abs(LongitudePoint2-LongitudeCenter).

After that, correct results will be by using EllipticArcSegment.createCircularEllipticArc method with Wgs84 spatial reference.

But, another bug you will see at last step only if you will use some angles for Arc instead of  Circle drawing. And this is a next story...

0 Kudos
MarkBaird
Esri Regular Contributor

That's a fair point about the documentation, I've fed that information back to our geometry team.

0 Kudos