Hello Cliff, In the case of a geodetic reference system (ie WGS84) if I'm not mistaken there is a utility class to do the apply the same solution: GeodeticCalculator. I never used it, but looking to the api it's what you need.
1) Instantiate this class with WGS84. 2) set the center point: setStartingGeographicPoint(double longitude, double latitude) 3) for each angle/azimuth: * setDirection(double azimuth, double distance) * getDestinationGeographicPoint() This means you'll calculate n points around the same point at the same distance at a different angle. The definition of a circle. The problem of the projection remains however. You'll get a perfect circle at the center of the projection but the more you'll go to the poles, the more "pear-shaped" your circle will be. On the poles you'll get very weird results. Especially for big circles. This is because on the cylindrical projection distances decrease at a rate of - roughly - cosine(latitude) while on the screen it's still the same dimension. The top line of the projection is in fact one single geographical point. All this explanation to tell this will only work properly in certain conditions. Otherwise you'll need to find another projection. If you need to have a perfect circle at all times, you'll need to inverse the problem: draw a circle on the screen in pixel coordinates and calculate for each point the geographical location - taking the projection and reference system into account. Unfortunately I don't know how you can do this in Geotools. Not yet. Jan >----- Oorspronkelijk bericht ----- >Van: Cliff Darling [mailto:[EMAIL PROTECTED] >Verzonden: maandag, april 21, 2008 11:32 PM >Aan: 'Jan Goyvaerts' >CC: [email protected] >Onderwerp: Re: [Geotools-gt2-users] Create polygon/geometry for circle with >given center and radius > >Thanks Jan. > >I am using a WGS84 projection (the default geographic projection). Is there >a way to modify the algorithm to work with a non-cartesian CRS? I am not >sure what would be involved. > >Would it suffice to convert to Cartesian, collect all of the points, and >then transform back to WGS84? > >Thanks, > >Cliff > > > >On Mon, Apr 21, 2008 at 10:07 PM, Jan Goyvaerts <[EMAIL PROTECTED]> >wrote: > >> Hi Cliff, >> >> No Java code at hand, but in pseudo code this should basically look like >> this: >> >> for angle = 0 to 359 step 1 do >> x = centerX + raduis * sine(angle) >> y = centerY + radius * cosine(angle) >> done >> >> (Decrease the step value of the for loop to make it look smoother.) >> >> This is assuming the coordinate reference system is carthesian. The >> projection you'll use for the map is of importance too. As it might not >> display the geometry as a round circle. >> >> Jan >> >> On Mon, 21 Apr 2008 20:16:16 +0100 >> "Cliff Darling" <[EMAIL PROTECTED]> wrote: >> >> > Does anyone have a code snippet for creating a polygon that represents a >> > circle around a center point with a given radius? >> > >> > Thanks, >> > >> > Cliff >> > >> >> >> -- >> Jan Goyvaerts <[EMAIL PROTECTED]> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference >> Don't miss this year's exciting event. There's still time to save $100. >> Use priority code J8TL2D2. >> >> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone >> _______________________________________________ >> Geotools-gt2-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> > ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
