Hi,
I'm here to ask if I can commit a "Google Projection" class to
Geotools. The projection used for Google Maps is basically
a modified EPSG:41001 ("WGS84 / Simple Mercator"), but coordinates
have to be transformed assuming a sphere instead of an ellipsoid.
Using the major axis as radius seems to work, thought it would
be probably more correct to use the one of the equivalent
authalic sphere... hard to tell since this is all reverse engineering,
in proj they get the same effect by using these params:
+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0
+k=1.0 +units=m [EMAIL PROTECTED] +wktext +no_defs.
I get a good result by using the attached class plus the following
wkt definiton:
100003=PROJCS["WGS84 / Simple Mercator / Google", GEOGCS["WGS 84",
DATUM["WGS_1984", SPHEROID["WGS_1984", 6378137.0, 298.257223563]],
PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295],
AXIS["Longitude", EAST], AXIS["Latitude", NORTH]],
PROJECTION["Mercator_1SP_Google"], PARAMETER["latitude_of_origin", 0.0],
PARAMETER["central_meridian", 0.0], PARAMETER["scale_factor", 1.0],
PARAMETER["false_easting", 0.0], PARAMETER["false_northing", 0.0],
UNIT["m", 1.0], AXIS["x", EAST], AXIS["y", NORTH],
AUTHORITY["EPSG","100003"]]
The attached class seems to do the trick, thought it would
be probably much more compact if Mercator1SP could be extended
and had a param to force the sphere version of the transform.
Martin, what do you think? Just give me some hints, I'll do the
work.
Cheers
Andrea
package org.geotools.referencing.operation.projection;
import org.geotools.metadata.iso.citation.Citations;
import org.geotools.referencing.NamedIdentifier;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterNotFoundException;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.operation.CylindricalProjection;
import org.opengis.referencing.operation.MathTransform;
/**
* Mercator 1SP variation used by Google, which basically requires to accept
lat/lon values
* as spherical coordinates, that is, avoiding to do any conversion from
ellipsoid to the sphere.
* @author Andrea Aime
*/
public class Mercator1SPGoogle extends Mercator {
/**
* Constructs a new map projection from the supplied parameters.
*
* @param parameters The parameter values in standard units.
* @throws ParameterNotFoundException if a mandatory parameter is missing.
*/
protected Mercator1SPGoogle(final ParameterValueGroup parameters)
throws ParameterNotFoundException
{
super(parameters);
}
/**
* [EMAIL PROTECTED]
*/
public ParameterDescriptorGroup getParameterDescriptors() {
return Provider.PARAMETERS;
}
/**
* Provides the transform equations for the spherical case of the Mercator
projection.
*
* @version $Id: Mercator1SPGoogle.java 7371 2007-08-03 16:47:45Z aaime $
* @author Martin Desruisseaux
* @author Rueben Schulz
*/
private static final class Spherical extends Mercator.Spherical {
/**
* Constructs a new map projection from the suplied parameters.
*
* @param parameters The parameter values in standard units.
* @throws ParameterNotFoundException if a mandatory parameter is
missing.
*/
protected Spherical(final ParameterValueGroup parameters)
throws ParameterNotFoundException
{
super(parameters);
}
/**
* [EMAIL PROTECTED]
*/
public ParameterDescriptorGroup getParameterDescriptors() {
return Provider.PARAMETERS;
}
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
////////
////////
//////// PROVIDERS
////////
////////
////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
/**
* The [EMAIL PROTECTED]
org.geotools.referencing.operation.MathTransformProvider math transform
* provider} for a [EMAIL PROTECTED] Mercator1SP Mercator 1SP} projection
(EPSG code 9804).
*
* @since 2.2
* @version $Id: Mercator1SPGoogle.java 7371 2007-08-03 16:47:45Z aaime $
* @author Martin Desruisseaux
* @author Rueben Schulz
*
* @see org.geotools.referencing.operation.DefaultMathTransformFactory
*/
public static class Provider extends AbstractProvider {
/**
* The parameters group.
*/
static final ParameterDescriptorGroup PARAMETERS =
createDescriptorGroup(new NamedIdentifier[] {
new NamedIdentifier(Citations.OGC, "Mercator_1SP_Google"),
new NamedIdentifier(Citations.GEOTOOLS, "Mercator_1SP_Google")
}, new ParameterDescriptor[] {
SEMI_MAJOR, SEMI_MINOR,
LATITUDE_OF_ORIGIN, CENTRAL_MERIDIAN, SCALE_FACTOR,
FALSE_EASTING, FALSE_NORTHING
});
/**
* Constructs a new provider.
*/
public Provider() {
super(PARAMETERS);
}
/**
* Returns the operation type for this map projection.
*/
public Class getOperationType() {
return CylindricalProjection.class;
}
/**
* Creates a transform from the specified group of parameter values.
*
* @param parameters The group of parameter values.
* @return The created math transform.
* @throws ParameterNotFoundException if a required parameter was not
found.
*/
protected MathTransform createMathTransform(final ParameterValueGroup
parameters)
throws ParameterNotFoundException
{
// make sure we assume a spherical reference
parameters.parameter("semi_major").setValue(parameters.parameter("semi_minor").getValue());
return new Spherical(parameters);
}
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel