[MetaCRS] Possible Proj4js 1.1.0 problem: EPSG:900913 <--> EPSG:26986 transformation
Michael Adair
madair at dmsolutions.ca
Wed Sep 19 13:20:32 PDT 2012
The problem is here:
// A point location in web mercator.
var myPoint = { x: -73.21132, y: 42.71387 };
That's looks like a point in Lat/Long, not web mercator. Solution is to
use EPSG:4326 as your source (or convert to EPSG:900913 first).
Mike
On 19/09/2012 3:48 PM, Ben Krepp wrote:
>
> Hi all,
>
> I'm running into problems using Proj4js to transform coordinates
> between ESPG:900916 ("web Mercator") and EPSG:26986 (Massachusetts
> mainland state plane NAD83, meters) and vice-versa. The results I'm
> getting are way off.
>
> I've constructed a minimal test case that illustrates the problem:
>
> *[ BEGIN CODE]*
>
> function initialize() {
>
> Proj4js.reportError = function(msg) { alert('Proj4
> error: ' + msg); } ;
>
> // Massachusetts State Plane NAD83, meters
>
> var oDestPrj = new Proj4js.Proj('EPSG:26986');
>
> // Google "web mercator"
>
> var oSrcPrj = new Proj4js.Proj('EPSG:900913');
>
> // A point location in web mercator.
>
> var myPoint = { x: -73.21132, y: 42.71387 };
>
> // Project my point to EPSG:26986.
>
> Proj4js.transform(oSrcPrj, oDestPrj, myPoint);
>
> // Result should be (approximately) 59819.70, 941765.22
>
> document.write("x : " + myPoint.x + " y : " + myPoint.y);
>
> }
>
> *[ END CODE]*
>
> In the example above, the input point { x: -73.21132, y: 42.71387 } is
> transformed into { x : 9220379.520106662 y : -186260.82310388796 }.
>
> I'm using a newly downloaded copy of Proj4js 1.1.0, the SRS definition
> for EPSG:900913 that came with the Proj4js download, and the SRS
> definition for EPSG:26986 downloaded from www.spatialreference.org
> <http://www.spatialreference.org>.
>
> I've either stumbled upon a bug, or am doing something incredibly
> bone-headed.
>
> Any help that might be offered would be much appreciated.
>
> Thanks,
> Ben
>
> *Benjamin Krepp*** | Manager of GIS and IT
>
> CENTRAL TRANSPORTATION PLANNING STAFF
>
> 617.973.7137** | _bkrepp at ctps.org <mailto:bkrepp at ctps.org>_
>
> www.ctps.org/bostonmpo <http://www.ctps.org/bostonmpo>
>
> Description: Description: cid:5F54AF76-729F-48CE-9BEE-5E4887E4DA63
>
>
>
> _______________________________________________
> MetaCRS mailing list
> MetaCRS at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/metacrs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/metacrs/attachments/20120919/600361ba/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 14765 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/metacrs/attachments/20120919/600361ba/attachment-0001.png>
More information about the MetaCRS
mailing list