[mapserver-users] drawing a circle

Sucharita Samuel iworktech.sucharita at gmail.com
Mon Sep 8 03:20:19 EDT 2008


Hi ramya,
              I was able to draw a circle on the map with specified radius.
I have done this in C#.net. Following steps will help you achieve the
desired result.

First, initialize the scale of the map by doing map.prepareQuery(); map is
nothing but the mapobject
Then,get the scale of the map
Divide the screen map resolution by 2.54 (because 1cm = 2.54 pixels).
 The above 3 steps are needed to get a circle of exact radius, else the
circle will not be accurate.

    4.   Get the image point that is clicked on the map (i.e. the center of
the circle) and       convert the image point to map point (i.e. pixel to
point).
    5.    Use
if (layer.queryByPoint(map, point, mapscript.MS_SINGLE, tolerance) ==
(
int)MS_RETURN_VALUE.MS_SUCCESS)
to identify the feature.
   6.  Open the layer using layer.open();
   7.  Divide the radius by the scale and multiply by 1000 to convert
centimeter to kilometer   (scale returned by the map object (in
centimeters))
  8.Create a shape object for circle
shapeObj
oShp = new shapeObj((int)MS_SHAPE_TYPE.MS_SHAPE_POLYGON);
 9. Add a line object to the above created shape object.
10. Apply a for loop to get the points on the circumference of the circle
and add it to the line object.
for
(int iDegree = 0; iDegree <= 360; iDegree = iDegree + 10)
 For circle, we need the for loop to go from 0 to 360 degrees.

11. Once all the points are added to the line object, after the end of the
for loop, add that line to the shape object (for circle).
oShp.add(oLine);
12. Once you get the shape, create a temporary layer and assign the
properties/attributes like opacity, outline color, color of circle etc.
13. Finally, draw this layer and call the layer.close() method .

 Thanks and Regards,
Sucharita Samuel
iWorkTechnologies Pvt. Ltd., Pune



On Sun, Sep 7, 2008 at 9:20 PM, ramya srinivasan <hellomps at gmail.com> wrote:

> Hi all,
>  * I want to draw a circle with the center clicked by the user on the
> map.Can anyone help me??*
> **
> *Thanks*
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080908/6eebd141/attachment.html


More information about the mapserver-users mailing list