| | |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.se.simu.config.PropertiesConfig; |
| | | import com.se.simu.domain.po.DataPo; |
| | | import com.se.simu.domain.po.PondingPo; |
| | | import com.se.simu.domain.po.SimuPo; |
| | | import com.se.simu.domain.vo.*; |
| | | import com.se.simu.helper.GdalHelper; |
| | |
| | | } |
| | | |
| | | public Double getWaterArea(SimuPo simu, double x, double y, Long timestamp) { |
| | | List<PondingPo> list = readWaterJson(simu.getServiceName(), timestamp); |
| | | if (CollectionUtils.isEmpty(list)) return null; |
| | | |
| | | //DataPo data = JSONUtil.toBean(simu.getData(), DataPo.class); |
| | | //SpatialReference sr = GdalHelper.createSpatialReference(data.getEpsg()); |
| | | |
| | | Geometry p = new Geometry(ogr.wkbPoint); |
| | | p.AddPoint_2D(x, y); |
| | | p.AssignSpatialReference(GdalHelper.SR4326); |
| | | |
| | | for (PondingPo po : list) { |
| | | if (StringHelper.isEmpty(po.getPolygon())) continue; |
| | | |
| | | Geometry polygon = Geometry.CreateFromWkt(po.getPolygon()); |
| | | polygon.AssignSpatialReference(GdalHelper.SR4326); |
| | | if (polygon.Contains(p)) { |
| | | return po.getArea(); |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | private List<PondingPo> readWaterJson(String serviceName, Long timestamp) { |
| | | String filePath = config.getOutPath() + File.separator + serviceName + File.separator + "waters" + File.separator + timestamp + File.separator + "water.json"; |
| | | String json = getText(filePath); |
| | | if (StringHelper.isEmpty(json)) { |
| | | return null; |
| | | } |
| | | |
| | | return JSONUtil.toList(json, PondingPo.class); |
| | | } |
| | | |
| | | public Double getWaterArea2(SimuPo simu, double x, double y, Long timestamp) { |
| | | String filePath = config.getOutPath() + File.separator + simu.getServiceName() + File.separator + "waters" |
| | | + File.separator + timestamp + File.separator + "water.geojson"; |
| | | if (!FileUtil.exist(filePath)) return null; |