From 1fe2e7075d517249f6019396ec5f09427f3795e5 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 22 九月 2023 15:43:15 +0800
Subject: [PATCH] 1

---
 src/main/java/com/moon/server/service/data/RasterAnalysisService.java |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/moon/server/service/data/RasterAnalysisService.java b/src/main/java/com/moon/server/service/data/RasterAnalysisService.java
index 571fbe2..1f4658a 100644
--- a/src/main/java/com/moon/server/service/data/RasterAnalysisService.java
+++ b/src/main/java/com/moon/server/service/data/RasterAnalysisService.java
@@ -143,6 +143,7 @@
      */
     private void openRaster(AnalysisResultEntity entity, String filePath, Geometry geo, int size) {
         Dataset ds = null;
+        filePath = "D:\\Moon\\data\\DOM\\test.tif";
         try {
             ds = gdal.Open(filePath);
             if (null == ds) {
@@ -234,15 +235,15 @@
         int yMinPixel = Math.max((int) Math.floor((maxY - env[3]) / pixelHeight), 1);
         int xMaxPixel = Math.min((int) Math.floor((env[1] - minX) / pixelWidth), xSize);
         int yMaxPixel = Math.min((int) Math.floor((maxY - env[2]) / pixelHeight), ySize);
-
-        int bandCount = ds.getRasterCount();
-        int width = Math.abs(xMaxPixel - xMinPixel);
-        int height = Math.abs(yMaxPixel - yMinPixel);
-        if (width < 1 || height < 1 || xMaxPixel < 1 || yMaxPixel < 1) {
+        if (xMaxPixel < 1 || yMaxPixel < 1 || xMaxPixel - xMinPixel < 1 || yMaxPixel - yMinPixel < 1) {
             setError(entity, "鏌ヨ鑼冨洿鏃犳晥");
             return;
         }
 
+        int bandCount = ds.getRasterCount();
+        int width = xMaxPixel - xMinPixel;
+        int height = yMaxPixel - yMinPixel;
+
         if (width * height > StaticData.I64 * StaticData.I64) {
             readRasterForBlocks(entity, ds, bandCount, xMinPixel, yMinPixel, width, height);
             return;

--
Gitblit v1.9.3