[mapserver-users] Intersection of rectangle and circle

Sucharita Samuel iworktech.sucharita at gmail.com
Sat May 10 04:57:14 EDT 2008


  Hi Kishore,

  I hope the following explanation will make the problem clear to you,

  I have a map image (of India with states marked on it. Each state is a
feature). When the user clicks on any position of the map, I draw a circle
of 5km radius around the clicked point. Now  I want to find out the the
states that are completely covered by the circle, and the percentage of the
other states that lie inside the circle.

 I have drawn the circle using a bounding rectangle. Now the problem is, if
there is a very small state that lies in any four corners of the rectangle,
but not actually inside the circle, my algorithm considers it to be lying
inside the circle as the state actually lies within the boundaries of the
bounding rectangle.

 I need to find out the states that actually lie inside the circle, the
states that are completely excluded and the percentage of states that
partially lie inside the circle(and not the bounding rectangle)

Can You help me with this?

Thanks,
Sucharita


On Fri, May 9, 2008 at 6:41 PM, P Kishor <punk.kish at gmail.com> wrote:

> Let's clarify a few things first --
>
> On 5/9/08, Sucharita Samuel <iworktech.sucharita at gmail.com> wrote:
> > Hi friends,
> > I need to find the intersection of a rectangle and circle.
>
> what exactly do you need to find?
>  - the points at which they intersect?
>  - whether or not they intersect?
>  - the overlapping area of their intersection?
>  - whether the circle is contained in the rect?
>  - whether the rect is contained in the circle?
>
>
>
> > As you
> >  must be aware that a  circle in mapserver terminology is a shapeobject
> > drawn
> >  using the upper left and bottom right co-ordinates of a rectangle.
>
> I am now aware of that at all. My MapServer is extremely rusty, but I
> remember drawing circles using MapScript and an equation that provided
> the center of the circle and the radius. As you can see, there are
> more than one ways to do it.
>
>
> >      In the above case I get the intersection of two rectangles, but as
> the
> >  circle lies inside the rectangle, i am not able to find whether my first
> >  rectangle intersects with the bottom corner of the rectangle(that
> contains
> >  the circle), which is not part of the circle.
> >
>
> once again, your question is not clear. If a circle 'C' lies inside
> rectangle R, then the minimum bounding rectangle (MBR) of the circle
> 'C' (which is always a square) will lie completely within 'R'.
> Depending on your definition of intersection, there may or may not be
> any intersection at all.
>
>
> > I am using ASP.NET. Any solution in this case would be of great help.
> >
>
>
> ASP.NET is irrelevant here. Figure out clearly what you want to
> achieve, solve the problem as an algorithm problem, then you can
> implement it in any language you want to use.
>
> As is, at least to me, your question is not clear at all.
>
>
> > Thanks in advance,
> > Sucharita
> >
> >
> _______________________________________________
> 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/20080510/f4debb5c/attachment.html


More information about the mapserver-users mailing list