[MetaCRS] Problems when reprojecting with Proj4js
Hugo
hfpmartins at gmail.com
Fri Mar 4 10:24:29 EST 2011
Hello Michael,
Thanks for your quick answer. Well, i'm not sure but i think i was using
version 1.0.1. Nevertheless, i have downloaded the trunk and still get the
same wrong coordinates as before.
Any hints more?
I would also like to make an additional question which might be important
after solving this issue. Is it possible to use grids through proj4js?? This
might be or relevance specially if i want to reproject from EPSG:27492 to
EPSG:3763 (etrs89).
Thanks once again.
Best regards,
Hugo
On Fri, Mar 4, 2011 at 2:48 PM, Michael Adair <madair at dmsolutions.ca> wrote:
> Hugo,
>
> I just tried your test case in the index page of Proj4js trunk and it came
> up with the correct transformed coords. Do you have an up-to-date version
> of Proj4js?
>
> Mike
>
>
> On 04/03/2011 9:21 AM, Hugo wrote:
>
> Hello all,
>
> 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:
>
> 1. Included proj4js-combined.js in the web page
>
> 2. Created the SRS defintions:
> 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";
>
> 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";
>
> 3. Then i tried the following:
>
> var mercator = new OpenLayers.Projection("EPSG:900913");
> var hglipcc = new OpenLayers.Projection("EPSG:20791");
> xcoord = 19120.326567
> ycoord = -293121.903092
> var coordMarker = new OpenLayers.Geometry.Point(xcoord, ycoord);
> var coordMarkerRep = coordMarker.transform (hglipcc, etrs);
> var searchCoord = new OpenLayers.LonLat(xcoord, ycoord);
> var searchCoordRep = searchCoord.transform(hglipcc, mercator);
>
> Both returned the same wrong coordiantes: x= -881483.8794817993 and y= -7.081154551613622e-10
> where they should be x= -881320.416615 and y= 4442714.696599.
>
> Also, i have tried to use the projection definitions and reproject
> transformation directly from Proj4js and the returned results were exactly
> the same.
>
> Finally i have tried to reproject to EPSG:4326 and still, the output
> coordinates are strange: it returned lon=-7.918504416434706 and lat=0
> where it should be lon=-7.917036 and lat=37.025879.
>
> Is this a known problem or is it something i'm doing wrong? Any sugestions
> are more than welcome!
> Thanks in advance.
>
> Best regards,
> Hugo
>
>
>
>
>
>
> 3. Defined projections using new OpenLayers.Projection('EPSG:xxxxx');
>
> 4. the code used to reproject:
>
> var coordMarker = new OpenLayers.Geometry.Point(xcoord, ycoord); //these
> coords in epsg 27492
>
> OpenLayers.Projection.transform(coordMarker, hg73ipcc, mercator);
>
> 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
>
> I've tried to reproject from epsg:27492 to wgs84 and also got wrong
> coordinates returned.
> Am i missing something here??? Any sugestions to solve this?
>
> --
> Hugo Martins
> LabNT - ISEGI UNL
> Campus de Campolide
> 1070-312 Lisboa
> N 38°43'56.84", W 9°9'35.74"
>
>
> _______________________________________________
> MetaCRS mailing listMetaCRS at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/metacrs
>
>
> _______________________________________________
> MetaCRS mailing list
> MetaCRS at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/metacrs
>
>
--
Hugo Martins
LabNT - ISEGI UNL
Campus de Campolide
1070-312 Lisboa
N 38°43'56.84", W 9°9'35.74"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/metacrs/attachments/20110304/e5ad27c5/attachment-0001.html
More information about the MetaCRS
mailing list