<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
The problem is here:<br>
<br>
<p class="MsoNormal"> // A point location in web
mercator.</p>
<p class="MsoNormal"> var myPoint = { x: -73.21132,
y: 42.71387 };<br>
</p>
<p class="MsoNormal">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).<br>
</p>
<p class="MsoNormal">Mike<br>
</p>
<br>
<br>
<div class="moz-cite-prefix">On 19/09/2012 3:48 PM, Ben Krepp wrote:<br>
</div>
<blockquote cite="mid:06ff01cd969f$bc5891e0$3509b5a0$@ctps.org"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<div class="WordSection1">
<p class="MsoNormal">Hi all,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">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.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I’ve constructed a minimal test case that
illustrates the problem:</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><b>[ BEGIN CODE]</b></p>
<p class="MsoNormal">function initialize() { </p>
<p class="MsoNormal"> Proj4js.reportError =
function(msg) { alert('Proj4 error: ' + msg); } ;</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> // Massachusetts State
Plane NAD83, meters</p>
<p class="MsoNormal"> var oDestPrj = new
Proj4js.Proj('EPSG:26986');</p>
<p class="MsoNormal"> // Google "web mercator"</p>
<p class="MsoNormal"> var oSrcPrj = new
Proj4js.Proj('EPSG:900913'); </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> // A point location in web
mercator.</p>
<p class="MsoNormal"> var myPoint = { x:
-73.21132, y: 42.71387 };</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> // Project my point to
EPSG:26986.</p>
<p class="MsoNormal"> Proj4js.transform(oSrcPrj,
oDestPrj, myPoint);</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> // Result should be
(approximately) 59819.70, 941765.22</p>
<p class="MsoNormal"> document.write("x : " +
myPoint.x + " y : " + myPoint.y);</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal"><b>[ END CODE]</b></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">In the example above, the input point { x:
-73.21132, y: 42.71387 } is transformed into { x :
9220379.520106662 y : -186260.82310388796 }.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">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 <a moz-do-not-send="true"
href="http://www.spatialreference.org">www.spatialreference.org</a>.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">I’ve either stumbled upon a bug, or am
doing something incredibly bone-headed. </p>
<p class="MsoNormal">Any help that might be offered would be
much appreciated.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Thanks,<br>
Ben</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><b><span>Benjamin Krepp</span></b><b><span>
</span></b><span> | </span><span>Manager of GIS and IT</span><span></span></p>
<p class="MsoNormal"><span>CENTRAL TRANSPORTATION PLANNING STAFF</span><span></span></p>
<p class="MsoNormal"><span>617.973.7137</span><b><span> </span></b><span> |
</span><u><span><a moz-do-not-send="true"
href="mailto:bkrepp@ctps.org">bkrepp@ctps.org</a></span></u><span></span></p>
<p class="MsoNormal"><span><a moz-do-not-send="true"
href="http://www.ctps.org/bostonmpo"><span>www.ctps.org/bostonmpo</span></a></span><span></span></p>
<p class="MsoNormal"><span><img id="Picture_x0020_1"
src="cid:part4.09030408.06070108@dmsolutions.ca"
alt="Description: Description:
cid:5F54AF76-729F-48CE-9BEE-5E4887E4DA63" height="73"
width="233"></span></p>
<p class="MsoNormal"> </p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
MetaCRS mailing list
<a class="moz-txt-link-abbreviated" href="mailto:MetaCRS@lists.osgeo.org">MetaCRS@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/metacrs">http://lists.osgeo.org/mailman/listinfo/metacrs</a>
</pre>
</blockquote>
<br>
</body>
</html>