长江流域9省2市可视化(不展示业务信息水质及真实断面)

news/2024/10/30 12:00:21/

一、处理9省+2市地理信息为geojson集成到项目

 shp转geojson关键Java代码

/*** shp转换为Geojson* @param shpPath* @return*/
public static Map shape2Geojson(String shpPath,String filePath){Map map = new HashMap();FeatureJSON fjson = new FeatureJSON();try{StringBuffer sb = new StringBuffer();sb.append("{\"type\": \"FeatureCollection\",\"features\": ");File file = new File(shpPath);ShapefileDataStore shpDataStore = null;shpDataStore = new ShapefileDataStore(file.toURL());//设置编码Charset charset = Charset.forName("utf-8");shpDataStore.setCharset(charset);String typeName = shpDataStore.getTypeNames()[0];SimpleFeatureSource featureSource = null;featureSource =  shpDataStore.getFeatureSource (typeName);SimpleFeatureCollection result = featureSource.getFeatures();SimpleFeatureIterator itertor = result.features();JSONArray array = new JSONArray();while (itertor.hasNext()){SimpleFeature feature = itertor.next();StringWriter writer = new StringWriter();fjson.writeFeature(feature, writer);JSONObject json = new JSONObject(writer.toString());array.put(json);}itertor.close();sb.append(array.toString());sb.append("}");//写入文件try {File geofile = new File(filePath);PrintStream ps = new PrintStream(new FileOutputStream(geofile));ps.println( sb.toString());// 往文件里写入字符串} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}map.put("status", "success");map.put("message", sb.toString());}catch(Exception e){map.put("status", "failure");map.put("message", e.getMessage());e.printStackTrace();}return map;
}

二、配置可视化展示图层信息

前端架构设计实现可参照:iClientOL实现前端gis开发架构_兴诚的博客-CSDN博客

import { Layersymbols } from '../SymbolsInfo/mapSymbols'
import GeoJSON from 'ol/format/GeoJSON'
import {getLyaerRenderSymbol} from '../MapCommon'
import {LayersRenderSet} from '../RendersInfo/LayersRenderSet'export let layersInfo = {wyl: {layerCode:'wyl',sourceType:'ArcgisTile',title:'午夜蓝',url:'http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer',visible:false},XZQHRegion: {layerCode:'XZQHRegion',isRLayerPanel: true,sourceType: 'Vector',title: '行政区划',url: '/static/geojson/changjiangRegion/510000/bound.json',dataPath:'',geoType: 'geojson',wrapX: false,opacity: 1,location: {longitude: 109.46198629061443, latitude: 29.504518455495273, level: 5.64688833592623},visible: true},shanghaiRegion: {layerCode:'shanghaiRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/310000/bound.json',title:'上海市',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},jiangsuRegion: {layerCode:'jiangsuRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/320000/bound.json',title:'江苏省',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},zhejiangRegion: {layerCode:'zhejiangRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/330000/bound.json',title:'浙江省',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},anhuiRegion: {layerCode:'anhuiRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/340000/bound.json',title:'安徽省',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},jiangxiRegion: {layerCode:'jiangxiRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/360000/bound.json',title:'江西省',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},hubeiRegion: {layerCode:'hubeiRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/420000/bound.json',title:'湖北省',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},hunanRegion: {layerCode:'hunanRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/430000/bound.json',title:'湖南省',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},chongqingRegion: {layerCode:'chongqingRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/500000/bound.json',title:'重庆市',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},sichuanRegion: {layerCode:'sichuanRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/510000/bound.json',title:'四川省',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},yunnanRegion: {layerCode:'yunnanRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/530000/bound.json',title:'云南省',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},guizhouRegion: {layerCode:'guizhouRegion',isRLayerPanel: true,sourceType:'GeoVector',url:'/static/geojson/changjiangRegion/520000/bound.json',title:'贵州省',style:Layersymbols.areaRegionSymbol,format: new GeoJSON(),wrapX: false,opacity: 1,location: {longitude: 115.783878, latitude: 34.308761, level: 8},visible:true},changjiangLine: {layerCode: 'changjiangLine',isRLayerPanel: true,sourceType: 'Vector',title: '长江',url: '/static/geojson/changjiangRegion/riverL1.json',dataPath:'',// labelField: 'NAME',geoType: 'geojson',maxZoom: Infinity,minZoom: -Infinity,wrapX: false,opacity: 1,location: {longitude: 109.46198629061443, latitude: 29.504518455495273, level: 5.64688833592623},visible: true},geoJsonFe1: {layerCode: 'geoJsonFe1',isRLayerPanel: true,sourceType: 'Vector',title: '断面',url: '/static/geojson/changjiangRegion/duanmian.json',dataPath:'',floatLabelInfo: {floatLabelField: 'val', offsetX: 8, offsetY: -16},geoType: 'geojson',maxZoom: Infinity,minZoom: -Infinity,wrapX: false,opacity: 1,location: {longitude: 109.46198629061443, latitude: 29.504518455495273, level: 5.64688833592623},visible: true},CRegion: {layerCode: 'CRegion',sourceType: 'Vector',title: '绘制区域',wrapX: false,isModify: true,opacity: 1,visible: false},LS: {layerCode:'LS',sourceType:'Vector',title:'临时',wrapX:false,opacity: 1,visible:true}
}

三、行政区划刷新关键前端代码

refreshXZQH(regionCode){commonRefreshVectorGeojsonLayer('/static/geojson/changjiangRegion/'+regionCode+'/XZQH.json',layersInfo,'XZQHRegion',this.smap)
}

四、可视化效果

如果对恁有帮助,请点赞打赏支持! 

技术合作交流qq:2401315930


http://www.ppmy.cn/news/43924.html

相关文章

TensorFlow 2.0 快速入门指南:第二部分

原文:TensorFlow 2.0 Quick Start Guide 协议:CC BY-NC-SA 4.0 译者:飞龙 本文来自【ApacheCN 深度学习 译文集】,采用译后编辑(MTPE)流程来尽可能提升效率。 不要担心自己的形象,只关心如何实现…

嵌入式开发——串口常见问题和调试手段

1、串口介绍 参考博客:《ARM芯片(S5PV210芯片)——串口通信详解》、《UART和RS232、RS485的联系和区别、以及对软件编程的影响》; 2、串口常见问题 (1)内核没有开启串口,导致没有产生设备节点; (2)上层应用…

靶机精讲之CTF4

主机发现 靶机193 端口扫描 服务扫描 80,25(明确版本)攻击面更大 web渗透 blog是交互式的程序 发现index可进行手动爆破(地址包含) http://192.168.10.193/index.html?page../../../../../../../../etc/passwd 无发…

可视化图表API格式要求有哪些?Sugar BI详细代码示例(2)

Sugar BI中的每个图表可以对应一个数据 API,用户浏览报表时,选定一定的过滤条件,点击「查询」按钮将会通过 API 拉取相应的数据;前面说过,为了确保用户数据的安全性,Sugar BI上的所有数据请求都在Sugar BI的…

常用STM32F4HAL库函数及其示例

STM32F4HAL库函数是针对STM32F4系列微控制器的硬件抽象层,它封装了一些底层硬件操作,使程序员可以更方便地编写应用代码。以下是常用的一些STM32F4HAL库函数及其详细解释和示例。 GPIO库函数 HAL_GPIO_Init():初始化GPIO口。 示例&#xff…

gru 串联LLm

单纯是为了降低大LLM 设计的结构 当前如果transformers 可以 输出一个状态也是可以的 这样串联的好处是每次运行知识一个小模型的计算量 时间换空间的概念 可以训练100个模型而后根据需要进行微调 从100 个中选择一个预测比较接近的进行微调预测 预测后继续进行从100中选择 而后…

从 Python 中的字典列表中删除重复项

要从字典列表中删除重复项: 使用字典推导来遍历列表。使用每个 id 属性的值作为键,使用字典作为值。使用 dict.values() 方法只获取唯一的字典。使用 list() 类将结果转换为列表。 list_of_dictionaries [{id: 1, site: jiyik.com},{id: 2, site: goo…

男生|女生漫画头像怎么制作,分享3种免费制作方法,不用求人

大家发现没有,最近特别流行卡通漫画头像!一些小伙伴们通过处理自己的照片,把照片制作成漫画头像,让照片看起来更有趣。那么,男生、女生漫画头像怎么制作呢?需要用到哪些工具?今天给大家分享3种免费制作漫画…