1

I am using street directory API and it is using the UTM WGS-1984 48N projection system. I only need to convert static values! I am mostly using JavaScript but at the moment I'm alright with any solutions!

1

You can use the OpenLayers coordinates conversion as below, but you need to add reference to OpenLayers script:

 <script src="OpenLayers.js"></script>
    <script>

        var fromProjection = new OpenLayers.Projection("EPSG:32648");   //refers to epsg projection 32648 - wgs 84 / utm zone 48n
        var toProjection   = new OpenLayers.Projection("EPSG:4326"); // to  wgs 84 
        var position       = new OpenLayers.LonLat(13.41,52.52).transform( fromProjection, toProjection);

    </script>

source: Example

  • The source data is in UTM zone 48N, and target should be in degrees. So this attempt does not deliver the needed values. – AndreJ Dec 4 '15 at 6:30
  • In this case, if as @J. Doe don't mind using any solution, there is a library in python to convert from UTM to lon & lat. pypi.python.org/pypi/utm – Shiko Dec 4 '15 at 6:37
  • proj4js.org should do almost the same in javascript. But I have no experience with it. – AndreJ Dec 4 '15 at 6:42
  • Source: EPSG:32648 refers to epsg projection 32648 - wgs 84 / utm zone 48n. Target: EPSG:4326 refers to epsg projection wgs 84 – Shiko Dec 4 '15 at 6:47
0

you can use this type of function as a parameter sending him a point and will return you to become longitude and latitude

convertPointGeoToGrades:function(point){
                console.log("pointMercator",point);
            var coordLatLong = webMercatorUtils.webMercatorToGeographic(point);
            console.log("coordLatLong",coordLatLong);
            var coordLatGrad = null;
            var coordLatMin = null;
            var coordLatSeg = null;
            var coordLongGrad = null;
            var coordLongMin = null;
            var coordLongSeg = null;
            // got dashes?
            //if ((coordLatLong.x.toString().substr(0,1) != "-")||(coordLatLong.y.toString().substr(0,1) != "-")) {
            //    alert("Selecciona una ubicacion dentro de Bolivia");
            //    this.clearAll();
            //}
            //else {
            // degrees = degrees
            coordLatGrad = coordLatLong.x.toString().split(".");
            dojo.byId("coordLatGrad").value = coordLatGrad[0];

            coordLongGrad = coordLatLong.y.toString().split(".");
            dojo.byId("coordLongGrad").value = coordLongGrad[0];

            // * 60 = mins
            var ddLatRemainder = ("0." + coordLatGrad[1]) * 60;
            coordLatMin = ddLatRemainder.toString().split(".");
            dojo.byId("coordLatMin").value = coordLatMin[0];

            var ddLongRemainder = ("0." + coordLongGrad[1]) * 60;
            coordLongMin = ddLongRemainder.toString().split(".");
            dojo.byId("coordLongMin").value = coordLongMin[0];

            // * 60 again = secs
            var ddLatMinRemainder = ("0." + coordLatMin[1]) * 60;
            dojo.byId("coordLatSeg").value = (ddLatMinRemainder).toFixed(4);

            var ddLongMinRemainder = ("0." + coordLongMin[1]) * 60;
            dojo.byId("coordLongSeg").value = (ddLongMinRemainder).toFixed(4);
            //}
        }
  • 1
    OP can't use the webMercatorUtils because the data is in UTM so how is this helpful? – mkennedy Dec 3 '15 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.