Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## geotools-gt2-users

 [Geotools-gt2-users] Creating a buffer around a point From: Alex - 2009-08-29 16:48:04 Attachments: Message as HTML ```Hi, I'm having difficulties figuring out how to create a buffer on N meters around a given point. I work with JTS geometries and I try to use the following code : public static Geometry getPointBuffer(Point point, double distanceMeters) throws NoSuchAuthorityCodeException, FactoryException, MismatchedDimensionException, TransformException{ CoordinateReferenceSystem pointCRS = CRS.decode("EPSG:4326"); CoordinateReferenceSystem radiusCRS = CRS.decode("EPSG:32630"); MathTransform transformToUtm = CRS.findMathTransform(pointCRS, radiusCRS); Geometry targetGeometry = JTS.transform( point, transformToUtm); Geometry buffer = targetGeometry.buffer(distanceMeters); buffer.setSRID(32630); MathTransform transformToGeo = CRS.findMathTransform(radiusCRS, pointCRS); Geometry bufferGeo = JTS.transform( buffer, transformToGeo); bufferGeo.setSRID(4326); return bufferGeo; } for the following point : POINT (2.16229 41.3953) and a distance of 5000 meters I get the following polygon : POLYGON ((2.1668585664549775 41.35554016723455, 2.1605728155293 41.35471376204175, 2.154571657038669 41.35270371296712, 2.1490854073842818 41.349587027106196, 2.144324701588059 41.345483128365466, 2.1404724289152757 41.34054932112889, 2.13767671399557 41.334974806952445, 2.1360452117294355 41.328973474816856, 2.1356409371529472 41.32277573270135, 2.1364797955297057 41.316619686596034, 2.138529914925493 41.310742000847185, 2.141712815464533 41.30536878944814, 2.1459063787954538 41.3007068904193, 2.150949510736572 41.296935864099616, 2.156648322542981 41.294201030919375, 2.1627835947102874 41.29260782561655, 2.1691192345488095 41.29221769417829, 2.175411397470465 41.293045698993566, 2.1814179140899173 41.29505992935786, 2.1869076522796567 41.298182741613445, 2.1916694459194326 41.30229377916705, 2.195520240128788 41.30723465081568, 2.198312135359968 41.31281507951014, 2.1999380582252 41.31882027583668, 2.2003358431020676 41.32501924352674, 2.1994905727257703 41.33117369000711, 2.197435095200101 41.337047194460446, 2.19424870612777 41.34241427945901, 2.190054054957272 41.347069039672576, 2.185012401483143 41.35083300158266, 2.1793174093663206 41.353561920250755, 2.1731877165978544 41.35515126136847, 2.1668585664549775 41.35554016723455)) which is not correct at all ! the initial point is not within the bounds of the created buffer .... The funny thing is this method worked fine in a similar project ... but now I can't figure out what's happening. As you will see the Points I'm dealing with are located in the Barcelona area. I don't know if this has an incidence. What am I doing wrong ? How can I properly create a buffer of XXX meters around a given Point Many thanks for helping me :) Cheers. ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Michael Bedward - 2009-08-31 02:37:44 ```Hi Alex, You've been snared by the "axis order" trap :) If you edit the CRS.decode calls to this... CoordinateReferenceSystem pointCRS = CRS.decode("EPSG:4326", true); CoordinateReferenceSystem radiusCRS = CRS.decode("EPSG:32630", true); ...your buffer will be centred on the point. Michael 2009/8/30 Alex : > Hi, > > I'm having difficulties figuring out how to create a buffer on N meters > around a given point. > I work with JTS geometries and I try to use the following code : > > > public static Geometry getPointBuffer(Point point, double distanceMeters) > throws NoSuchAuthorityCodeException, FactoryException, > MismatchedDimensionException, TransformException{ > >         CoordinateReferenceSystem pointCRS = CRS.decode("EPSG:4326"); >         CoordinateReferenceSystem radiusCRS = CRS.decode("EPSG:32630"); > > >         MathTransform transformToUtm = CRS.findMathTransform(pointCRS, > radiusCRS); > >         Geometry targetGeometry = JTS.transform( point, transformToUtm); > >         Geometry buffer = targetGeometry.buffer(distanceMeters); >         buffer.setSRID(32630); > >         MathTransform transformToGeo = CRS.findMathTransform(radiusCRS, > pointCRS); > >         Geometry bufferGeo = JTS.transform( buffer, transformToGeo); >         bufferGeo.setSRID(4326); > > >         return bufferGeo; > >     } > > > for the following point : > > POINT (2.16229 41.3953) > > and a distance of 5000 meters > > I get the following polygon : > POLYGON ((2.1668585664549775 41.35554016723455, 2.1605728155293 > 41.35471376204175, 2.154571657038669 41.35270371296712, 2.1490854073842818 > 41.349587027106196, 2.144324701588059 41.345483128365466, 2.1404724289152757 > 41.34054932112889, 2.13767671399557 41.334974806952445, 2.1360452117294355 > 41.328973474816856, 2.1356409371529472 41.32277573270135, 2.1364797955297057 > 41.316619686596034, 2.138529914925493 41.310742000847185, 2.141712815464533 > 41.30536878944814, 2.1459063787954538 41.3007068904193, 2.150949510736572 > 41.296935864099616, 2.156648322542981 41.294201030919375, 2.1627835947102874 > 41.29260782561655, 2.1691192345488095 41.29221769417829, 2.175411397470465 > 41.293045698993566, 2.1814179140899173 41.29505992935786, 2.1869076522796567 > 41.298182741613445, 2.1916694459194326 41.30229377916705, 2.195520240128788 > 41.30723465081568, 2.198312135359968 41.31281507951014, 2.1999380582252 > 41.31882027583668, 2.2003358431020676 41.32501924352674, 2.1994905727257703 > 41.33117369000711, 2.197435095200101 41.337047194460446, 2.19424870612777 > 41.34241427945901, 2.190054054957272 41.347069039672576, 2.185012401483143 > 41.35083300158266, 2.1793174093663206 41.353561920250755, 2.1731877165978544 > 41.35515126136847, 2.1668585664549775 41.35554016723455)) > > > which is not correct at all ! > > the initial point is not within the bounds of the created buffer .... > > The funny thing is this method worked fine in a similar project ... but now > I can't figure out what's happening. > > As you will see the Points I'm dealing with are located in the Barcelona > area. I don't know if this has an incidence. > > What am I doing wrong ? > How can I properly create a buffer of XXX meters around a given Point > > > Many thanks for helping me :) > > Cheers. > > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now.  http://p.sf.net/sfu/bobj-july > _______________________________________________ > Geotools-gt2-users mailing list > Geotools-gt2-users@... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Alex - 2009-08-31 04:40:13 Attachments: Message as HTML ```Thanks Michael. In fact I think I have been using incorrect EPSG code for RadiusCRS. I tried with EPSG:32631 and the recult is closer to what I expected. So my best guess is that I'm using icorrect UTM zone for my point. I think that I first need to figure out the correct UTM zone for the latitude/longitude of my point. The thing is I don't know in advance where my point will be located so I really can't hardcode the EPSG code for the UTM. so now comes my second question :) Is there a way to calculate the UTM zone and the corresponding EPSG code for given latitude / longitude coordinates. Thank you for your insights. Cheers On Mon, Aug 31, 2009 at 4:37 AM, Michael Bedward wrote: > Hi Alex, > > You've been snared by the "axis order" trap :) > > If you edit the CRS.decode calls to this... > > CoordinateReferenceSystem pointCRS = CRS.decode("EPSG:4326", true); > CoordinateReferenceSystem radiusCRS = CRS.decode("EPSG:32630", > true); > > ...your buffer will be centred on the point. > > Michael > > > 2009/8/30 Alex : > > Hi, > > > > I'm having difficulties figuring out how to create a buffer on N meters > > around a given point. > > I work with JTS geometries and I try to use the following code : > > > > > > public static Geometry getPointBuffer(Point point, double distanceMeters) > > throws NoSuchAuthorityCodeException, FactoryException, > > MismatchedDimensionException, TransformException{ > > > > CoordinateReferenceSystem pointCRS = CRS.decode("EPSG:4326"); > > CoordinateReferenceSystem radiusCRS = CRS.decode("EPSG:32630"); > > > > > > MathTransform transformToUtm = CRS.findMathTransform(pointCRS, > > radiusCRS); > > > > Geometry targetGeometry = JTS.transform( point, transformToUtm); > > > > Geometry buffer = targetGeometry.buffer(distanceMeters); > > buffer.setSRID(32630); > > > > MathTransform transformToGeo = CRS.findMathTransform(radiusCRS, > > pointCRS); > > > > Geometry bufferGeo = JTS.transform( buffer, transformToGeo); > > bufferGeo.setSRID(4326); > > > > > > return bufferGeo; > > > > } > > > > > > for the following point : > > > > POINT (2.16229 41.3953) > > > > and a distance of 5000 meters > > > > I get the following polygon : > > POLYGON ((2.1668585664549775 41.35554016723455, 2.1605728155293 > > 41.35471376204175, 2.154571657038669 41.35270371296712, > 2.1490854073842818 > > 41.349587027106196, 2.144324701588059 41.345483128365466, > 2.1404724289152757 > > 41.34054932112889, 2.13767671399557 41.334974806952445, > 2.1360452117294355 > > 41.328973474816856, 2.1356409371529472 41.32277573270135, > 2.1364797955297057 > > 41.316619686596034, 2.138529914925493 41.310742000847185, > 2.141712815464533 > > 41.30536878944814, 2.1459063787954538 41.3007068904193, 2.150949510736572 > > 41.296935864099616, 2.156648322542981 41.294201030919375, > 2.1627835947102874 > > 41.29260782561655, 2.1691192345488095 41.29221769417829, > 2.175411397470465 > > 41.293045698993566, 2.1814179140899173 41.29505992935786, > 2.1869076522796567 > > 41.298182741613445, 2.1916694459194326 41.30229377916705, > 2.195520240128788 > > 41.30723465081568, 2.198312135359968 41.31281507951014, 2.1999380582252 > > 41.31882027583668, 2.2003358431020676 41.32501924352674, > 2.1994905727257703 > > 41.33117369000711, 2.197435095200101 41.337047194460446, 2.19424870612777 > > 41.34241427945901, 2.190054054957272 41.347069039672576, > 2.185012401483143 > > 41.35083300158266, 2.1793174093663206 41.353561920250755, > 2.1731877165978544 > > 41.35515126136847, 2.1668585664549775 41.35554016723455)) > > > > > > which is not correct at all ! > > > > the initial point is not within the bounds of the created buffer .... > > > > The funny thing is this method worked fine in a similar project ... but > now > > I can't figure out what's happening. > > > > As you will see the Points I'm dealing with are located in the Barcelona > > area. I don't know if this has an incidence. > > > > What am I doing wrong ? > > How can I properly create a buffer of XXX meters around a given Point > > > > > > Many thanks for helping me :) > > > > Cheers. > > > > > > > > > > > > > ------------------------------------------------------------------------------ > > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > > trial. Simplify your report design, integration and deployment - and > focus > > on > > what you do best, core application coding. Discover what's new with > > Crystal Reports now. http://p.sf.net/sfu/bobj-july > > _______________________________________________ > > Geotools-gt2-users mailing list > > Geotools-gt2-users@... > > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > > > > ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Michael Bedward - 2009-08-31 04:49:38 ```Hi Alex, I tested the code and data that you posted earlier, with the extra boolean arg on the decode method calls, and it produced a buffer polygon that was centred nicely on the input point. > so now comes my second question :) > > Is there a way to calculate the UTM zone and the corresponding EPSG code for > given latitude / longitude coordinates. > If you go to http://www.epsg-registry.org/ you can search by lat-long bounding box. Hope that helps, Michael ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Roman Isitua - 2009-08-31 07:55:31 Attachments: Message as HTML ```Hi,I think the following link will be helpful http://spatialreference.org/ref/epsg/32631/On the spatialreference.org site each UTM zone (epsg code) has a geographical boundary. eg for 32631 the bounds are as followsWGS84 Bounds: 0.0000, 0.0000, 6.0000, 84.0000  Projected Bounds: 166021.4431, 0.0000, 833978.5569, 9329005.1825I don't know what your requirements are but if ur application is restricted to a region eg a country or a no of countries u can do a point in polygon test i.e. compare the lon/lat point you have with a set bounding boxes (each box corresponding to the UTM zones your app covers).Roman. --- On Sun, 8/30/09, Alex wrote: From: Alex Subject: Re: [Geotools-gt2-users] Creating a buffer around a point To: geotools-gt2-users@... Date: Sunday, August 30, 2009, 9:40 PM Thanks Michael. In fact I think I have been using incorrect EPSG code for RadiusCRS. I tried with EPSG:32631 and the recult is closer to what I expected. So my best guess is that I'm using icorrect UTM zone for my point. I think that I first need to figure out the correct UTM zone for the latitude/longitude of my point. The thing is I don't know in advance where my point will be located so I really can't hardcode the EPSG code for the UTM. so now comes my second question :) Is there a way to calculate the UTM zone and the corresponding EPSG code for given latitude / longitude coordinates. Thank you for your insights. Cheers   On Mon, Aug 31, 2009 at 4:37 AM, Michael Bedward wrote: Hi Alex, You've been snared by the "axis order" trap :) If you edit the CRS.decode calls to this...         CoordinateReferenceSystem pointCRS = CRS.decode("EPSG:4326", true);         CoordinateReferenceSystem radiusCRS = CRS.decode("EPSG:32630", true); ...your buffer will be centred on the point. Michael 2009/8/30 Alex : > Hi, > > I'm having difficulties figuring out how to create a buffer on N meters > around a given point. > I work with JTS geometries and I try to use the following code : > > > public static Geometry getPointBuffer(Point point, double distanceMeters) > throws NoSuchAuthorityCodeException, FactoryException, > MismatchedDimensionException, TransformException{ > >         CoordinateReferenceSystem pointCRS = CRS.decode("EPSG:4326"); >         CoordinateReferenceSystem radiusCRS = CRS.decode("EPSG:32630"); > > >         MathTransform transformToUtm = CRS.findMathTransform(pointCRS, > radiusCRS); > >         Geometry targetGeometry = JTS.transform( point, transformToUtm); > >         Geometry buffer = targetGeometry.buffer(distanceMeters); >         buffer.setSRID(32630); > >         MathTransform transformToGeo = CRS.findMathTransform(radiusCRS, > pointCRS); > >         Geometry bufferGeo = JTS.transform( buffer, transformToGeo); >         bufferGeo.setSRID(4326); > > >         return bufferGeo; > >     } > > > for the following point : > > POINT (2.16229 41.3953) > > and a distance of 5000 meters > > I get the following polygon : > POLYGON ((2.1668585664549775 41.35554016723455, 2.1605728155293 > 41.35471376204175, 2.154571657038669 41.35270371296712, 2.1490854073842818 > 41.349587027106196, 2.144324701588059 41.345483128365466, 2.1404724289152757 > 41.34054932112889, 2.13767671399557 41.334974806952445, 2.1360452117294355 > 41.328973474816856, 2.1356409371529472 41.32277573270135, 2.1364797955297057 > 41.316619686596034, 2.138529914925493 41.310742000847185, 2.141712815464533 > 41.30536878944814, 2.1459063787954538 41.3007068904193, 2.150949510736572 > 41.296935864099616, 2.156648322542981 41.294201030919375, 2.1627835947102874 > 41.29260782561655, 2.1691192345488095 41.29221769417829, 2.175411397470465 > 41.293045698993566, 2.1814179140899173 41.29505992935786, 2.1869076522796567 > 41.298182741613445, 2.1916694459194326 41.30229377916705, 2.195520240128788 > 41.30723465081568, 2.198312135359968 41.31281507951014, 2.1999380582252 > 41.31882027583668, 2.2003358431020676 41.32501924352674, 2.1994905727257703 > 41.33117369000711, 2.197435095200101 41.337047194460446, 2.19424870612777 > 41.34241427945901, 2.190054054957272 41.347069039672576, 2.185012401483143 > 41.35083300158266, 2.1793174093663206 41.353561920250755, 2.1731877165978544 > 41.35515126136847, 2.1668585664549775 41.35554016723455)) > > > which is not correct at all ! > > the initial point is not within the bounds of the created buffer .... > > The funny thing is this method worked fine in a similar project ... but now > I can't figure out what's happening. > > As you will see the Points I'm dealing with are located in the Barcelona > area. I don't know if this has an incidence. > > What am I doing wrong ? > How can I properly create a buffer of XXX meters around a given Point > > > Many thanks for helping me :) > > Cheers. > > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now.  http://p.sf.net/sfu/bobj-july > _______________________________________________ > Geotools-gt2-users mailing list > Geotools-gt2-users@... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now.  http://p.sf.net/sfu/bobj-july -----Inline Attachment Follows----- _______________________________________________ Geotools-gt2-users mailing list Geotools-gt2-users@... https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Alex - 2009-08-31 13:05:48 Attachments: Message as HTML ```Here are the messages I was forwarding to Roman instead of the list ... yeah maybe that's the way I'll do this ... Since my application is going to cover locations everywhere in the world I need to do things the clean way straight up :) I need to get the WGS84 bounds for all 60 UTM zones and their corresponding EPSG code and create a DB table for easy EPSG code lookup. I'll also probably store the UTM code for each point inside the databse ... that will save me a spatial query during regular buffer creation ... If anybody has a better ...cleaner approach to submit that would be very nice to hear : )) Thank you Michael and Roman for your help. ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Alex - 2009-08-31 13:05:50 Attachments: Message as HTML ```Ok it seems there was an easier way after all. EPSG codes for WGS84 UTM in the northern hemisphere are numbered from 32600 onwards and for the southern hemisphere 32700 onwards. So I developped these 2 simple methods to get the appropriate EPSG code for any given latitude longitude coordinate : Feel free to use them if needed. public static String getEPSGWGS84UTMCode(double latitude, double longitude){ //since in the EPSG database, NORTH UTM zones on the WGS84 are nubberd from 32600 onwards //and SOUTHERN are numbered 32700 onwards int base = 0; if (latitude >= 0) { base = 32600; } else { base = 32700; } int code = base + getWGS84UTMZoneNumber(latitude, longitude); System.out.println("EPSG code = EPSG:"+code ); return "EPSG:"+code; } public static int getWGS84UTMZoneNumber(double latitude, double longitude){ //Manage exceptions first :) if (longitude == 180) { return 60; }else if (latitude >= 56.0f && latitude < 64.0f && longitude >= 3.0f && longitude < 12.0f) { // Norway's exception zone return 32; } else if (latitude >= 72.0f && latitude < 84.0f) { // Svalbard Exceptions if (longitude >= 0.0f && longitude < 9.0f){ return 31; }else if (longitude >= 9.0f && longitude < 21.0f){ return 33; }else if (longitude >= 21.0f && longitude < 33.0f){ return 35; } else if (longitude >= 33.0f && longitude < 42.0f){ return 37; } } else{ int code = (int) (Math.floor((longitude + 180)/6) + 1); System.out.println("UTM zone = " + code); return code; } return 0; } Hope this helps somebody someday and brings me to posterity. Have fun and many thanks to both of you. P.S. Michael was right about enforcing longitude first as JTS Points have longitude as the first value. ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Michael Bedward - 2009-09-01 03:59:23 ```Hi Alex, Many thanks for posting your code and summary to the list - that's great. Michael ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Jody Garnett - 2009-09-01 09:33:46 Attachments: Message as HTML ```Two ideas ... use an equal are project ... but make up the WKT yourself based on the location you are buffering.... PROJCS["NAD83 / BC Albers", GEOGCS["NAD83", DATUM["North American Datum 1983", SPHEROID["GRS 1980", 6378137.0, 298.257222101, AUTHORITY ["EPSG","7019"]], TOWGS84[1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4269"]], PROJECTION["Albers Equal Area", AUTHORITY["EPSG","9822"]], PARAMETER["central_meridian", -126.0], PARAMETER["latitude_of_origin", 45.0], PARAMETER["standard_parallel_1", 50.0], PARAMETER["false_easting", 1000000.0], PARAMETER["false_northing", 0.0], PARAMETER["standard_parallel_2", 58.5], UNIT["m", 1.0], AXIS["Easting", EAST], AXIS["Northing", NORTH], AUTHORITY["EPSG","3005"]] Use one of the Auto projections; this will have the same effect as your database table of 60 UTM zones; see AutoFactory for details... factory = new AutoCRSFactory(); ProjectedCRS utm = factory.createProjectedCRS("AUTO:42001,"+lat","+lon); Jody On 31/08/2009, at 11:05 PM, Alex wrote: > Here are the messages I was forwarding to Roman instead of the > list ... > > > > yeah maybe that's the way I'll do this ... > > > Since my application is going to cover locations everywhere in the > world I need to do things the clean way straight up :) > > I need to get the WGS84 bounds for all 60 UTM zones and their > corresponding EPSG code and create a DB table for easy EPSG code > lookup. > I'll also probably store the UTM code for each point inside the > databse ... that will save me a spatial query during regular buffer > creation ... > > > If anybody has a better ...cleaner approach to submit that would be > very nice to hear : )) > > Thank you Michael and Roman for your help. > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and > focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july_______________________________________________ > Geotools-gt2-users mailing list > Geotools-gt2-users@... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Michael Bedward - 2009-09-01 09:59:56 ```Hi Jody > Use one of the Auto projections; this will have the same effect as your > database table of 60 UTM zones; see AutoFactory for details... > factory = new AutoCRSFactory(); > ProjectedCRS utm = factory.createProjectedCRS("AUTO:42001,"+lat","+lon); > Jody I see AutoCRSFactory is deprecated. Is that a problem in this instance ? Michael ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Jody Garnett - 2009-09-01 10:07:07 ```It is deprecated for a strange reason; future plans of Matin :-) That said you should need to reference this class directly; using CRS.decode should work and find the auto factory on the classpath... I was just ripping sample code out of the test case. Jody On 01/09/2009, at 7:59 PM, Michael Bedward wrote: > Hi Jody > >> Use one of the Auto projections; this will have the same effect as >> your >> database table of 60 UTM zones; see AutoFactory for details... >> factory = new AutoCRSFactory(); >> ProjectedCRS utm = factory.createProjectedCRS("AUTO: >> 42001,"+lat","+lon); >> Jody > > I see AutoCRSFactory is deprecated. Is that a problem in this > instance ? > > Michael ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Jody Garnett - 2009-09-02 02:00:08 Attachments: Message as HTML ```On 02/09/2009, at 12:15 AM, Alex wrote: > Thanks Jody for your feedback. > > I now have basically 3 approaches to do the same thing :) > > 1. The code I posted (maybe not universal since it will only work > with WGS84 and UTM) > 2. Your "Good idea" using EPSG:3005 > 3. Use of AutoCRSFactory(); (maybe slow ?) > > Considering performance, which approach should I use. Is my code > valid enough for all cases? This is computational graph theory; all approaches are valid - you just need to choose based on accuracy vs performance :-) Depending on your buffer size we may be over thinking this way too much - ie the difference between the approaches may be less then the accuracy of your source data. > I'm basically developping a geographically enabled search engine so > if have the chance of attracting many users, performance of queries > will be critical to user's experience. From what I can foresee my > data will always be stored using WGS84 lat/lon values inside a > GeoSpatial Database so probably that "universality" of the code > doesn't matter after all. > > I'm also considering storing the best EPSG code (for WGS84/UTM) > inside the database alongside the POI. The code could be determined > using solution no1. > My concern is about the time it would take to find the code for > potetially millions of Points .... maybe I could do it once and for > all in a batch and then at new POI creation time OR I could try to > get the EPSG code from DB and if not available, use one of the 3 > methods above to feed that field and persist it back to DB... > > Many ways of doing the same thing even though it took me a couple of > days before I could even figure out where the problem was actually > lying :) > > Any thoughts appreciated. Set up a test case with JUnit - try out each approach - and measure the performance. There should be no difference between the way the "AUTO" definitions generate a projection for a given region; and your database of UTM mappings. Ie they should both produce the correct definition for a UTM zone; however I worry that they do not take into account distortion as you move north as well as making use of an equal area projection would. Regards - and please report back to the list on how you are going; this is an interesting problem and may well be worth a blog post when you are done. Jody > > Cheers > > ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Michael Bedward - 2009-08-31 06:26:08 ```Hi Alex, > Is there a way to figure out the UTM zone and therefore EPSG code > programatically ? > Well the zone is easy... for almost everywhere the zones are six degrees wide starting from 180 deg W. The only exceptions are a wider box around Norway and somewhere else that I forget, but it's probably mentioned here... http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system I'm no expert about EPSG (or referencing in general) but as far as I know there isn't any straightforward relationship between EPSG codes and zone indices. You have to do a lookup. Someone else here might be able to provide a better answer. Michael ```
 Re: [Geotools-gt2-users] Creating a buffer around a point From: Michael Bedward - 2009-08-31 06:29:45 ```PS. this page in the User Guide might be relevant for programmatic searches... http://docs.codehaus.org/display/GEOTDOC/01+CRS+Helper+Class#01CRSHelperClass-SearchingforaCoordinateReferenceSystem 2009/8/31 Michael Bedward : > Hi Alex, > >> Is there a way to figure out the UTM zone and therefore EPSG code >> programatically ? >> > > Well the zone is easy... for almost everywhere the zones are six > degrees wide starting from 180 deg W. The only exceptions are a wider > box around Norway and somewhere else that I forget, but it's probably > mentioned here... > > http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system > > I'm no expert about EPSG (or referencing in general) but as far as I > know there isn't any straightforward relationship between EPSG codes > and zone indices. You have to do a lookup. > > Someone else here might be able to provide a better answer. > > Michael > ```