납품데이터셋 업로드 geojson 파일 수정
This commit is contained in:
@@ -49,7 +49,14 @@ public class DatasetBatchService {
|
|||||||
Object labelJson = map.get("label-json");
|
Object labelJson = map.get("label-json");
|
||||||
|
|
||||||
// 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();
|
String fileName = Paths.get(comparePath).getFileName().toString();
|
||||||
@@ -67,6 +74,11 @@ public class DatasetBatchService {
|
|||||||
// JSON 유효성 체크
|
// JSON 유효성 체크
|
||||||
JsonNode featuresNode = json.path("features");
|
JsonNode featuresNode = json.path("features");
|
||||||
|
|
||||||
|
if (!featuresNode.isArray()) {
|
||||||
|
log.warn("features array 아님. skip. file={}", geojsonPath);
|
||||||
|
return; // skip
|
||||||
|
}
|
||||||
|
|
||||||
if (featuresNode.isMissingNode() || !featuresNode.isArray() || featuresNode.isEmpty()) {
|
if (featuresNode.isMissingNode() || !featuresNode.isArray() || featuresNode.isEmpty()) {
|
||||||
return; // skip
|
return; // skip
|
||||||
}
|
}
|
||||||
@@ -76,35 +88,46 @@ public class DatasetBatchService {
|
|||||||
|
|
||||||
for (JsonNode feature : featuresNode) {
|
for (JsonNode feature : featuresNode) {
|
||||||
|
|
||||||
JsonNode prop = feature.path("properties");
|
try {
|
||||||
|
JsonNode prop = feature.path("properties");
|
||||||
|
|
||||||
String compareClassCd = prop.path("before").asText(null);
|
String compareClassCd = prop.path("before").asText(null);
|
||||||
String targetClassCd = prop.path("after").asText(null);
|
String targetClassCd = prop.path("after").asText(null);
|
||||||
|
|
||||||
ArrayNode arr = mapper.createArrayNode();
|
// null 방어
|
||||||
arr.add(feature);
|
if (compareClassCd == null || targetClassCd == null) {
|
||||||
|
log.warn("class 값 없음. skip. file={}", fileName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ObjectNode root = base.deepCopy();
|
ArrayNode arr = mapper.createArrayNode();
|
||||||
root.set("features", arr);
|
arr.add(feature);
|
||||||
|
|
||||||
DatasetObjRegDto objRegDto =
|
ObjectNode root = base.deepCopy();
|
||||||
DatasetObjRegDto.builder()
|
root.set("features", arr);
|
||||||
.datasetUid(datasetUid)
|
|
||||||
.compareYyyy(compareYyyy)
|
|
||||||
.compareClassCd(compareClassCd)
|
|
||||||
.targetYyyy(targetYyyy)
|
|
||||||
.targetClassCd(targetClassCd)
|
|
||||||
.comparePath(comparePath)
|
|
||||||
.targetPath(targetPath)
|
|
||||||
.labelPath(labelPath)
|
|
||||||
.mapSheetNum(mapSheetNum)
|
|
||||||
.geojson(root)
|
|
||||||
.geojsonPath(geojsonPath)
|
|
||||||
.fileName(fileName)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// 데이터 타입별 insert
|
DatasetObjRegDto objRegDto =
|
||||||
insertByType(subDir, objRegDto);
|
DatasetObjRegDto.builder()
|
||||||
|
.datasetUid(datasetUid)
|
||||||
|
.compareYyyy(compareYyyy)
|
||||||
|
.compareClassCd(compareClassCd)
|
||||||
|
.targetYyyy(targetYyyy)
|
||||||
|
.targetClassCd(targetClassCd)
|
||||||
|
.comparePath(comparePath)
|
||||||
|
.targetPath(targetPath)
|
||||||
|
.labelPath(labelPath)
|
||||||
|
.mapSheetNum(mapSheetNum)
|
||||||
|
.geojson(root)
|
||||||
|
.geojsonPath(geojsonPath)
|
||||||
|
.fileName(fileName)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 데이터 타입별 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)) {
|
if ("label-json".equals(dirName)) {
|
||||||
// json 파일이면 파싱
|
// json 파일이면 파싱
|
||||||
data.put("label-json", readJson(path));
|
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());
|
data.put("geojson_path", path.toAbsolutePath().toString());
|
||||||
} else {
|
} else {
|
||||||
data.put(dirName, path.toAbsolutePath().toString());
|
data.put(dirName, path.toAbsolutePath().toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user