Re: [OpenMap Users] OMCircle Distortion?

From: Christopher Franklin <>
Date: Tue, 29 Jul 2008 11:43:25 -0400

I am attaching 2 screen shots to help illustrate what exactly I am
trying to explain here. In the pictures, the circle that is being drawn
is exactly the same size. The only thing that has changed is the center

To define a circle I click once to set the center and I click a second
time to set where I want the edge of that circle. Using that method I
would expect the edge of the circle to be drawn through my current mouse
position. The handle is being added to the location where the mouse was
clicked and to the original center location. Whenever I click to the
N/S line the handle lines up with the edge, however when I click closer
to the E/W line the handle is being drawn where I click and the edge of
the circle is being drawn further out. The arguments to OMCircle are the
center LatLon that I am generating on the first click and the distance
calculated between my first click and my second click as the radius.

I do understand that graphically it isn't going to look much like a
circle, but mathematically it should all calculate out. When I printed
out the values of both the Screen coordinates and the converted Lat/Lon
I can plug those numbers into the distance formula and see that the
radius I should have is correct, as well as finding a point on a circle
I can see the edge handle is being drawn at the correct Lat/Lon position
to be on the edge of the circle. Looking through the code again I can
see one place where this problem may be occurring... I am using an
offset on the Edge Handle OMGraphic. The graphic is 16x16px and I am
using an offset of 7 pixels to display it from the center instead of the
corner. Could this be causing the huge offset seen in the picture above?

Thank you for all your help on this!

Don Dietrick wrote:
> OMCircle basically does what your are doing - it finds the points at
> different angles at the same distance from the center, and then
> connects those points as a polygon.
> I'm not sure why your handle would show up in a different place than
> the circle edge, especially if the N/S points are lining up, but I
> don't understand your algorithm for finding the E/W handle (distance
> from the center to that point).
> - Don
> Christopher Franklin wrote:
>> Hi Don,
>> Thanks for replying so quickly.
>> Don Dietrick wrote:
>>> Hi Chris,
>>> Christopher Franklin wrote:
>>>> Greetings,
>>>> I am working on a project that requires a user to select an area on
>>>> the map by using a circle. The user clicks to select the center and
>>>> then again to select the edge (radius). I am using an OMCircle
>>>> because it exhibits the proper behavior for a circle on a globe.
>>>> I have noticed a problem with the OMCircle though. After drawing it
>>>> using the provided center and radius I am adding a graphic to
>>>> represent the center and another to represent the rightmost edge of
>>>> the circle. When the circle is drawn on or near the equator
>>>> everything appears correct. However, if the circle is drawn north
>>>> or south there is a noticeable distortion in how the circle and the
>>>> edge handle are drawn. I have done some experimentation and
>>>> discovered that the handle is being drawn in the correct location,
>>>> but the edge of the circle is not. The further away from the
>>>> equator the greater the discrepancy between my handle location and
>>>> the OMCircle edge. If, however, I move the handle to the top of the
>>>> circle it is always drawn in the correct location. For usability
>>>> purposes I would like the handle to be on the right hand side! Is
>>>> there a way to fix this? If not, I guess they will have to deal
>>>> with the handle being on the top or bottom of the circle...
>>> How are you creating the handle location, and what are its location
>>> parameters? How do you know the handle is in the right place?
>> The handle location is being generated by taking the current position
>> of the center in Lat/Lon and adding the circle radius to the
>> Longitude. To generate the the handle position on the "top" of the
>> circle I instead added the radius to the Latitude.
>> To determine that the handle was in the proper location took a bit of
>> experimentation. I have the ability to produce multiple circles at a
>> time. By experimentation I determined that by clicking on the center
>> of the circle and my artificial handle I was able to create the same
>> size of circle. If I click on the center and then put the radius on
>> the displayed circle edge I get a new circle with the edge handle
>> being drawn in the location of my second mouse click, but the drawn
>> edge of the circle is about 1 degree further out. The distance of the
>> distortion increases the further away from the equator I place the
>> circle. The problem persists at lower levels of zoom, although the
>> ratio of distances stays the same, just the scale changes. For
>> instance at a 100k zoom level the circle edge would be drawn about
>> 1k further out than it should be.
>> I hope this helps make the problem clearer... it is easier to see
>> than to describe in words!
>>> OMCircles created with distance radius shouldn't appear as circles
>>> in certain projections when you move away from the equator. Pixel
>>> distance from the center will vary along the circle edge for the
>>> same distance (depends on latitude, angle on edge from center).
>> I realize this. In fact, the problem I am trying to describe is
>> actually drawing the circle as far more circular than it actually
>> should be. The handle I am laying down shows that the circle is
>> slightly off from where it should be. I am going to go out on a limb
>> here and hypothesize that what it looks like is the 800m difference
>> between 1 degree lat and 1 degree lon is not being taken into
>> account. Feel free to slap me if I am wrong on that one!
>>>> Another problem I would like to bring up is when zoomed in to a
>>>> small area (~1m scale) the OMCircle draws as a polygon
>>>> approximation of a circle. Is there a way to increase the number of
>>>> segments being drawn at that low of scale?
>>> OMCircles let you set the number of segments used to represent the
>>> circle, but you might be seeing a precision problem that occurs from
>>> using floats in the OMCircle. The next version of OpenMap will
>>> address the precision problem.
>>> Hope this helps,
>>> Don
>>> --
>>> [To unsubscribe to this list send an email to ""
>>> with the following text in the BODY of the message "unsubscribe
>>> openmap-users"]
>> I hope this clarifies things a little for you. If not let me know and
>> I can either clarify more or post some code if that would help.
>> Thanks,
>> Chris
>> --
>> [To unsubscribe to this list send an email to ""
>> with the following text in the BODY of the message "unsubscribe
>> openmap-users"]
> --
> [To unsubscribe to this list send an email to ""
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]

[To unsubscribe to this list send an email to ""
with the following text in the BODY of the message "unsubscribe openmap-users"]

(image/jpeg attachment: not_offset.jpg)

(image/jpeg attachment: offset.jpg)

Received on Tue Jul 29 2008 - 11:45:22 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT