납품데이터셋 업로드 geojson 파일 수정
This commit is contained in:
@@ -49,7 +49,14 @@ public class DatasetBatchService {
|
||||
Object labelJson = map.get("label-json");
|
||||
|
||||
// JSON 파싱
|
||||
JsonNode json = parseJson(labelJson);
|
||||
JsonNode json;
|
||||
try {
|
||||
json = parseJson(labelJson);
|
||||
} catch (Exception e) {
|
||||
// 실패하면 skip, 다음 진행
|
||||
log.error("GeoJSON 파싱 실패. skip. file={}", geojsonPath, e);
|
||||
return;
|
||||
}
|
||||
|
||||
// 파일명 파싱
|
||||
String fileName = Paths.get(comparePath).getFileName().toString();
|
||||
@@ -67,6 +74,11 @@ public class DatasetBatchService {
|
||||
// JSON 유효성 체크
|
||||
JsonNode featuresNode = json.path("features");
|
||||
|
||||
if (!featuresNode.isArray()) {
|
||||
log.warn("features array 아님. skip. file={}", geojsonPath);
|
||||
return; // skip
|
||||
}
|
||||
|
||||
if (featuresNode.isMissingNode() || !featuresNode.isArray() || featuresNode.isEmpty()) {
|
||||
return; // skip
|
||||
}
|
||||
@@ -76,11 +88,18 @@ public class DatasetBatchService {
|
||||
|
||||
for (JsonNode feature : featuresNode) {
|
||||
|
||||
try {
|
||||
JsonNode prop = feature.path("properties");
|
||||
|
||||
String compareClassCd = prop.path("before").asText(null);
|
||||
String targetClassCd = prop.path("after").asText(null);
|
||||
|
||||
// null 방어
|
||||
if (compareClassCd == null || targetClassCd == null) {
|
||||
log.warn("class 값 없음. skip. file={}", fileName);
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayNode arr = mapper.createArrayNode();
|
||||
arr.add(feature);
|
||||
|
||||
@@ -105,6 +124,10 @@ public class DatasetBatchService {
|
||||
|
||||
// 데이터 타입별 insert
|
||||
insertByType(subDir, objRegDto);
|
||||
} catch (Exception e) {
|
||||
// 개별 feature skip
|
||||
log.error("feature 처리 실패. skip. file={}", fileName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +368,12 @@ public class DatasetService {
|
||||
// 폴더별 처리
|
||||
if ("label-json".equals(dirName)) {
|
||||
// json 파일이면 파싱
|
||||
try {
|
||||
data.put("label-json", readJson(path));
|
||||
} catch (Exception e) {
|
||||
log.error("파일 JSON 읽기 실패. skip. file={}", path, e);
|
||||
return; // skip
|
||||
}
|
||||
data.put("geojson_path", path.toAbsolutePath().toString());
|
||||
} else {
|
||||
data.put(dirName, path.toAbsolutePath().toString());
|
||||
|
||||
Reference in New Issue
Block a user