13693261870
2024-10-31 f7c642eed8ae076553f95a1f0ac5fd2e7c31b6a1
src/main/java/com/se/simu/service/WaterService.java
@@ -152,11 +152,10 @@
                return null;
            }
            double[] values = new double[1];
            ds.GetRasterBand(1).ReadRaster(XY[0], XY[1], 1, 1, values);
            double val = values[0];
            double[] vals = new double[1];
            ds.GetRasterBand(1).ReadRaster(XY[0], XY[1], 1, 1, vals);
            return isValid(val) ? val : null;
            return isValid(vals[0]) ? vals[0] : null;
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return null;
@@ -184,8 +183,6 @@
     * @return 像素坐标
     */
    public int[] coordinates2ColRow(double[] gt, double x, double y) {
        int[] ints = new int[2];
        // 向下取整,如果向上取整会导致计算结果偏大,从而在后面读取到邻近像元的数据
        //Double col = Math.floor(((y - gt[3]) * gt[1] - (x - gt[0]) * gt[4]) / (gt[5] * gt[1] - gt[2] * gt[4]));
        Double col = Math.floor((y * gt[1] - x * gt[4] + gt[0] * gt[4] - gt[3] * gt[1]) / (gt[5] * gt[1] - gt[2] * gt[4]));