src/main/java/com/se/simu/domain/po/PondingPo.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/se/simu/helper/GdalHelper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/se/simu/service/ResultService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/se/simu/domain/po/PondingPo.java
@@ -1,9 +1,11 @@ package com.se.simu.domain.po; import com.se.simu.domain.dto.PointDto; import com.se.simu.helper.GdalHelper; import io.swagger.annotations.ApiModelProperty; import org.gdal.ogr.Geometry; import org.gdal.ogr.ogr; import org.gdal.osr.osr; @SuppressWarnings("ALL") public class PondingPo { @@ -16,6 +18,9 @@ @ApiModelProperty("积水深度") private Double depth; @ApiModelProperty("面积") private Double area; public PondingPo() { } @@ -24,9 +29,15 @@ point.AddPoint_2D(dto.getX(), dto.getY()); point.AssignSpatialReference(polygon.GetSpatialReference()); //GdalHelper.toWgs84(polygon.GetSpatialReference(), polygon); //GdalHelper.toWgs84(polygon.GetSpatialReference(), point); polygon.TransformTo(GdalHelper.SR4326); point.TransformTo(GdalHelper.SR4326); this.polygon = polygon.ExportToWkt(); this.point = point.ExportToWkt(); this.depth = dto.getVal(); this.area = polygon.Area(); } public PondingPo(String polygon, String point, Double depth) { @@ -58,4 +69,12 @@ public void setDepth(Double depth) { this.depth = depth; } public Double getArea() { return area; } public void setArea(Double area) { this.area = area; } } src/main/java/com/se/simu/helper/GdalHelper.java
@@ -128,8 +128,7 @@ } } public static Geometry getMinPoint(Dataset ds) { public static Geometry getMinPoint(Dataset ds) { double[] transform = new double[6]; ds.GetGeoTransform(transform); @@ -142,8 +141,7 @@ return Transform(ds, point); } public static Geometry getMaxPoint(Dataset ds) { public static Geometry getMaxPoint(Dataset ds) { double[] transform = new double[6]; ds.GetGeoTransform(transform); @@ -156,11 +154,9 @@ return Transform(ds, point); } public static Geometry Transform(Dataset ds, Geometry point) { public static Geometry Transform(Dataset ds, Geometry point) { point.AssignSpatialReference(ds.GetSpatialRef()); if (ds.GetSpatialRef().IsGeographic() > 0) { if (ds.GetSpatialRef().IsGeographic() > 0) { return point; } @@ -189,6 +185,15 @@ return point; } public static int toWgs84(SpatialReference sr, Geometry g) { CoordinateTransformation ct = new CoordinateTransformation(sr, GdalHelper.SR4326); if (sr.IsProjected() != 1) { sr.SetAxisMappingStrategy(osr.OAMS_TRADITIONAL_GIS_ORDER); } return g.TransformTo(GdalHelper.SR4326); } public static double[] fromWgs84(SpatialReference sr, double x, double y) { CoordinateTransformation ct = new CoordinateTransformation(GdalHelper.SR4326, sr); if (sr.IsProjected() != 1) { src/main/java/com/se/simu/service/ResultService.java
@@ -496,7 +496,8 @@ if (CollectionUtils.isEmpty(list)) return; try { writeJson(dto.getOutPath() + File.separator + "water.json", JSON.toJSONString(list)); filePath = dto.getOutPath() + File.separator + "waters" + File.separator + ticks + File.separator + "water.json"; writeJson(filePath, JSON.toJSONString(list)); } catch (Exception ex) { log.error(ex.getMessage(), ex); }