用geo-tools绘制河段流量生成图片
前言
1.需要绘制的河段json
2.接口查出的数据
一、流程
1.读河道的json
代码如下:
public void DrawImage(HsfxRivlFourResult waterCondition, String endtime, String requestUrl, String pngFolder) throws IOException {
//读json文件
String filePath = "F:/2020/黑龙江省/jsons/HeiLongJiang/HLJRIVL.json";
String jsondata = httpRequest(filePath, "GET");
try {
DataAssembly(jsondata, waterCondition.HsfxRivlFourResult, endtime, requestUrl, "0", pngFolder);
} catch (Exception e) {
e.printStackTrace();
}
}
2.将数据拼接成新的geojson
代码:
public void DataAssembly(String jsondata, List<HsfxRivlFourVO> DataResult, String endtime, String requestUrl, String type, String pngFolder) throws IOException {
JSONObject jobj = JSON.parseObject(jsondata);
com.alibaba.fastjson.JSONArray movies = jobj.getJSONArray("features");//构建JSONArray数组
List polyLines = new ArrayList<>();
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
for (int i = 0; i < movies.size(); i++) {
JSONObject Jsonkey = (JSONObject) movies.get(i);
JSONObject Jsonproperties = (JSONObject) Jsonkey.get("properties");
String JsonRVCD = (String) Jsonproperties.get("RVCD"