guanxian_gongyeguanxian.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // 排水接混接点标注_L
  2. const fs = require('fs');
  3. const wuShuiColor = "#FBBC05"; // 黄色
  4. const yuanGuan = 310000;
  5. /**
  6. * 找不到横截面数据全部按圆管处理半径0.8
  7. * @param {*} inFilePath
  8. * @param {*} outFilePath
  9. */
  10. function readLineFile(inFilePath, outFilePath) {
  11. try {
  12. // 同步读取GeoJSON文件
  13. const data = fs.readFileSync(inFilePath, 'utf8');
  14. // 解析GeoJSON数据
  15. const geojson = JSON.parse(data);
  16. for (let i = 0; i < geojson.features.length; i++) {
  17. let feature = geojson.features[i];
  18. // 圆管
  19. geojson.features[i].properties["符号风格"] = yuanGuan
  20. geojson.features[i].properties["符号颜色"] = wuShuiColor
  21. geojson.features[i].properties["x长"] = 0.1
  22. geojson.features[i].properties["x宽"] =0.1
  23. }
  24. // 同步写入GeoJSON文件
  25. fs.writeFileSync(outFilePath, JSON.stringify(geojson, null, 2));
  26. console.log('GeoJSON文件已成功保存');
  27. } catch (err) {
  28. console.error('操作GeoJSON文件时出错:', err);
  29. }
  30. }
  31. readLineFile("./data/guanxian/工业管线情况说明/原始数据/工业管线情况说明_L.geojson", "./data/guanxian/工业管线情况说明/符号字段/工业管线情况说明_L.geojson");