我是一个新手程序员,致力于智能手机的基于JavaScript的Web应用程序。
该应用程序使用navigator.geolocation API获取经度和纬度。
我需要一个基于JavaScript的函数,以支持“ Everest-India 1830”基准的Polyconic Transformation将获得的位置转换为Easting&Northing。还将需要相同的逆函数将东/北转换为经度/纬度。
在互联网上进行研究后,我遇到了proj4js。但是,我不能很清楚地了解所需转换的步骤,也找不到足够的文档。
提前致谢。
最佳答案
好的,使用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项目页面,多圆锥体转换“尚未针对任何测试点进行验证”,因此您可能需要对这些结果进行一些检查。
关于javascript - 经度(WGS84)到多圆锥变换转换,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11051749/