QCAD集成 proj4.js

qcad 集成 proj4.js

安装依赖 wkt-parser.js

  1. 下载源码 wkt-parser
  2. 修改源码 wkt-parser

在文件头添加如下代码:

if (typeof(global)==="undefined") {
  global = this;
}

(function (global, factory) {
  global.wkt = factory();
}(global, (function (wkt) {
'use strict';

同时删除文件末尾的

module.exports = index;

并添加

return index;

})));
  1. 下载源码 proj4.js
  2. 修改源码 proj4.js
(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('wkt-parser')) :
    typeof define === 'function' && define.amd ? define(['wkt-parser'], factory) :
    (global.proj4 = factory(global.wkt));
}(this, (function (wkt) { 'use strict';

改为


include("wkt-parser.js");
(function (global, factory) {
  global.proj4 = factory(global.wkt);
}(global, (function (wkt) {'use strict'

  1. 将修改后的wkt-parser.jsproj4.js放到scripts文件下。
  2. 测试,打开QCAD,单击菜单 [Misc]->[Development]-> [Scripshell],输入一下代码:
var firstProjection = 'PROJCS["NAD83 / Massachusetts Mainland",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",42.68333333333333],PARAMETER["standard_parallel_2",41.71666666666667],PARAMETER["latitude_of_origin",41],PARAMETER["central_meridian",-71.5],PARAMETER["false_easting",200000],PARAMETER["false_northing",750000],AUTHORITY["EPSG","26986"],AXIS["X",EAST],AXIS["Y",NORTH]]';
  
var secondProjection = "+proj=gnom +lat_0=90 +lon_0=0 +x_0=6300000 +y_0=6300000 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";

proj4(firstProjection,secondProjection,[2,5]);

如下图所示:

在这里插入图片描述

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片