86 lines
2.9 KiB
JavaScript
86 lines
2.9 KiB
JavaScript
|
|
// 通过打包配置文件来决定引入那些地图文件
|
||
|
|
|
||
|
|
// 以下文件为包含省内地级市区域内容细节的地图文件
|
||
|
|
import { provice as provice_incity } from "./provice/provice_incity"
|
||
|
|
|
||
|
|
// 以下文件为只包含省级地图轮廓信息的地图文件
|
||
|
|
import { provice as provice_nocity } from "./provice/provice_nocity"
|
||
|
|
|
||
|
|
// 以下_full文件为包含地级市市内区域内容细节的地图文件
|
||
|
|
import { provice as provice_full } from "./provice/provicegeo_full"
|
||
|
|
|
||
|
|
// 以下文件为只包含地级市地图轮廓信息的地图文件
|
||
|
|
import { provice as provice_geo } from "./provice/provicegeo"
|
||
|
|
|
||
|
|
// 以下_full文件为包含直辖市市内区域内容细节的地图文件
|
||
|
|
import { city as city_full } from "./city/citygeo_full"
|
||
|
|
|
||
|
|
// 以下文件为只包含直辖市市级地图轮廓信息的地图文件
|
||
|
|
import { city as city_geo } from "./city/citygeo"
|
||
|
|
|
||
|
|
export function intersect(checkPoint, polygonPoints) {
|
||
|
|
for (let j = 0; j < polygonPoints.features.length; j++) {
|
||
|
|
var counter = 0;
|
||
|
|
var i;
|
||
|
|
var xinters;
|
||
|
|
var p1, p2;
|
||
|
|
var pointCount = polygonPoints.features[j].geometry.coordinates[0][0].length;
|
||
|
|
p1 = polygonPoints.features[j].geometry.coordinates[0][0][0];
|
||
|
|
for (i = 1; i <= pointCount; i++) {
|
||
|
|
p2 = polygonPoints.features[j].geometry.coordinates[0][0][i % pointCount];
|
||
|
|
if (
|
||
|
|
checkPoint[0] > Math.min(p1[0], p2[0]) &&
|
||
|
|
checkPoint[0] <= Math.max(p1[0], p2[0])
|
||
|
|
) {
|
||
|
|
if (checkPoint[1] <= Math.max(p1[1], p2[1])) {
|
||
|
|
if (p1[0] != p2[0]) {
|
||
|
|
xinters =
|
||
|
|
(checkPoint[0] - p1[0]) *
|
||
|
|
(p2[1] - p1[1]) /
|
||
|
|
(p2[0] - p1[0]) +
|
||
|
|
p1[1];
|
||
|
|
if (p1[1] == p2[1] || checkPoint[1] <= xinters) {
|
||
|
|
counter++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
p1 = p2;
|
||
|
|
}
|
||
|
|
if (counter % 2 == 0) {
|
||
|
|
console.log(polygonPoints.features[j].properties.name)
|
||
|
|
} else {
|
||
|
|
return polygonPoints.features[j].properties.name;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export function findMap(nowPoint, name, deepset) {
|
||
|
|
let provice
|
||
|
|
let city
|
||
|
|
if (deepset[0]) {
|
||
|
|
if(deepset[1]){
|
||
|
|
provice = provice_full
|
||
|
|
city = city_full
|
||
|
|
}else{
|
||
|
|
provice = provice_geo
|
||
|
|
city = city_geo
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if(deepset[1]){
|
||
|
|
provice = provice_incity
|
||
|
|
city = city_full
|
||
|
|
}else{
|
||
|
|
provice = provice_nocity
|
||
|
|
city = city_geo
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (provice[name]) {
|
||
|
|
if (provice[name][name]) {
|
||
|
|
let cityname = intersect(nowPoint, provice[name][name])
|
||
|
|
return provice[name].city[cityname]
|
||
|
|
}
|
||
|
|
return provice[name]
|
||
|
|
}
|
||
|
|
return city[name]
|
||
|
|
}
|