Select to view content in your preferred language

Attempting to implement Proj4js

3498
2
04-10-2012 01:09 AM
Salomon_VágadalJoensen
Deactivated User
I'm trying to implement the Proj4js to convert geographic points from EPSG:32629 to EPSG:4326, instead of using geometry service, because it is easier on the server to do the conversion client-side.

I've followed the guide here:
http://www.polygongis.com/index.php/2011/05/02/proj4js-client-side-coordinate-conversion/

But the converted points are incorrect, compared to the geometry service that we have running.

The webpage we have it running on is: http://www.munin.fo/fiskikort.html (might not be available in the future)

but the relevant code is:
    <script type="text/javascript" src="proj4js/lib/proj4js-combined.js"></script>


 Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
 Proj4js.defs["EPSG:32629"] = "+proj=utm +zone=29 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
 
 var src = new Proj4js.Proj("EPSG:32629");
 var dst = new Proj4js.Proj("EPSG:4326");

/* ... */

 function projektión(evt) {
  // get mapPoint from event and display the mouse coordinates
  
  var point = new Proj4js.Point(evt.x, evt.y);
  var outpt = Proj4js.transform(src, dst, point);
  console.log("x: " + outpt.x + " y: " + outpt.y);
 }


I must be doing something wrong because the examples I've seen show that Proj4js works instead of a geometry service.
0 Kudos
2 Replies
derekswingley1
Deactivated User
Since this isn't a JS API specific question, I recommend posting this either on gis.stackexchange or the mailing list that covers proj4js.
0 Kudos
Salomon_VágadalJoensen
Deactivated User
After going through the code and the MapServer, I found out that it wasn't in what we usually use (which is WGS84 UTM29), but in webmercator ESRI:54004

Now the projections are correct down to +/- 1m.

Silly me.
0 Kudos