[mapserver-users] How to draw a circle with a centroid and radius

Sucharita Samuel iworktech.sucharita at gmail.com
Mon May 12 06:31:15 EDT 2008


Hi Friends,
               I am really stuck up with this for a long time now. As far as
I have googled, I have found that to draw a circle, either using a mapfile
or dynamically using a mapscript, the circle has to be defined by two set of
points of its bounding rectangle. The image that I get on my screen is a
circle (because the layer is defined as a circle), but to draw this circle,
a set of two points is used which ultimately is a line. I will provide my
code sample below,

DrawCircle(double x, double y, double dRadius)
{
         double minx = x - dRadius;
         double miny = y + dRadius;
         double maxx = x + dRadius;
         double maxy = y - dRadius;

         //upper left corner of the bounding rectangle
         pointObj oPointMin = pixel2point(new pointObj(minx, miny, 0, 0));

        //lower right corner of the bounding rectangle
         pointObj oPointMax = pixel2point(new pointObj(maxx, maxy, 0, 0));

         lineObj oLine = new lineObj();
         oLine.add(oPointMin);
         oLine.add(oPointMax);
         shapeObj oShp = new shapeObj((int)MS_SHAPE_TYPE.MS_SHAPE_LINE);
          oShp.add(oLine);

        // Creation of a temporary layer (for circle)
                       layerObj oTempLayer = new layerObj(map);
                        oTempLayer.name = "UserCircle";
                        oTempLayer.status = 1;
                        oTempLayer.type = MS_LAYER_TYPE.MS_LAYER_CIRCLE;
                        classObj oTempClass = new classObj(oTempLayer);
                        styleObj oStyle = new styleObj(oTempClass);
                        oStyle.outlinecolor.setRGB(0, 0, 0);
                        oStyle.color.setRGB(255, 227, 255);
                        oTempLayer.addFeature(oShp);

         In the last line, I add the shape object to the temporary layer and
then draw that layer which thus gives me a circle. But now, I want to find
the intersection of this circle with the underlying layer features which I
am unable to do, as the circle is not actually a circle or polygon that will
give me the intersection and thus the area of intersection.

The link
http://lists.dmsolutions.ca/pipermail/mapserver-users/2004-March/016983.html
has a code sample to draw a circle with polygon but that code doesn't seem
to work because it does not give me a circle but some other shaped polygon.


Friends, please help me with this problem.

Thanks,
Sucharita.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080512/77fe09a4/attachment.html


More information about the mapserver-users mailing list