我是一个新手程序员在为智能手机基于JavaScript的网络应用程序工作。
应用程序使用navigator.geolocation接口获取经度和纬度。
我需要一个基于JavaScript的函数来转换获得的位置为东和北使用多锥变换与“珠穆朗玛峰-印度1830”基准,我需要支持。同样,将东经/北距转换为经度/纬度也需要相同的反函数。
在互联网上做了一些研究之后,我偶然发现了proj4js。但是,我无法非常清楚地了解所需转换的过程&也找不到足够的文档。
提前谢谢。
发布于 2012-06-15 22:44:38
好的,使用Spatialreference.org的REST服务,您可以获得这个投影的定义(http://spatialreference.org/ref/sr-org/7345/proj4/),结果是
+proj=poly +lat_0=33.625 +lon_0=77.375 +x_0=0 +y_0=0 +a=6377301.243 +b=6356100.228368102 +units=m +no_defs若要使其与proj4一起使用,请在defs/文件夹中创建一个名为SRORG7345.js的定义文件,其中包含以下内容:
Proj4js.defs["SRORG7345"] = "+proj=poly +lat_0=33.625 +lon_0=77.375 +x_0=0 +y_0=0 +a=6377301.243 +b=6356100.228368102 +units=m +no_defs";然后执行此操作以从EPSG:4236转换为您的新投影:
<html>
<Script src='proj4js-compressed.js'></script>
<script src='defs/EPSG4236.js'></script>
<script src='defs/SRORG7345.js'></script>
<script>
// creating source and destination Proj4js objects
// once initialized, these may be re-used as often as needed
var source = new Proj4js.Proj('EPSG:4236'); //source coordinates will be in Longitude/Latitude
var dest = new Proj4js.Proj('SRORG7345'); //IndiaPolyConic
var p = new Proj4js.Point(-76.0,45.0); //any object will do as long as it has 'x' and 'y' properties
Proj4js.transform(source, dest, p); //do the transformation. x and y are modified in place
console.log(p);
</script>
</html>我要指出的是,根据proj4js项目页面,多锥转换“尚未针对任何测试点进行验证”,因此您可能需要对这些结果进行一些检查。
https://stackoverflow.com/questions/11051749
复制相似问题