Re: Determining poly bounds

From: Donald Dietrick <dietrick@bbn.com>
Date: Thu Dec 06 2001 - 22:21:05 EST

Hi Jeremy,

This'll be in later versions of OMGraphics, when the internals get
converted to use java.awt.Shape objects. The Shape interface has
intersection query methods in it. I have a preliminary version of
OMPoly written, but it's not optimized and it is noticeably slower at
the moment if you have a lot of them.

in general, I create the Shapes from the internal projected xpoints and
ypoints like this at the end of OMPoly.generate():

        // xpoints and ypoints hold the projected coordinates, so
         // create the shape object from them...
         int numShapes = xpoints.length;
         shapes = new Shape[numShapes];
         for (i=0; i < numShapes; i++) {
             int shapeSize = xpoints[i].length;
             if (isPolygon) {
                 Polygon polygon = new Polygon(xpoints[i], ypoints[i],
                                               xpoints[i].length);
                 shapes[i] = polygon;
             } else {

                 GeneralPath path = new GeneralPath();
                 for (j = 1; j < shapeSize; j++) {
                     Line2D segment =
                         new Line2D.Float((float)xpoints[i][j-1],
                                          (float)ypoints[i][j-1],
                                          (float)xpoints[i][j],
                                          (float)ypoints[i][j]);
                     path.append(segment, true);

                 }
                 shapes[i] = path;
             }
         }

This might get you started, but note that it will be changing from
optimization - it's just a proof of concept.

Cheers,

Don

On Thursday, December 6, 2001, at 02:46 PM, Jeremy Zacker wrote:

> I have built a mouse mode that draw a rectangle on the screen when the
> user
> drags the mouse across the map (similar to NavMouseMode but without the
> ratio check).
>
> I am trying to determine if the user sweeps the mouse over the objects
> displayed on
> the map. For OMGraphics with a single plot point, tis was easy. But I
> am
> having trouble with OMPoly. I looked at DrawUtil.inside_polygon, but I
> don't want to just
> check the plot points of the OMPoly. I also want to check if any line
> drawn between
> plot points was captured during the sweep.
>
> I am using the RENDERTYPE_LATLON, so I cannot grab the 'xs' and 'ys'
> from the OMPoly.
> Does anyone know of an API to do what I am asking? I can generate the
> 'xs' and 'ys' if I must,
> but I'd prefer not to.
>
> --
> Jeremy "Slacker" Zacker - "BLAH!"
> MCS Blk IV
> (732) 450-7066
>
>
> --
> [To unsubscribe to this list send an email to "majdart@bbn.com"
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]
>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Donald Dietrick, dietrick@bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Dec 6 22:18:37 2001

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:32 EDT