how to programmatically create circles?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to programmatically create circles?

Matthias Lendholt
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Reply | Threaded
Open this post in threaded view
|

Re: how to programmatically create circles?

geowolf
On Tue, Sep 11, 2012 at 3:20 PM, Matthias Lendholt <[hidden email]> wrote:
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?

Have a look at the PointBuffers process, also described here: 

(back at the time it was in GeoServer, now it is in GeoTools process-vector unsupported module)

Cheers
Andrea
 

--
==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.
==

Ing. Andrea Aime 
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:   +39 0584 962313
mob:   +39  339 8844549


-------------------------------------------------------


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Reply | Threaded
Open this post in threaded view
|

Re: how to programmatically create circles?

Simon Hartley
In reply to this post by Matthias Lendholt
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:[hidden email]]
Sent: 11 September 2012 14:20
To: [hidden email]
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



*** This communication has been sent from World Fuel Services
Corporation or its subsidiaries or its affiliates for the intended recipient
only and may contain proprietary, confidential or privileged information.
If you are not the intended recipient, any review, disclosure, copying,
use, or distribution of the information included in this communication
and any attachments is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to this
communication and delete the communication, including any
attachments, from your computer. Electronic communications sent to or
from World Fuel Services Corporation or its subsidiaries or its affiliates
may be monitored for quality assurance and compliance purposes.***



------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Reply | Threaded
Open this post in threaded view
|

Re: how to programmatically create circles?

Matthias Lendholt
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:[hidden email]]
> Sent: 11 September 2012 14:20
> To: [hidden email]
> 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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users