Simon,
Many thanks for your code!!
Matthias
Am 11.09.2012 16:37, schrieb Simon Hartley:
> My code looks like this:
>
> private static Geometry create3DCircle(double lng, double lat, double
> radiusNm) {
> GeodeticCalculator calc = new
> GeodeticCalculator(DefaultEllipsoid.WGS84);
> calc.setStartingGeographicPoint(lng, lat);
> final int SIDES = 32 + 16 * ((int)Math.ceil(radiusNm / 40) / 5);
> // Fairly random.
>
> double distance = radiusNm * 1852 /*1855.3248*/; //
> Convert to metres.
> double baseAzimuth = 360.0 / SIDES;
> Coordinate coords[] = new Coordinate[SIDES+1];
> for( int i = 0; i < SIDES; i++){
> double azimuth = 180 - (i * baseAzimuth);
> calc.setDirection(azimuth, distance);
> Point2D point = calc.getDestinationGeographicPoint();
> coords[i] = new Coordinate(point.getX(), point.getY());
> }
> coords[SIDES] = coords[0];
>
> LinearRing ring = GEOMETRY_FACTORY.createLinearRing( coords );
> Polygon polygon = GEOMETRY_FACTORY.createPolygon( ring, null );
>
> return polygon;
> }
>
>
>
> Simon Hartley
> Software Developer, AirData
>
>
>
>
> -----Original Message-----
> From: Matthias Lendholt [mailto:[email protected]]
> Sent: 11 September 2012 14:20
> To: [email protected]
> Subject: [Geotools-gt2-users] how to programmatically create circles?
>
> Hi,
>
> In my uDig/Geotools based application I have to programmatically create
> circle geometries based on centre + radius. I assume it will only affect
> geotools + JTS functionalities.
>
> I found this:
> http://docs.codehaus.org/display/GEOTDOC/01+How+to+Create+a+Geometry#id-01HowtoCreateaGeometry-CreatingaCircle
>
> However, my center is a Point in WGS84 and the radius is given in [m]/[km]. I
> guess I have to convert at first my center into another CRS, create the
> circle geometry and then, convert the geometry back into WGS84.
>
> Could anyone provide me the details how to realize these transformations and
> which CRS I have to use?
>
>
> Thanks,
> Matthias
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users