Draw a circle

OseiOsei Global Mapper UserPosts: 119Trusted User
edited January 2009 in SDK
Is there a method with which I can draw ellipses and circles. I am able to do that in the Global Mapper application but I cant find a function in the SDK that can do that for me.
Is it possible?

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited May 2008
    In the SDK you just have to do the math yourself to generate a list of XY coordinate values to form the ellipse or circle, then create a new line or area feature based on those and add it to your custom vector layer.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • OseiOsei Global Mapper User Posts: 119Trusted User
    edited May 2008
    Thanks. The pseudocode is as follows

    for(i = 0 to 49)
    Take x = (i / 50) * radius
    Compute y value ( y = sqrt(r*r - x*x)

    Add (x,y) 1st Quadrant
    Add (y,-x) 2nd Quadrant
    Add (-x,-y) 3rd Quadrant
    Add(-y, x) 4th Quadrant
    next i

    Offset all points by centre
  • DilysDilys Global Mapper User Posts: 41Trusted User
    edited January 2009
    Hi Mike,

    I am working on a project that creates a number of rings with a same center point and move the rings around the map all the time.

    I am using the similar method that Osei suggested to create the rings. I calculate the coordinate of all the points on the rings and draw the rings, and recalculate the entire coordinate of points when move the rings.

    Is there any SDK function which is similar to the ‘Create Range Ring(s)…” function in the Global Mapper application?

    The SDK function takes 4 parameters, number of Range Rings, Range Ring Radius, the unit of the Range Ring Radius, and the center point of the ring(s) to draw the rings with the same center point. Also the scale of those rings can fit to the projection of map when they move.

    Cheers
    Dilys
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited January 2009
    Dilys,

    While there is not currently a method like you describe to create a range ring, you could easily generate your own range ring by using the GM_CalcProjectedLocation function. Just call that function for a series of bearing values (say every 1 degree around a circle) to get a list of points forming your range ring, then create the area or line feature with the GM_AddAreaToVectorLayer or GM_AddLineToVectorLayer functions.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
Sign In or Register to comment.