From: Andrea A. <aa...@op...> - 2007-10-14 16:17:11
|
Martin Desruisseaux ha scritto: > Abraham Mármol Asís a écrit : >> I only need to convert a point expressed in EPGS:20030 (what is a >> mercator projection) and then obtain its equivalent Longitutude and >> latitude (that suites the google system) to invoque the google map >> method: map.setCenter (new GLatLng(myLat,myLong), myZom); >> >> The problem is how to obtain that long,lat corresponding to EPSG >> Projection... > > A possible approach is to transform from EPSG:20030 to EPSG:4326 (which is > latitude,longitude on WGS 84 ellipsoid). > > Be aware that (latitude,longitude) are not unique. For example (40°N, 10°E) do > not design a single location. It may be many different locations, depending of > the underlying CRS. (40°N, 10°E) in WGS 84 may be one km apart from (40°N, 10°E) > in an other geographic CRS! So the choice of the target GeographicCRS really matter. > > I believe (not sure - Andrea could confirm) that the Google CRS has been added > in the Geoserver code base, not in the Geotools code base. In the main time, WGS > 84 (EPSG:4326) is probably the closest CRS available in GeoTools. Google projection is really just a Mercator projection defined onto a sphere, but with a twist: when you trasform from the WGS84 ellipsoid to the sphere, you have to ignore the ellipsoid-sphere adjustment, that is, you have to assume the lat and lon on the sphere are the same as with the ellipsoid. That's what the GeoServer Mercator1SPGoogle class does, it subclasses the Mercator projection and makes sure the projection uses the spherical math (and the wkt defining the Google CRS states the usage of a WGS84 ellipsoid, so that the step that does the ellipsoid->sphere step in the transform does not take place). I believe there are cleaner ways to do this, but it's the only one I could come up in the allotted time. For example, in proj they define the CRS as it really is (mercator over a sphere) and they have a way to say the lat/lon correction must be avoided. I can push the transform back to GeoTools, if Martin feels my hack is acceptable. Cheers Andrea |