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

From: Ken Anderson <kanderson_at_bbn.com>
Date: Mon, 01 Nov 2004 15:23:05 -0500

I'll send you some code that is an extension of com/bbn/openmap/geo package.
The basic idea is that if you treat a point on the earth as a unit 3D vector rather than lat/lon, you can do computations using vector algebra.

If you want a circle around the point p, a radius r away, compute a point x a distance r from p then compute a rotation matrx M that will rotate x d degrees about p to get the next point on the circle . Same idea for drawing great circles.

k

At 03:02 PM 11/1/2004 -0500, 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;
>
>
>
> 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;
>
> }
>
>

```--
[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:23:43 EST

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