优化巡检定位不准确问题

This commit is contained in:
wuxw 2025-04-15 14:38:47 +08:00
parent 696f2d9cd7
commit 70c9d0d654
3 changed files with 56 additions and 6 deletions

View File

@ -119,4 +119,52 @@ export function listInspectionTaskDetails(_that,_data){
} }
}); });
}) })
}
var x_PI = 3.14159265358979324 * 3000.0 / 180.0;
var PI = 3.1415926535897932384626;
var a = 6378245.0;
var ee = 0.00669342162296594323;
function out_of_china(lng, lat) {
var lat = +lat;
var lng = +lng;
// 纬度3.86~53.55,经度73.66~135.05
return !(lng > 73.66 && lng < 135.05 && lat > 3.86 && lat < 53.55);
}
function transformlat(lng, lat) {
var lat = +lat;
var lng = +lng;
var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
return ret
}
function transformlng(lng, lat) {
var lat = +lat;
var lng = +lng;
var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;
return ret
}
export function wgs84togcj02(lng, lat) {
var lat = +lat;
var lng = +lng;
if (out_of_china(lng, lat)) {
return [lng, lat]
} else {
var dlat = transformlat(lng - 105.0, lat - 35.0);
var dlng = transformlng(lng - 105.0, lat - 35.0);
var radlat = lat / 180.0 * PI;
var magic = Math.sin(radlat);
magic = 1 - ee * magic * magic;
var sqrtmagic = Math.sqrt(magic);
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
var mglat = lat + dlat;
var mglng = lng + dlng;
return { lat: mglat, lng: mglng }
}
} }

View File

@ -17,12 +17,12 @@ let baseUrl = '/';
// 腾讯地图Key, h5使用 // 腾讯地图Key, h5使用
let QQMapKey = ''; let QQMapKey = '';
let commonBaseUrl= 'https://shuimuwy.com/'; let commonBaseUrl= 'http://demo.homecommunity.cn/';
// #ifndef H5 // #ifndef H5
//服务器域名 小程序 或者 app 时 后端地址 //服务器域名 小程序 或者 app 时 后端地址
//let baseUrl = 'http://demo.homecommunity.cn/'; //let baseUrl = 'http://demo.homecommunity.cn/';
let baseUrl = 'https://shuimuwy.com/'; let baseUrl = 'http://demo.homecommunity.cn/';
// #endif // #endif
//app支付时这里需要填写支付秘钥 //app支付时这里需要填写支付秘钥

View File

@ -54,7 +54,8 @@
} from '../../lib/java110/utils/common.js'; } from '../../lib/java110/utils/common.js';
import { import {
queryDictInfo, queryDictInfo,
queryInspectionItemTitle queryInspectionItemTitle,
wgs84togcj02
} from '../../api/inspection/inspection.js'; } from '../../api/inspection/inspection.js';
import { import {
getCurrentCommunity, getCurrentCommunity,
@ -263,7 +264,8 @@
} else { } else {
this.description += (item.itemTitle + ':' + item.radio + ';') this.description += (item.itemTitle + ':' + item.radio + ';')
} }
}) });
let {lat,lng} = wgs84togcj02(this.longitude,this.latitude)
let obj = { let obj = {
"taskId": this.taskId, "taskId": this.taskId,
"taskDetailId": this.taskDetailId, "taskDetailId": this.taskDetailId,
@ -275,8 +277,8 @@
"photos": this.photos, "photos": this.photos,
"userId": this.userId, "userId": this.userId,
"userName": this.userName, "userName": this.userName,
"latitude": this.latitude, "latitude": lat,
"longitude": this.longitude "longitude": lng
} }
let msg = ""; let msg = "";