软件导出成果图效果
一、技术实现应用背景
大气污染是当今世界面临的一个严重问题。它不仅对人类健康造成了危害,还对环境和生态系统产生了负面影响。在许多地区,大气污染已经成为了日常生活中不可忽视的问题。
虽然大气污染的问题是复杂的,但是我们可以采取措施来减少它的影响。首先,我们需要加强环保意识,更加注重环境保护。这需要我们每个人都能够负起责任,采取行动来减少我们的碳排放量。例如,我们可以骑自行车或步行代替开车,减少能源的消耗。我们也可以减少使用塑料袋和一次性餐具等对环境有害的物品。
其次,政府也应该采取行动,制定更加严格的环保法规。政府可以加强环境监测,对那些污染环境的企业进行处罚。政府还可以鼓励和支持环保技术的发展和应用,提高环保产业的竞争力。
最后,我们还需要加强国际合作,共同应对大气污染问题。通过国际合作,我们可以分享经验和技术,共同应对全球气候变化和环境污染问题。只有大家齐心协力,才能够解决这个世界面临的共同问题。
在未来,我们需要更加注重环境保护,采取更加积极的行动来应对大气污染的问题。这不仅有利于人类健康,也有利于保护地球的生态系统和环境。让我们共同努力,为未来的世界创造一个更加美好的明天。
虽然大气污染是当今世界面临的一个严重问题,但它在空间分布上并不均匀。不同地区的大气污染程度有所不同,有些地区的污染更加严重。因此,我们需要采取针对性措施来应对不同地区的大气污染问题。通过加强环保意识、政府的环保法规、环保技术的发展和应用,以及国际合作,我们可以更加有效地解决大气污染问题,保护人类健康和地球的生态系统和环境。
虽然大气污染是一个严重的全球性问题,但它在不同地区的空间分布却是不均匀的。因此,为了更好地应对大气污染,我们需要针对不同地区制定具体的解决方案。同时,加强环保意识、推行环保法规和促进环保技术的发展,也是重要的应对措施。此外,国际间的合作也能够帮助我们更好地应对大气污染问题,保护人类健康和地球生态环境。我们可以通过制作空气质量插值图等方式来更加全面地了解大气污染的分布情况,为采取有效措施提供科学依据。
二、应用场景
三、空间地理信息数据处理
拆分全国、省、市、区县行政区划数据(目前处理出来3253矢量shp格式数据)
四、空气质量标准参照
环境空气质量指数(AQI)技术规定(试行)(HJ633_2012)
五、编写java代码实现
package cn.AirQuality.air.controller; import cn.AirQuality.air.common.HttpUtils; import cn.AirQuality.air.common.InterpolationUtils; import cn.AirQuality.air.model.StationWithData; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.io.File; import java.util.List; import java.util.Random; @Api(tags = "数据导出") @RestController @RequestMapping("/api/export") public class ExportController { @Value(value = "${export-path.EDVRURL}") private String EDVRURL; @Value(value = "${export-path.EDVRURL1}") private String EDVRURL1; @Value(value = "${export-path.EDVRRD}") private String EDVRRD; Double TransferDouble(Object v){ try { double vr = Double.valueOf(v.toString()); return vr; } catch (Exception e){ return 0.0; } } @ApiOperation(value = "EDVR") @GetMapping(value = "/EDVRVec") public String EDVRVec(String adcd,String dt,String avgType,String factor) { // 获取数据 JSONObject obj = JSON.parseObject("{data:" + HttpUtils.sendGet(EDVRURL1 + "/qEnvgasStationDay/findInterpolationDataList","monitorTime=" + dt.replace(" ", "%20") + "&property=" + avgType + "®ionCode=" + adcd + "&type=1") + "}"); JSONArray datalist = (JSONArray)obj.get("data"); double[][] trainData = new double[datalist.size()][3]; Random rdm=new Random(); for (int i = 0; i < datalist.size(); i++) { // StationWithData data = datalist.get(i); trainData[i][0] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("longitude")); trainData[i][1] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("latitude")); trainData[i][2] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get(factor)); // trainData[i][2] = TransferDouble(rdm.nextInt(500)); } //D:\gis\china String boundryFile =EDVRRD + "/" + adcd + "/bound.shp"; int[] size = new int[]{400, 400}; boolean isclip = true; double[] dataInterval = new double[]{0, 50, 100, 150, 200, 300} ; if(avgType.equals("1")){ if(factor.equals("so2")){ dataInterval = new double[]{0, 150, 500, 650, 800, 1600} ; } if(factor.equals("no2")){ dataInterval = new double[]{0, 100, 200, 700, 1200, 2340} ; } if(factor.equals("co")){ dataInterval = new double[]{0, 5, 10, 35, 60, 90} ; } if(factor.equals("o3")){ dataInterval = new double[]{0, 160, 200, 300, 400, 800} ; } if(factor.equals("pm25")){ dataInterval = new double[]{0, 35, 75, 115, 150, 250} ; } if(factor.equals("pm10")){ dataInterval = new double[]{0, 50, 150, 250, 350, 420} ; } } if(avgType.equals("2")||avgType.equals("3")){ if(factor.equals("so2")){ dataInterval = new double[]{0, 50, 150, 475, 800, 1600} ; } if(factor.equals("no2")){ dataInterval = new double[]{0, 40, 80, 180, 280, 565} ; } if(factor.equals("co")){ dataInterval = new double[]{0, 2, 4, 14, 24, 36} ; } if(factor.equals("o3")){ dataInterval = new double[]{0, 100, 160, 215, 265, 800} ; } if(factor.equals("pm25")){ dataInterval = new double[]{0, 35, 75, 115, 150, 250} ; } if(factor.equals("pm10")){ dataInterval = new double[]{0, 50, 150, 250, 350, 420} ; } } String strJson = InterpolationUtils.calEquiSurface(trainData, dataInterval, size, boundryFile, isclip); return strJson; } @ApiOperation(value = "EDVR") @GetMapping(value = "/EDVRVec1") public String EDVRVec1(String adcd,String dt,String avgType,String factor,String cityOrStation,String stationIdList) { // 获取数据 JSONObject obj = JSON.parseObject("{data:" + HttpUtils.sendGet(EDVRURL1 + "/qEnvgasStationDay/findInterpolationDataList","monitorTime=" + dt.replace(" ", "%20") + "&property=" + avgType + "®ionCode=" + adcd + "&cityOrStation=" + cityOrStation + "&stationIdList=" + stationIdList + "&type=1") + "}"); JSONArray datalist = (JSONArray)obj.get("data"); double[][] trainData = new double[datalist.size()][3]; Random rdm=new Random(); for (int i = 0; i < datalist.size(); i++) { // StationWithData data = datalist.get(i); trainData[i][0] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("longitude")); trainData[i][1] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("latitude")); trainData[i][2] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get(factor)); // trainData[i][2] = TransferDouble(rdm.nextInt(500)); } //D:\gis\china String boundryFile =EDVRRD + "/" + adcd + "/bound.shp"; int[] size = new int[]{400, 400}; boolean isclip = true; double[] dataInterval = new double[]{0, 50, 100, 150, 200, 300} ; if(avgType.equals("1")){ if(factor.equals("so2")){ dataInterval = new double[]{0, 150, 500, 650, 800, 1600} ; } if(factor.equals("no2")){ dataInterval = new double[]{0, 100, 200, 700, 1200, 2340} ; } if(factor.equals("co")){ dataInterval = new double[]{0, 5, 10, 35, 60, 90} ; } if(factor.equals("o3")){ dataInterval = new double[]{0, 160, 200, 300, 400, 800} ; } if(factor.equals("pm25")){ dataInterval = new double[]{0, 35, 75, 115, 150, 250} ; } if(factor.equals("pm10")){ dataInterval = new double[]{0, 50, 150, 250, 350, 420} ; } } if(avgType.equals("2")||avgType.equals("3")){ if(factor.equals("so2")){ dataInterval = new double[]{0, 50, 150, 475, 800, 1600} ; } if(factor.equals("no2")){ dataInterval = new double[]{0, 40, 80, 180, 280, 565} ; } if(factor.equals("co")){ dataInterval = new double[]{0, 2, 4, 14, 24, 36} ; } if(factor.equals("o3")){ dataInterval = new double[]{0, 100, 160, 215, 265, 800} ; } if(factor.equals("pm25")){ dataInterval = new double[]{0, 35, 75, 115, 150, 250} ; } if(factor.equals("pm10")){ dataInterval = new double[]{0, 50, 150, 250, 350, 420} ; } } String strJson = InterpolationUtils.calEquiSurface(trainData, dataInterval, size, boundryFile, isclip); return strJson; } public String InterpolationVec(String adcd,JSONArray datalist,String avgType,String factor) { double[][] trainData = new double[datalist.size()][3]; Random rdm=new Random(); for (int i = 0; i < datalist.size(); i++) { // StationWithData data = datalist.get(i); trainData[i][0] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("longitude")); trainData[i][1] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("latitude")); trainData[i][2] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get(factor)); // trainData[i][2] = TransferDouble(rdm.nextInt(500)); } //D:\gis\china String boundryFile =EDVRRD + "/" + adcd + "/bound.shp"; System.out.println(boundryFile); int[] size = new int[]{400, 400}; boolean isclip = true; double[] dataInterval = new double[]{0, 50, 100, 150, 200, 300} ; if(avgType.equals("1")){ if(factor.equals("so2")){ dataInterval = new double[]{0, 150, 500, 650, 800, 1600} ; } if(factor.equals("no2")){ dataInterval = new double[]{0, 100, 200, 700, 1200, 2340} ; } if(factor.equals("co")){ dataInterval = new double[]{0, 5, 10, 35, 60, 90} ; } if(factor.equals("o3")){ dataInterval = new double[]{0, 160, 200, 300, 400, 800} ; } if(factor.equals("pm25")){ dataInterval = new double[]{0, 35, 75, 115, 150, 250} ; } if(factor.equals("pm10")){ dataInterval = new double[]{0, 50, 150, 250, 350, 420} ; } } if(avgType.equals("2")||avgType.equals("3")){ if(factor.equals("so2")){ dataInterval = new double[]{0, 50, 150, 475, 800, 1600} ; } if(factor.equals("no2")){ dataInterval = new double[]{0, 40, 80, 180, 280, 565} ; } if(factor.equals("co")){ dataInterval = new double[]{0, 2, 4, 14, 24, 36} ; } if(factor.equals("o3")){ dataInterval = new double[]{0, 100, 160, 215, 265, 800} ; } if(factor.equals("pm25")){ dataInterval = new double[]{0, 35, 75, 115, 150, 250} ; } if(factor.equals("pm10")){ dataInterval = new double[]{0, 50, 150, 250, 350, 420} ; } } String strJson = InterpolationUtils.calEquiSurface(trainData, dataInterval, size, boundryFile, isclip); return strJson; } public String InterpolationVec(String adcd,Listdatalist ,String avgType,String factor) { double[][] trainData = new double[datalist.size()][3]; Random rdm=new Random(); for (int i = 0; i < datalist.size(); i++) { StationWithData data = datalist.get(i); trainData[i][0] = data.getLongitude().doubleValue(); trainData[i][1] = data.getLatitude().doubleValue(); trainData[i][2] = data.getAqi().doubleValue(); if(factor.equals("co")){ trainData[i][2] = data.getCo().doubleValue(); } if(factor.equals("so2")){ trainData[i][2] = data.getSo2().doubleValue(); } if(factor.equals("no2")){ trainData[i][2] = data.getNo2().doubleValue(); } if(factor.equals("o3")){ trainData[i][2] = data.getO3().doubleValue(); } if(factor.equals("pm10")){ trainData[i][2] = data.getPm10().doubleValue(); } if(factor.equals("pm25")){ trainData[i][2] = data.getPm25().doubleValue(); } // trainData[i][2] = TransferDouble(rdm.nextInt(500)); } //D:\gis\china String boundryFile =EDVRRD + "\\" + adcd + "\\bound.shp"; int[] size = new int[]{400, 400}; boolean isclip = true; double[] dataInterval = new double[]{0, 50, 100, 150, 200, 300} ; if(avgType.equals("1")){ if(factor.equals("so2")){ dataInterval = new double[]{0, 150, 500, 650, 800, 1600} ; } if(factor.equals("no2")){ dataInterval = new double[]{0, 100, 200, 700, 1200, 2340} ; } if(factor.equals("co")){ dataInterval = new double[]{0, 5, 10, 35, 60, 90} ; } if(factor.equals("o3")){ dataInterval = new double[]{0, 160, 200, 300, 400, 800} ; } if(factor.equals("pm25")){ dataInterval = new double[]{0, 35, 75, 115, 150, 250} ; } if(factor.equals("pm10")){ dataInterval = new double[]{0, 50, 150, 250, 350, 420} ; } } if(avgType.equals("2")||avgType.equals("3")){ if(factor.equals("so2")){ dataInterval = new double[]{0, 50, 150, 475, 800, 1600} ; } if(factor.equals("no2")){ dataInterval = new double[]{0, 40, 80, 180, 280, 565} ; } if(factor.equals("co")){ dataInterval = new double[]{0, 2, 4, 14, 24, 36} ; } if(factor.equals("o3")){ dataInterval = new double[]{0, 100, 160, 215, 265, 800} ; } if(factor.equals("pm25")){ dataInterval = new double[]{0, 35, 75, 115, 150, 250} ; } if(factor.equals("pm10")){ dataInterval = new double[]{0, 50, 150, 250, 350, 420} ; } } String strJson = InterpolationUtils.calEquiSurface(trainData, dataInterval, size, boundryFile, isclip); return strJson; } @ApiOperation(value = "EDVR") @GetMapping(value = "/EDVRVecForcast") public String EDVRVecForcast(String adcd,String dt,String factor) { // 获取数据 JSONObject obj = JSON.parseObject("{data:" + HttpUtils.sendGet(EDVRURL1 + "/homePage/forcastMapAreaData","monitorTime=" + dt.replace(" ", "%20") + "&provinceCode=" + adcd) + "}"); JSONArray datalist = (JSONArray)obj.get("data"); double[][] trainData = new double[datalist.size()][3]; Random rdm=new Random(); for (int i = 0; i < datalist.size(); i++) { // StationWithData data = datalist.get(i); trainData[i][0] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("longitude")); trainData[i][1] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get("latitude")); trainData[i][2] = TransferDouble(((com.alibaba.fastjson.JSONObject)datalist.get(i)).get(factor)); // trainData[i][2] = TransferDouble(rdm.nextInt(300)); } //D:\gis\china String boundryFile =EDVRRD + "\\" + adcd + "\\bound.shp"; int[] size = new int[]{400, 400}; boolean isclip = true; double[] dataInterval = new double[]{0, 50, 100, 150, 200, 300} ; String strJson = InterpolationUtils.calEquiSurface(trainData, dataInterval, size, boundryFile, isclip); return strJson; } @ApiOperation(value = "EDVR管控数据") @GetMapping(value = "/stationEDVRURLVec") public String stationEDVRURLVec(String adcd,String factor,String monitorTime) { // 获取数据 JSONObject obj = JSON.parseObject(HttpUtils.sendGet(EDVRURL,"monitorTime=" + monitorTime + "®ionCode="+adcd)); JSONArray datalist = (JSONArray)obj.get("data"); return this.InterpolationVec(adcd,datalist,"1",factor); } /** * 删除文件或文件夹 * @param directory */ public static void delAllFile(File directory){ if (!directory.isDirectory()){ directory.delete(); } else{ File [] files = directory.listFiles(); // 空文件夹 if (files.length == 0){ directory.delete(); System.out.println("删除" + directory.getAbsolutePath()); return; } // 删除子文件夹和子文件 for (File file : files){ if (file.isDirectory()){ delAllFile(file); } else { file.delete(); System.out.println("删除" + file.getAbsolutePath()); } } // 删除文件夹本身 directory.delete(); System.out.println("删除" + directory.getAbsolutePath()); } } }
package cn.AirQuality.air.controller; import cn.AirQuality.air.common.DateUtil; import cn.AirQuality.air.common.HttpUtils; import cn.AirQuality.air.common.geotools.FileFormat; import cn.AirQuality.air.common.geotools.Shape2Image; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.util.Date; import java.util.HashMap; import java.util.Map; /** * 图层控制Controller * * @author zdh * @date 2021-03-30 */ @Api(tags = "数据导出") @RestController @RequestMapping("/MapManage/GeoProcess") public class GeoProcessController { private String prefix = "MapManage/GeoProcess"; @Value(value = "${export-path.EDVRURL1}") private String EDVRURL1; @Value(value = "${export-path.EDVRRD}") private String EDVRRD; /** * * @param adcd 行正区域化 * @param exportscope 四至范围 * @param btime 开始时间 * @param etime 结束时间 * @param iWidth 图片宽 * @param iHeight 图片高 * @param avgType 时段类型:1小时,2、3天 * @param factor 污染物因子:aqi,so2,no2,co,o3,pm25,pm10 * @param cityOrStation 区域1,站点2 * @param stationIdList * @param request * @return */ //http://localhost:8915/MapManage/GeoProcess/exportMapByIv?adcd=0&exportscope=73.501142,6.323421,135.088511,53.560901&btime=2023-05-22 13:00&etime=2023-05-22 14:00&factor=so2&cityOrStation=1&avgType=1&iWidth=800&iHeight=600 @GetMapping("/exportMapByIv") @ResponseBody public String exportMapByIv(String adcd,String exportscope,String btime,String etime,int iWidth,int iHeight,String avgType,String factor,String cityOrStation,String stationIdList,HttpServletRequest request) { long start = System.currentTimeMillis(); String cdir=System.getProperty("user.dir"); String bPath = request.getServletContext().getRealPath(""); Date dt1=new Date(btime.replace("-","/")); Date dt2=new Date(etime.replace("-","/")); String dts=""; String imgs=""; while(dt2.compareTo(dt1)>-1){ // System.out.println(bPath); Shape2Image shp2img = new Shape2Image(); shp2img.ClearAllLayer(); String shpPath3 = EDVRRD + "/"+adcd+"/XZQH.shp"; String sldPath3 = EDVRRD + "/airsld/sld_XZQH1.sld"; String shpPath4 = EDVRRD + "/"+adcd+"/XZQHLabel.shp"; String sldPath4 = EDVRRD + "/airsld/sld_XZQHLabel.sld"; // String shpPath6 = "sxj/"+adcd+"subtitle.shp"; String dt=""; String imgDt=""; if(avgType.equals("1")){ imgDt = DateUtil.format(dt1,"yyyyMMddHH"); dt = DateUtil.format(dt1,"yyyy-MM-dd HH"); } if(avgType.equals("2")){ imgDt = DateUtil.format(dt1,"yyyyMMdd"); dt = DateUtil.format(dt1,"yyyy-MM-dd"); } if(avgType.equals("3")){ imgDt = DateUtil.format(dt1,"yyyyMM"); dt = DateUtil.format(dt1,"yyyy-MM"); } if(dt2.compareTo(dt1)==0){ dts = dts + imgDt; imgs = imgs + "/duoyuanronghe/"+adcd+"/img1/"+factor+"/"+avgType+"/G_" + imgDt + ".png"; }else { dts = dts + imgDt + ","; imgs = imgs + "/duoyuanronghe/"+adcd+"/img1/"+factor+"/"+avgType+"/G_" + imgDt + ".png,"; } File file4 = new File(EDVRRD + "/"+adcd+"/img1"); if(!file4.exists()){ file4.mkdir(); } File file3 = new File(EDVRRD + "/"+adcd+"/img1/"+factor); if(!file3.exists()){ file3.mkdir(); } File file2 = new File(EDVRRD + "/"+adcd+"/img1/"+factor+"/"+avgType); if(!file2.exists()){ file2.mkdir(); } File file1 = new File(EDVRRD + "/"+adcd+"/img1/"+factor+"/"+avgType+"/"+imgDt); if(!file1.exists()){ file1.mkdir(); } String shpPath2 = EDVRRD + "/"+adcd+"/img1/"+factor+"/"+avgType+"/"+imgDt+"/interpolation.shp"; String sldPath2 = EDVRRD + "/airsld/sld_interpolation"+factor+avgType+".sld"; String imgPath = EDVRRD + "/"+adcd+"/img1/"+factor+"/"+avgType+"/G_" + imgDt + ".png"; String geots=""; // geots = HttpUtils.sendGet("http://localhost:8915/api/export/controlEDVRVec","adcd=" + adcd+"&btime="+btime+"&etime="+etime); geots = HttpUtils.sendGet("http://localhost:8915/api/export/EDVRVec1", "adcd=" + adcd + "&dt=" + dt.replace(" ", "%20") + "&avgType=" + avgType+ "&cityOrStation=" + cityOrStation + "&stationIdList=" + stationIdList + "&factor=" + factor); FileFormat.geojson2Shape(geots,shpPath2); // FileFormat.geojsonf2Shape("sxj/"+adcd+"subtitle.json",shpPath6,"NAME","2021年4月13日20时-2021年4月14日20时"); Map paras = new HashMap(); // //double[] bbox = new double[]{114.810126,34.377357,122.705605,38.399928};山东 //double[] bbox = new double[]{102.458229,29.652697,106.431929,32.136854}; double[] bbox = new double[]{Double.parseDouble(exportscope.split(",")[0]),Double.parseDouble(exportscope.split(",")[1]),Double.parseDouble(exportscope.split(",")[2]),Double.parseDouble(exportscope.split(",")[3])}; paras.put("bbox", bbox); paras.put("width", iWidth); paras.put("height", iHeight); shp2img.addShapeLayer(shpPath2, sldPath2); // shp2img.addShapeLayer(shpPath3, sldPath3); // shp2img.addShapeLayer(shpPath4, sldPath4); shp2img.getMapContent(paras, imgPath); if(avgType.equals("1")){ dt1 = DateUtil.addDateHours(dt1,1); } if(avgType.equals("2")){ dt1 = DateUtil.addDateDays(dt1,1); } if(avgType.equals("3")){ dt1 = DateUtil.addDateMonths(dt1,1); } } return "{\"imgs\":\""+imgs+"\"," + "\"dts\":\""+dts+"\",\"spend\":\"图片生成完成,共耗时"+(System.currentTimeMillis() - start)+"ms\"}"; } @GetMapping("/exportMapByIvADCD") @ResponseBody public String exportMapByIvADCD(String adcd,String exportscope,String btime,String etime,int iWidth,int iHeight,String avgType,String factor,HttpServletRequest request) { long start = System.currentTimeMillis(); String cdir=System.getProperty("user.dir"); String bPath = request.getServletContext().getRealPath(""); Date dt1=new Date(btime.replace("-","/")); Date dt2=new Date(etime.replace("-","/")); String dts=""; String imgs=""; while(dt2.compareTo(dt1)>-1){ // System.out.println(bPath); Shape2Image shp2img = new Shape2Image(); shp2img.ClearAllLayer(); String sldPath3 = EDVRRD + "/airsld/sld_XZQH2.sld"; String shpPath4 = EDVRRD + "/"+adcd+"/XZQHLabel.shp"; String sldPath4 = EDVRRD + "/airsld/sld_XZQHLabel.sld"; // String shpPath6 = "sxj/"+adcd+"subtitle.shp"; String dt=""; String imgDt=""; if(avgType.equals("1")){ imgDt = DateUtil.format(dt1,"yyyyMMddHH"); dt = DateUtil.format(dt1,"yyyy-MM-dd HH"); } if(avgType.equals("2")){ imgDt = DateUtil.format(dt1,"yyyyMMdd"); dt = DateUtil.format(dt1,"yyyy-MM-dd"); } if(avgType.equals("3")){ imgDt = DateUtil.format(dt1,"yyyyMM"); dt = DateUtil.format(dt1,"yyyy-MM"); } if(dt2.compareTo(dt1)==0){ dts = dts + imgDt; imgs = imgs + "/duoyuanronghe/"+adcd+"/img2/"+factor+"/"+avgType+"/G_" + imgDt + ".png"; }else { dts = dts + imgDt + ","; imgs = imgs + "/duoyuanronghe/"+adcd+"/img2/"+factor+"/"+avgType+"/G_" + imgDt + ".png,"; } File file4 = new File(EDVRRD + "/"+adcd+"/img2"); if(!file4.exists()){ file4.mkdir(); } File file3 = new File(EDVRRD + "/"+adcd+"/img2/"+factor); if(!file3.exists()){ file3.mkdir(); } File file2 = new File(EDVRRD + "/"+adcd+"/img2/"+factor+"/"+avgType); if(!file2.exists()){ file2.mkdir(); } File file1 = new File(EDVRRD + "/"+adcd+"/img2/"+factor+"/"+avgType+"/"+imgDt); if(!file1.exists()){ file1.mkdir(); } String shpPath3 = EDVRRD + "/"+adcd+"/img2/"+factor+"/"+avgType+"/"+imgDt+"/XZQH.shp"; String imgPath = EDVRRD + "/"+adcd+"/img2/"+factor+"/"+avgType+"/G_" + imgDt + ".png"; JSONObject obj = JSON.parseObject("{data:" + HttpUtils.sendGet(EDVRURL1+"/qEnvgasStationDay/findInterpolationDataList","monitorTime=" + dt.replace(" ", "%20") + "&property=" + avgType + "®ionCode=" + adcd + "&type=2") + "}"); JSONArray datalist = (JSONArray)obj.get("data"); FileFormat.geojsonf2Shape(EDVRRD + "/"+adcd+"/XZQH.json",shpPath3,"level",factor+"Level", datalist,"PAC","regionCode"); // FileFormat.geojsonf2Shape("sxj/"+adcd+"subtitle.json",shpPath6,"NAME","2021年4月13日20时-2021年4月14日20时"); Map paras = new HashMap(); // //double[] bbox = new double[]{114.810126,34.377357,122.705605,38.399928};山东 //double[] bbox = new double[]{102.458229,29.652697,106.431929,32.136854}; double[] bbox = new double[]{Double.parseDouble(exportscope.split(",")[0]),Double.parseDouble(exportscope.split(",")[1]),Double.parseDouble(exportscope.split(",")[2]),Double.parseDouble(exportscope.split(",")[3])}; paras.put("bbox", bbox); paras.put("width", iWidth); paras.put("height", iHeight); shp2img.addShapeLayer(shpPath3, sldPath3); shp2img.addShapeLayer(shpPath4, sldPath4); shp2img.getMapContent(paras, imgPath); if(avgType.equals("1")){ dt1 = DateUtil.addDateHours(dt1,1); } if(avgType.equals("2")){ dt1 = DateUtil.addDateDays(dt1,1); } if(avgType.equals("3")){ dt1 = DateUtil.addDateMonths(dt1,1); } } return "{\"imgs\":\""+imgs+"\"," + "\"dts\":\""+dts+"\",\"spend\":\"图片生成完成,共耗时"+(System.currentTimeMillis() - start)+"ms\"}"; } }
六、模拟空气质量小时变换效果
如果对您有帮助
技术合作交流qq:2401315930