|
|
@@ -8,7 +8,7 @@ let params = {
|
|
|
}
|
|
|
function writeJson(params){
|
|
|
//现将json文件读出来
|
|
|
- fs.readFile('./person.json',function(err,data){
|
|
|
+ fs.readFile('./map_bf.json',function(err,data){
|
|
|
console.log('读取文件')
|
|
|
if(err){
|
|
|
return console.error(err);
|
|
|
@@ -98,16 +98,16 @@ function writeJson(params){
|
|
|
// console.log(d.properties.Dist_name+' '+name,'----8888888888888888-----')
|
|
|
if(d.properties.Divi_name == provinceName){
|
|
|
if(d.properties.Dist_name == name){
|
|
|
- if(d.properties.Upaz_name == 'Manpura Upazila'||d.properties.Upaz_name=='Kala Para Upazila'||d.properties.Upaz_name=='Galachipa Upazila'){
|
|
|
+ if(d.properties.Upaz_name=='Kutubdia Upazila'||d.properties.Upaz_name=='Maheshkhali Upazila'||d.properties.Upaz_name=='Phulbari Sadar Upazila'||d.properties.Upaz_name=='Bhurungamari Upazila'){
|
|
|
continue
|
|
|
}
|
|
|
if(cfName == d.properties.Upaz_name){
|
|
|
continue
|
|
|
}
|
|
|
item.properties.name = d.properties.Dist_name+' Division';
|
|
|
- if(item.geometry.coordinates[0][0].length == 0){
|
|
|
+ if(item.geometry.coordinates.length == 0){
|
|
|
number++;
|
|
|
- item.geometry.coordinates[0][0] = JSON.parse(JSON.stringify(d.geometry.coordinates[0][0]));
|
|
|
+ item.geometry.coordinates = JSON.parse(JSON.stringify(d.geometry.coordinates));
|
|
|
console.log('已筛选 '+number+' '+d.properties.Upaz_name+'-------------1---------');
|
|
|
}else{
|
|
|
let xArr = [],xIndex = 0;
|
|
|
@@ -127,9 +127,7 @@ function writeJson(params){
|
|
|
x1 = Number(key);
|
|
|
xArr[xIndex] = Number(key);
|
|
|
}else{
|
|
|
- if(Math.abs(x2-Number(key)) > 3){
|
|
|
- xIndex++;
|
|
|
- xArr[xIndex] = Number(key)-x2>0?'+':'-';
|
|
|
+ if(Math.abs(x2-Number(key)) > 20){
|
|
|
xIndex++;
|
|
|
xArr[xIndex] = x2;
|
|
|
xIndex++;
|
|
|
@@ -140,9 +138,7 @@ function writeJson(params){
|
|
|
y1 = Number(j);
|
|
|
yArr[yIndex] = Number(j);
|
|
|
}else{
|
|
|
- if(Math.abs(y2-Number(j)) > 3){
|
|
|
- yIndex++;
|
|
|
- yArr[yIndex] = Number(j) - y2>0?'+':'-';
|
|
|
+ if(Math.abs(y2-Number(j)) > 20){
|
|
|
yIndex++;
|
|
|
yArr[yIndex] = y2;
|
|
|
yIndex++;
|
|
|
@@ -159,55 +155,39 @@ function writeJson(params){
|
|
|
yk = y2-y1>0?'+':'-';
|
|
|
ykk = y2;
|
|
|
}
|
|
|
- // console.log(x1,xk,x2,xkk,y1,yk,y2,ykk)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
xIndex++;
|
|
|
- yIndex++;
|
|
|
xArr[xIndex] = Number(x2);
|
|
|
+ yIndex++;
|
|
|
yArr[yIndex] = Number(y2);
|
|
|
if(x1||x2||y1||y2){
|
|
|
- console.log(xArr,yArr,'-------')
|
|
|
- if(yk == '-'){
|
|
|
- if(y2>y1){
|
|
|
- arr2 = d.geometry.coordinates[0][0].slice(y1,y2)
|
|
|
- }else{
|
|
|
- arr2 = d.geometry.coordinates[0][0].slice(y1,d.geometry.coordinates[0][0].length-1)
|
|
|
- arr2.push(...(d.geometry.coordinates[0][0].slice(0,y2)))
|
|
|
- }
|
|
|
+ console.log(xArr,item.geometry.coordinates[0][0].length,yArr,d.geometry.coordinates[0][0].length,'-------')
|
|
|
+ if(yArr.length == 4){
|
|
|
+ y1 = yArr[2]
|
|
|
+ y2 = yArr[1]
|
|
|
+ }
|
|
|
+ if(y2>y1){
|
|
|
+ arr2 = d.geometry.coordinates[0][0].slice(y2,d.geometry.coordinates[0][0].length)
|
|
|
+ arr2.push(...(d.geometry.coordinates[0][0].slice(0,y1)))
|
|
|
}else{
|
|
|
- if(yArr.length == 3){
|
|
|
- y1 = yArr[2]
|
|
|
- y2 = yArr[1]
|
|
|
- }
|
|
|
- if(y2>y1){
|
|
|
- arr2 = d.geometry.coordinates[0][0].slice(y2,d.geometry.coordinates[0][0].length-1)
|
|
|
- arr2.push(...(d.geometry.coordinates[0][0].slice(0,y1)))
|
|
|
- }else{
|
|
|
- arr2 = d.geometry.coordinates[0][0].slice(y2,y1)
|
|
|
- }
|
|
|
-
|
|
|
+ arr2 = d.geometry.coordinates[0][0].slice(y2,y1)
|
|
|
}
|
|
|
- if(xk == '-'){
|
|
|
- // if(xk != yk){
|
|
|
- // arr2 = arr2.reverse();
|
|
|
- // }
|
|
|
- if(x2>x1){
|
|
|
- item.geometry.coordinates[0][0].splice(x2,item.geometry.coordinates[0][0]-1-x2)
|
|
|
- item.geometry.coordinates[0][0].splice(0,x1,...arr2)
|
|
|
- }else{
|
|
|
- item.geometry.coordinates[0][0].splice(x2,x1-x2,...arr2)
|
|
|
- }
|
|
|
+ if(x2>x1){
|
|
|
+ item.geometry.coordinates[0][0].splice(x2,item.geometry.coordinates[0][0].length-1-x2)
|
|
|
+ item.geometry.coordinates[0][0].splice(0,x1,...arr2)
|
|
|
+ }else if(x2 == x1){
|
|
|
+ x1 = Math.max(...xArr)
|
|
|
+ x2 = Math.min(...xArr)
|
|
|
+ console.log(x1,x2)
|
|
|
+ item.geometry.coordinates[0][0].splice(x2,x1-x2,...arr2)
|
|
|
}else{
|
|
|
- if(x2>x1){
|
|
|
- item.geometry.coordinates[0][0].splice(x1,x2-x1,...arr2)
|
|
|
- }else{
|
|
|
- item.geometry.coordinates[0][0].splice(x1,item.geometry.coordinates[0][0]-1-x1)
|
|
|
- item.geometry.coordinates[0][0].splice(0,x2,...arr2)
|
|
|
- }
|
|
|
-
|
|
|
+ item.geometry.coordinates[0][0].splice(x2,x1-x2,...arr2)
|
|
|
+ }
|
|
|
+ if(d.geometry.coordinates.length>1){
|
|
|
+ item.geometry.coordinates.push(...d.geometry.coordinates.slice(1,d.geometry.coordinates.length))
|
|
|
}
|
|
|
number++;
|
|
|
console.log('已筛选 '+number+' '+d.properties.Upaz_name+'-------------2---------');
|
|
|
@@ -221,7 +201,6 @@ function writeJson(params){
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // console.log('计算第'+i+'轮结束'+' 未对比数'+arr3.length);
|
|
|
if(arr3Length == arr3.length){
|
|
|
index++;
|
|
|
}else{
|
|
|
@@ -232,19 +211,12 @@ function writeJson(params){
|
|
|
arr3Length = arr3.length;
|
|
|
fun(arr3,provinceName,name,item)
|
|
|
}else{
|
|
|
- // console.log(provinceName+' 1')
|
|
|
- // console.log(provinceNameArrJSON[provinceName]+' 2')
|
|
|
- // console.log(provinceNameArrJSON[provinceName].features.length+'已计算个数')
|
|
|
if(index>=2){
|
|
|
item = {
|
|
|
type: "Feature",
|
|
|
geometry: {
|
|
|
type: "MultiPolygon",
|
|
|
- coordinates: [
|
|
|
- [
|
|
|
- arr3[0].geometry.coordinates[0][0]
|
|
|
- ]
|
|
|
- ]
|
|
|
+ coordinates: arr3[0].geometry.coordinates
|
|
|
},
|
|
|
properties: {
|
|
|
name:'',
|
|
|
@@ -277,7 +249,7 @@ function writeJson(params){
|
|
|
}
|
|
|
}
|
|
|
// for(let provinceName of provinceNameArr){
|
|
|
- // for(let name of cityName['Barisal']){
|
|
|
+ for(let name of cityName['Barisal']){
|
|
|
let item = {
|
|
|
type: "Feature",
|
|
|
geometry: {
|
|
|
@@ -291,9 +263,9 @@ function writeJson(params){
|
|
|
index = 0;
|
|
|
number = 0;
|
|
|
arr3Length = 0;
|
|
|
- // fun(bangladesh.features,'Barisal',name,item)
|
|
|
- // }
|
|
|
- fun(bangladesh.features,'Barisal','Barisal',item)
|
|
|
+ fun(bangladesh.features,'Barisal',name,item)
|
|
|
+ }
|
|
|
+ // fun(bangladesh.features,'Barisal','Bhola',item)
|
|
|
// }
|
|
|
// fun(bangladesh.features,'Khulna')
|
|
|
// console.log(cityName)
|