| | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.se.simu.config.PropertiesConfig; |
| | | import com.se.simu.domain.dto.ExtensionDto; |
| | | import com.se.simu.domain.dto.LayerDto; |
| | | import com.se.simu.domain.dto.ResultDto; |
| | | import com.se.simu.helper.GdalHelper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.gdal.gdal.Band; |
| | | import org.gdal.gdal.Dataset; |
| | | import org.gdal.gdal.gdal; |
| | | import org.gdal.gdalconst.gdalconst; |
| | | import org.gdal.ogr.Geometry; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | } |
| | | |
| | | private void copeTerrain(ResultDto dto, LayerDto layer) { |
| | | // |
| | | Dataset ds = null; |
| | | try { |
| | | ds = gdal.Open(dto.getTerrainFile(), gdalconst.GA_ReadOnly); |
| | | if (null == ds || 0 == ds.getRasterCount() || null == ds.GetSpatialRef()) return; |
| | | |
| | | setTerrainInfo(ds, layer); |
| | | setWaterInfo(dto, layer); |
| | | createTerrainPng(dto, ds, layer); |
| | | } finally { |
| | | if (null != ds) ds.delete(); |
| | | } |
| | | } |
| | | |
| | | private void setTerrainInfo(Dataset ds, LayerDto layer) { |
| | | Geometry minPoint = GdalHelper.getMinPoint(ds); |
| | | Geometry maxPoint = GdalHelper.getMaxPoint(ds); |
| | | double minx = getMinVal(minPoint.GetX(0), 10000000); |
| | | double miny = getMinVal(minPoint.GetY(0), 10000000); |
| | | double maxx = getMaxVal(maxPoint.GetX(0) + MAX_X_OFFSET, 10000000); |
| | | double maxy = getMaxVal(maxPoint.GetY(0), 10000000); |
| | | layer.setExtension(new ExtensionDto(minx, miny, maxx, maxy, Double.MAX_VALUE, Double.MIN_VALUE)); |
| | | |
| | | Band band = ds.GetRasterBand(1); |
| | | double[] mm = new double[2]; |
| | | band.ComputeRasterMinMax(mm, 0); |
| | | layer.getTerrain().setHeight(getMinVal(mm[0], 1000), getMaxVal(mm[1], 1000)); |
| | | } |
| | | |
| | | private static double getMinVal(double val, double radix) { |
| | | return ((long) Math.floor(val * radix)) / radix; |
| | | } |
| | | |
| | | private static double getMaxVal(double val, double radix) { |
| | | return ((long) Math.ceil(val * radix)) / radix; |
| | | } |
| | | |
| | | private void setWaterInfo(ResultDto dto, LayerDto layer) { |
| | | |
| | | } |
| | | |
| | | private void createTerrainPng(ResultDto dto, Dataset ds, LayerDto layer) { |
| | | |
| | | } |
| | | |
| | | private void copeBuilding(ResultDto dto, LayerDto layer) { |