java实现大气质量插值图及六项污染物插值图图片导出

news2024/7/4 4:24:04

软件导出成果图效果

一、技术实现应用背景

大气污染是当今世界面临的一个严重问题。它不仅对人类健康造成了危害,还对环境和生态系统产生了负面影响。在许多地区,大气污染已经成为了日常生活中不可忽视的问题。

虽然大气污染的问题是复杂的,但是我们可以采取措施来减少它的影响。首先,我们需要加强环保意识,更加注重环境保护。这需要我们每个人都能够负起责任,采取行动来减少我们的碳排放量。例如,我们可以骑自行车或步行代替开车,减少能源的消耗。我们也可以减少使用塑料袋和一次性餐具等对环境有害的物品。

其次,政府也应该采取行动,制定更加严格的环保法规。政府可以加强环境监测,对那些污染环境的企业进行处罚。政府还可以鼓励和支持环保技术的发展和应用,提高环保产业的竞争力。

最后,我们还需要加强国际合作,共同应对大气污染问题。通过国际合作,我们可以分享经验和技术,共同应对全球气候变化和环境污染问题。只有大家齐心协力,才能够解决这个世界面临的共同问题。

在未来,我们需要更加注重环境保护,采取更加积极的行动来应对大气污染的问题。这不仅有利于人类健康,也有利于保护地球的生态系统和环境。让我们共同努力,为未来的世界创造一个更加美好的明天。

虽然大气污染是当今世界面临的一个严重问题,但它在空间分布上并不均匀。不同地区的大气污染程度有所不同,有些地区的污染更加严重。因此,我们需要采取针对性措施来应对不同地区的大气污染问题。通过加强环保意识、政府的环保法规、环保技术的发展和应用,以及国际合作,我们可以更加有效地解决大气污染问题,保护人类健康和地球的生态系统和环境。

虽然大气污染是一个严重的全球性问题,但它在不同地区的空间分布却是不均匀的。因此,为了更好地应对大气污染,我们需要针对不同地区制定具体的解决方案。同时,加强环保意识、推行环保法规和促进环保技术的发展,也是重要的应对措施。此外,国际间的合作也能够帮助我们更好地应对大气污染问题,保护人类健康和地球生态环境。我们可以通过制作空气质量插值图等方式来更加全面地了解大气污染的分布情况,为采取有效措施提供科学依据。

二、应用场景

三、空间地理信息数据处理

拆分全国、省、市、区县行政区划数据(目前处理出来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 + "&regionCode=" + 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 + "&regionCode=" + 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,List<StationWithData> 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] = 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 + "&regionCode="+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 + "&regionCode=" + 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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/563990.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

关于如何使用 python 下载CSV格式数据

本章节内容节自《python 编程从入门到实践》第十六章&#xff0c;我们将从网络上下载数据&#xff0c;并对数据进行可视化。就可以对其进行分析甚至观察其规律和关联。 学习目标 我们将访问并可视化以下两种常见格式存储的数据&#xff1a; CSV 使用 Python 模块 CSV 来处理以…

测试2年,26岁大龄程序员面试13家公司,拿下25K,差点被面试官KO了···

前言 我大概面试了13家公司&#xff0c;简历包装的是两年半测试经验&#xff0c;因为我的年纪已经是26岁&#xff0c;所以必须进行包装&#xff0c;这也并不是我想欺骗别人&#xff0c;而是现在无论干什么工作都需要有工作经验的&#xff0c;就连找个销售都要有工作经验的&…

Vue绑定class样式与style样式

1&#xff0c;回顾HTML的class属性 答&#xff1a;任何一个HTML标签都能够具有class属性&#xff0c;这个属性可能只有一个值&#xff0c;如class"happs"&#xff0c;也有可能存在多个属性值&#xff0c;如class"happs good blue"&#xff0c;js的原生DOM针…

STM32开发踩坑——芯片写保护解除

成立这个专栏的目的是&#xff0c;记录自己嵌入式开发遇到的问题&#xff0c;与成功的解决方法&#xff0c;方便自己回顾。 具体参考链接&#xff1a;STM32的Flash写了保护怎么办&#xff1f; 解决方法&#xff1a;在STLink连接目标板的情况下打开程序烧写软件ST-Link Utilit…

低代码开发迎来设备管理新时代:智能制造加速升级

随着智能制造时代的到来&#xff0c;制造业正在经历一场前所未有的变革。在这场变革中&#xff0c;设备管理平台和低代码开发已经成为了制造业的不二利器&#xff0c;帮助企业实现数字化转型&#xff0c;提高生产效率&#xff0c;降低成本&#xff0c;增强竞争力。 一、设备管…

OptaPlanner 中的hello world项目实战

实际操作步骤&#xff1a; 1.代码下载 下载下来的文件目录 2.使用编辑器打开hello-world项目 3.进行配置 配置JDK &#xff0c;File——》Settings File——》Project Structure 配置maven 说明&#xff1a;不用下载新的maven&#xff0c;用工具自带的&#xff0c;需要将sett…

旋翼无人机常用仿真工具

