Hello all,<br><br>I'm developing an application using GeoExt and Openlayers. I'm implementing a widget that will allow the user to enter coordinates in several SRS and the map gets zoomed to it while, at the same time, a vector feature is added to a specific layer. However i'm getting strange values after reprojecting the coordinates. I really need to use proj4js because some of the epsg definitions for Portuguese SRS do not have the local transformation parameters. For example, i wish to reproject from EPSG:20791 to EPSG:900913. This is what i have done:<br>
<br>1. Included proj4js-combined.js in the web page<br><br>2. Created the SRS defintions:<br>Proj4js.defs["EPSG:20791"] = "+proj=tmerc +lat_0=39.66666666666666 +lon_0=1 +k=1 +x_0=0 +y_0=0 +ellps=intl +pm=lisbon +units=m +towgs84=-288.885,-91.744,+126.244,-1.691,0.410,-0.211,-4.598";<br>
<br>Proj4js.defs["EPSG:900913"] = "+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 +nadgrids=@null +no_defs";<br><br>3. Then i tried the following:<br><br>var mercator = new OpenLayers.Projection("EPSG:900913");<br>
var hglipcc = new OpenLayers.Projection("EPSG:20791");<br>xcoord = 19120.326567<br>ycoord = -293121.903092<br>var coordMarker = new OpenLayers.Geometry.Point(xcoord, ycoord);<br>var coordMarkerRep = coordMarker.transform (hglipcc, etrs);<br>
var searchCoord = new OpenLayers.LonLat(xcoord, ycoord);<br>var searchCoordRep = searchCoord.transform(hglipcc, mercator);<br><br>Both returned the same wrong coordiantes: x= <span class="objectBox objectBox-number ">-881483.8794817993 and y= </span><span class="objectBox objectBox-number ">-7.081154551613622e-10 where they should be x= -881320.416615 and y= 4442714.696599.<br>
<br>Also, i have tried to use the projection definitions and reproject transformation directly from Proj4js and the returned results were exactly the same. <br><br>Finally i have tried to reproject to EPSG:4326 and still, the output coordinates are strange: it returned lon=</span><span class="objectBox objectBox-number ">-7.918504416434706 and lat=0 where it should be lon=-7.917036 and lat=37.025879.<br>
<br>Is this a known problem or is it something i'm doing wrong? Any sugestions are more than welcome!<br>Thanks in advance.<br><br>Best regards,<br>Hugo<br></span><span class="objectBox objectBox-number "><br></span><br>
<br><br><br><br>3. Defined projections using new OpenLayers.Projection('EPSG:xxxxx');<br><br>4. the code used to reproject:<br><br>var coordMarker = new OpenLayers.Geometry.Point(xcoord, ycoord); //these coords in epsg 27492<br>
<br>OpenLayers.Projection.transform(coordMarker, hg73ipcc, mercator);<br><br>The coordinates introduced were x= 19300.924567 and y=-293208.893092 and the output was x=-1897829.842341831 and y=4442821.889195204. The expected output should be x=-881320.416615 and y=4442714.696599<br>
<br>I've tried to reproject from epsg:27492 to wgs84 and also got wrong coordinates returned.<br>Am i missing something here??? Any sugestions to solve this?<br clear="all"><br>-- <br>Hugo Martins<br>LabNT - ISEGI UNL<br>
Campus de Campolide<br>1070-312 Lisboa<br>N 38°43'56.84", W 9°9'35.74"<br>