12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- const fs = require('fs');
- const turf = require('@turf/turf');
- const parse = require('wellknown');
- const wuShuiColor = "#628DB6";
- const wuShuiCircle = 500001;
- const wuShuiFang = 500003;
- const fangGuan=12010001;
- const yuanGuan=310000;
- const scaleYuan=3.1;
- const scaleFang=1;
- const yuanDefault=2.3;
- function readLineFile(inFilePath, outFilePath) {
- try {
- // 同步读取GeoJSON文件
- const data = fs.readFileSync(inFilePath, 'utf8');
- // 解析GeoJSON数据
- const geojson = JSON.parse(data);
- for (let i = 0; i < geojson.features.length; i++) {
- geojson.features[i].geometry.coordinates[0][0][2]=geojson.features[i].geometry.coordinates[0][0][2]-0.5
- let feature = geojson.features[i];
- if (geojson.features[i].properties["排口断"] !== null &&
- geojson.features[i].properties["排口断"].includes("×")) {
- // 方管
- geojson.features[i].properties["符号风格"] = fangGuan
- geojson.features[i].properties["符号颜色"] = wuShuiColor
- let ll = geojson.features[i].properties["排口断"].split("×")
- geojson.features[i].properties["x长"] = Number(ll[0]) / 1000
- geojson.features[i].properties["x宽"] = Number(ll[1]) / 1000
- } else {
- // 圆管
- geojson.features[i].properties["符号风格"] = yuanGuan
- geojson.features[i].properties["符号颜色"] = wuShuiColor
- geojson.features[i].properties["x长"] = Number(geojson.features[i].properties["排口断"]) / 2 / 1000
- geojson.features[i].properties["x宽"] = Number(geojson.features[i].properties["排口断"]) / 2 / 1000
- }
- }
- // 同步写入GeoJSON文件
- fs.writeFileSync(outFilePath, JSON.stringify(geojson, null, 2));
- console.log('GeoJSON文件已成功保存');
- } catch (err) {
- console.error('操作GeoJSON文件时出错:', err);
- }
- }
- readLineFile("./data/guanxian/雨水/原始数据/排水口_L.geojson", "./data/guanxian/雨水/符号字段/排水口_L.geojson");
|