포맷팅 적용

This commit is contained in:
2025-12-09 10:37:25 +09:00
parent f96fa3b8c7
commit 0f150f6e9e
11 changed files with 47 additions and 98 deletions

View File

@@ -13,8 +13,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.gce.geotiff.GeoTiffReader;
@@ -47,9 +45,8 @@ public class FIleChecker {
return true;
}
public static boolean verifyFileIntegrity(Path path, String expectedHash)
throws IOException, NoSuchAlgorithmException {
throws IOException, NoSuchAlgorithmException {
// 1. 알고리즘 선택 (SHA-256 권장, MD5는 보안상 비추천)
MessageDigest digest = MessageDigest.getInstance("SHA-256");
@@ -72,7 +69,6 @@ public class FIleChecker {
return actualHash.equalsIgnoreCase(expectedHash);
}
public static boolean checkTfw(String filePath) {
File file = new File(filePath);
@@ -90,13 +86,13 @@ public class FIleChecker {
lines.add(Double.parseDouble(line.trim()));
}
}
}catch (IOException ignored) {
} catch (IOException ignored) {
return false;
}
// 2. 6줄이 맞는지 확인
if (lines.size() < 6) {
//System.out.println("유효하지 않은 TFW 파일입니다. (데이터 부족)");
// System.out.println("유효하지 않은 TFW 파일입니다. (데이터 부족)");
return false;
}
@@ -123,9 +119,9 @@ public class FIleChecker {
if (coverage == null) return false;
// 3. GIS 필수 정보(좌표계)가 있는지 확인
//if (coverage.getCoordinateReferenceSystem() == null) {
// GeoTIFF가 아니라 일반 TIFF일 수도 있음(이미지는 정상이지만, 좌표계(CRS) 정보가 없습니다.)
//}
// if (coverage.getCoordinateReferenceSystem() == null) {
// GeoTIFF가 아니라 일반 TIFF일 수도 있음(이미지는 정상이지만, 좌표계(CRS) 정보가 없습니다.)
// }
return true;
@@ -149,59 +145,56 @@ public class FIleChecker {
String resStr = "";
boolean hasDriver = false;
// 리눅스/맥용
//ProcessBuilder pb = new ProcessBuilder("sh", "-c", "gdalinfo "+filePath+" | grep -i 'Geo'");
// 리눅스/맥용
// ProcessBuilder pb = new ProcessBuilder("sh", "-c", "gdalinfo "+filePath+" | grep -i 'Geo'");
List<String> command = new ArrayList<>();
List<String> command = new ArrayList<>();
//윈도우용
// 윈도우용
/*
command.add("cmd.exe"); // 윈도우 명령 프롬프트 실행
command.add("/c"); // 명령어를 수행하고 종료한다는 옵션
command.add("gdalinfo");
command.add(filePath);
command.add("|");
command.add("findstr");
command.add("/i");
command.add("Geo");
*/
command.add("cmd.exe"); // 윈도우 명령 프롬프트 실행
command.add("/c"); // 명령어를 수행하고 종료한다는 옵션
command.add("gdalinfo");
command.add(filePath);
command.add("|");
command.add("findstr");
command.add("/i");
command.add("Geo");
*/
command.add("sh"); // 리눅스,맥 명령 프롬프트 실행
command.add("-c"); // 명령어를 수행하고 종료한다는 옵션
command.add("gdalinfo");
command.add(filePath);
command.add("|");
command.add("grep");
command.add("-i");
command.add("Geo");
command.add("sh"); // 리눅스,맥 명령 프롬프트 실행
command.add("-c"); // 명령어를 수행하고 종료한다는 옵션
command.add("gdalinfo");
command.add(filePath);
command.add("|");
command.add("grep");
command.add("-i");
command.add("Geo");
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.redirectErrorStream(true);
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.redirectErrorStream(true);
try {
Process process = processBuilder.start();
try {
Process process = processBuilder.start();
// 인코딩은 윈도우 한글 환경에 맞게 MS949로 지정
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
// 인코딩은 윈도우 한글 환경에 맞게 MS949로 지정
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
//System.out.println(line);
if( line.contains("Driver: GTiff/GeoTIFF")) {
hasDriver = true;
break;
}
String line;
while ((line = reader.readLine()) != null) {
// System.out.println(line);
if (line.contains("Driver: GTiff/GeoTIFF")) {
hasDriver = true;
break;
}
int exitCode = process.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
int exitCode = process.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
return hasDriver;
}
}