# Re: [OpenMap Users] circle to polygon conversion problem

From: Don Dietrick <dietrick_at_bbn.com>
Date: Mon, 1 Nov 2004 15:00:27 -0500

This method depends totally on the projected coordinates of the
OMCircle. For smaller OMCircle sizes at larger projection scale
values, I wouldn't be surprised if the PathIterator needs to be
flattened a little to interpolate between the points a little better.
Either that, or make the projection scale number smaller so the
OMCircle is projected at a bigger size, with more pixel space between
coordinates.

The other alternative is to call the getCoordLists() method on the
OMCircle to get the raw lat/lon points of the circle.

- Don

On Nov 1, 2004, at 3:02 PM, Whanger, Thomas wrote:

> Hello,
>
>
>
> The com.bbn.openmap.dataAccess.shape.EsriPolygonList.convert(OMCircle,
> Projection) method converts the given OMCircle to an OMPoly using the
> given Projection, and it works great for circles with a larger radius.
>
>
>
>
> However, if the radius is less than approximately 0.2 decimal degrees,
> then the converted OMPoly is a rectangle or triangle (not a circular
> shaped polygon).  In addition, if the radius is less than 0.04 decimal
> degrees, then the converted OMPoly is a vertical line (not a circular
> shaped polygon).
>
>
>
> Does anyone know why this method fails for these circles with a
> smaller radius and/or how to get the method to work with these circles
> with a smaller radius?  Any help is greatly appreciated.
>
>
>
> Thanks,
>
> -Tom
>
>
>
> Here is the method's code:
>
>
>
>     //converts circles into polygons
>
>     public static OMPoly convert(OMCircle omCircle, Projection proj) {
>
>         GeneralPath shape = omCircle.getShape();
>
>
>
>         //get the PathIterator that defines the outline of the circle
>
>         PathIterator circle = shape.getPathIterator(null);
>
>         Vector initialPoints = new Vector();
>
>         float[] segPoints = new float[2];
>
>
>
>         while (!circle.isDone()) {
>
>             //by passing segpoints the array is filled with each x\y
> point
>
>             //iterated by the circle
>
>             int segType = circle.currentSegment(segPoints);
>
>
>
>             circle.next();
>
>         }
>
>
>
>         float[] circlePoints = new float[initialPoints.size()];
>
>
>
>         if (proj == null) {
>
>             return null;
>
>         }
>
>
>
>         //convert the x/y points to lat/lon points
>
>         for (int p = 0; p < initialPoints.size(); p += 2) {
>
>             LatLonPoint llp = proj.inverse(
>
>                     ((Float)initialPoints.elementAt(p)).intValue(),
>
>                     ((Float)initialPoints.elementAt(p +
> 1)).intValue());
>
>
>
>             circlePoints[p] = llp.getLatitude();
>
>             circlePoints[p + 1] = llp.getLongitude();
>
>         }
>
>
>
>         //using the circle data create an OMPoly
>
>         OMPoly poly = new OMPoly(circlePoints,
> OMGraphic.DECIMAL_DEGREES, omCircle.getLineType());
>
>         poly.setAppObject(omCircle.getAppObject());
>
>         DrawingAttributes da = new DrawingAttributes();
>
>         da.setFrom(omCircle);
>
>         da.setTo(poly);
>
>         return poly;
>
>     }
>
>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Nov 01 2004 - 15:01:01 EST

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