四旋翼常用仿真工具 rviz&#xff1a; 简单的质点&#xff08;也可以加上动力学姿态&#xff09;&#xff0c;用urdf模型在rviz中显示无人机和飞行轨迹、地图等。配合ROS代码使用&#xff0c;轻量化适合多机。典型的比如浙大ego-planner的仿真&#xff1a; https://github.c…

screen 的介绍及用法

screen 是什么 screen 是一种类似于终端模拟器的程序&#xff0c;允许你在一个终端窗口中创建和使用多个会话。这对于同时运行多个命令或任务非常有用&#xff0c;这样你就可以轻松地在它们之间切换&#xff0c;而不必依赖于多个终端窗口。此外&#xff0c;如果在ssh会话中运行…

HDMI之带宽计算

基本概念 像素时钟 英文 A pixel clock, also known as a dot clock, is a term commonly used in computer graphics and video display systems. It refers to the frequency at which pixels are displayed on a screen or monitor. The pixel clock determines the speed…

VMware是什么?VMware虚拟机最新安装教程

VMware Workstation是一款虚拟机软件&#xff0c;允许用户将Linux、Windows等多个操作系统作为虚拟机在单台PC上运行; 用户可以在虚拟机上重现服务器、桌面和平板电脑环境&#xff0c;无需重新启动即可跨不同操作系统同时运行应用。 通过对个人笔记本(PC)硬件资源的虚拟&#…

【zmq】REQ REP 模式

[c代码(https://github.com/dongyusheng/csdn-code/tree/master/ZeroMQ)zguide 官方有c++发布订阅:可以使用信封 发布订阅可以让消息一直流动请求应答是双向的,但是必须请求 应答 请求 应答 循环。简单的请求应答 requester 作为客户端以tcp连接到 reponderrequester zmq_sen…

自动化测试用例怎么写?最全自动化测试用例设计编写指南...

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 Python自动化测试&…

算法系列题目

文章目录 一. 下一个更大元素1. 下一个更大元素 Ⅰ2. 下一个较大元素II 二. 区间问题1. 贪心策略最少射箭问题无重叠区间合并区间划分字母区间 2. 差分数组 三. 设计类题目1. LRU(最近最少使用)缓存2. LFU(最不经常使用)缓存 一. 下一个更大元素 1. 下一个更大元素 Ⅰ 添加链…

磐维数据库panweidb单节点服务器在centos7.9安装(研发环境)

一、系统环境优化 1.1 关闭SELINUX # 修改配置文件 cat /etc/selinux/config | grep -i SELINUX SELINUXdisabled# 关闭SELINUX setenforce 0 1.2 内核参数优化 vi /etc/sysctl.conf 添加# panweidb net.ipv4.tcp_max_tw_buckets 10000 net.ipv4.tcp_tw_reuse 1 net.ipv4.t…

CAS是什么?它的底层原理是什么?

目录 一、CAS概述 二、底层原理 三、总结 一、CAS概述 CAS&#xff08;Compare and Swap&#xff09;比较和交换&#xff1a;是一种并发算法&#xff0c;也是一种乐观锁&#xff0c;从JDK5开始&#xff0c;jdk提供了java.util.concurrent.*,此包下面的类在高并发场景下经常使用…

CTF密码学总结

0x01 目录 常见编码: ASCII编码Base64/32/16编码shellcode编码Quoted-printable编码XXencode编码UUencode编码URL编码Unicode编码Escape/Unescape编码HTML实体编码敲击码(Tap code)莫尔斯电码(Morse Code)编码的故事 各种文本加密 换位加密: 栅栏密码(Rail-fence Cipher)曲路密…

第13届蓝桥杯Scratch选拔赛真题集锦

第13届蓝桥杯Scratch选拔赛真题集锦 编程题 第 1 题问答题 跳舞机游戏 题目说明 编程实现 跳舞机游戏。 具体要求: 1).点击绿旗&#xff0c;舞台左上角显示得分0代表玩家分数&#xff0c;在得分右侧倒计时10代表游戏时长(10s) 2).游戏开始倒数计时&#xff0c;在舞台上随…

目标检测的通用实例提取

论文&#xff1a;General Instance Distillation for Object Detection 论文地址&#xff1a;https://arxiv.org/pdf/2103.02340.pdfhttps://arxiv.org/pdf/2103.02340.pdf 摘要 In recent years, knowledge distillation has been proved to be an effective solution for m…

vulnhub靶场之bassamctf

1.信息收集 探测存活主机&#xff0c;输入&#xff1a;netdiscover -r 192.168.239.0/24 &#xff0c;发现192.168.239.177存活。 对目标主机192.168.239.176进行端口扫描&#xff0c;发现存活22(SSH)、80端口。 在浏览器上输入&#xff1a;http://192.168.239.177&#xff…

网络协议 | 典型协议、B/S模式、C/S模式

欢迎关注博主 Mindtechnist 或加入【Linux C/C/Python社区】一起学习和分享Linux、C、C、Python、Matlab&#xff0c;机器人运动控制、多机器人协作&#xff0c;智能优化算法&#xff0c;滤波估计、多传感器信息融合&#xff0c;机器学习&#xff0c;人工智能等相关领域的知识和…