Merge pull request '라벨링툴 상세 geom 리턴 형식 수정' (#195) from feat/infer_dev_260107 into develop

Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/195
This commit is contained in:
2026-01-12 17:30:29 +09:00
2 changed files with 127 additions and 47 deletions

View File

@@ -14,9 +14,13 @@ import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.ChangeDetect
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.ClassificationInfo; import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.ClassificationInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.DetailRes; import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.DetailRes;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.GeoFeatureRequest.Properties; import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.GeoFeatureRequest.Properties;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceDataGeometry;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InferenceDataGeometry.InferenceProperties;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InspectionResultInfo; import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.InspectionResultInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingGeometryInfo; import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingGeometryInfo;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto; import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LabelingListDto;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LearnDataGeometry;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.LearnDataGeometry.LearnProperties;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.SummaryRes; import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.SummaryRes;
import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.searchReq; import com.kamco.cd.kamcoback.trainingdata.dto.TrainingDataLabelDto.searchReq;
import com.querydsl.core.types.Projections; import com.querydsl.core.types.Projections;
@@ -456,29 +460,23 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
.build(); .build();
// 6. Geometry를 GeoJSON으로 변환 // 6. Geometry를 GeoJSON으로 변환
JsonNode geomJson = null; InferenceDataGeometry inferData =
if (mapSheetAnalDataInferenceGeomEntityEntity.getGeom() != null) { queryFactory
try { .select(
String geomString = Projections.constructor(
queryFactory InferenceDataGeometry.class,
.select( Expressions.stringTemplate("{0}", "Feature"),
Expressions.stringTemplate( Expressions.stringTemplate(
"ST_AsGeoJSON({0})", mapSheetAnalDataInferenceGeomEntity.geom)) "ST_AsGeoJSON({0})", mapSheetAnalDataInferenceGeomEntity.geom),
.from(mapSheetAnalDataInferenceGeomEntity) Projections.constructor(
.where( InferenceProperties.class,
mapSheetAnalDataInferenceGeomEntity.geoUid.eq( mapSheetAnalDataInferenceGeomEntity.classBeforeCd,
mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid())) mapSheetAnalDataInferenceGeomEntity.classAfterCd)))
.fetchOne(); .from(mapSheetAnalDataInferenceGeomEntity)
.where(
if (geomString != null) { mapSheetAnalDataInferenceGeomEntity.geoUid.eq(
ObjectMapper mapper = new ObjectMapper(); mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid()))
geomJson = mapper.readTree(geomString); .fetchOne();
}
} catch (Exception e) {
System.err.println("GeoJSON parsing error: " + e.getMessage());
// JSON 파싱 실패 시 null 유지
}
}
// 도엽 bbox json으로 가져오기 // 도엽 bbox json으로 가져오기
JsonNode mapBbox = null; JsonNode mapBbox = null;
@@ -500,37 +498,33 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
} }
// 7. 라벨링 저장한 Geometry를 GeoJSON으로 변환 // 7. 라벨링 저장한 Geometry를 GeoJSON으로 변환
JsonNode learnJson = null; LearnDataGeometry learnData =
try { queryFactory
String learnString = .select(
queryFactory Projections.constructor(
.select( LearnDataGeometry.class,
Expressions.stringTemplate( Expressions.stringTemplate("{0}", "Feature"),
"ST_AsGeoJSON({0})", mapSheetLearnDataGeomEntity.geom)) Expressions.stringTemplate(
.from(mapSheetLearnDataGeomEntity) "ST_AsGeoJSON({0})", mapSheetLearnDataGeomEntity.geom),
.where( Projections.constructor(
mapSheetLearnDataGeomEntity.geoUid.eq( LearnProperties.class,
mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid())) mapSheetLearnDataGeomEntity.classBeforeCd,
.fetchOne(); mapSheetLearnDataGeomEntity.classAfterCd)))
.from(mapSheetLearnDataGeomEntity)
if (learnString != null) { .where(
ObjectMapper mapper = new ObjectMapper(); mapSheetLearnDataGeomEntity.geoUid.eq(
learnJson = mapper.readTree(learnString); mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid()))
} .fetchOne();
} catch (Exception e) {
System.err.println("learnJson parsing error: " + e.getMessage());
// JSON 파싱 실패 시 null 유지
}
return DetailRes.builder() return DetailRes.builder()
.assignmentUid(assignmentUid) .assignmentUid(assignmentUid)
.changeDetectionInfo(changeDetectionInfo) .changeDetectionInfo(changeDetectionInfo)
.inspectionResultInfo(inspectionResultInfo) .inspectionResultInfo(inspectionResultInfo)
.geom(geomJson) .geom(inferData)
.beforeCogUrl(beforeCogUrl) .beforeCogUrl(beforeCogUrl)
.afterCogUrl(afterCogUrl) .afterCogUrl(afterCogUrl)
.mapBox(mapBbox) .mapBox(mapBbox)
.learnGeometry(learnJson) .learnGeometry(learnData)
.build(); .build();
} catch (Exception e) { } catch (Exception e) {

View File

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.kamco.cd.kamcoback.common.utils.geometry.GeometryDeserializer; import com.kamco.cd.kamcoback.common.utils.geometry.GeometryDeserializer;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.util.UUID; import java.util.UUID;
@@ -159,6 +160,91 @@ public class TrainingDataLabelDto {
} }
} }
@Schema(name = "InferenceDataGeometry", description = "InferenceDataGeometry")
@Getter
@Setter
@NoArgsConstructor
public static class InferenceDataGeometry {
private String type;
@JsonIgnore private String learnGeomString;
private JsonNode geometry;
private InferenceProperties properties;
public InferenceDataGeometry(
String type, String learnGeomString, InferenceProperties properties) {
this.type = type;
this.properties = properties;
ObjectMapper mapper = new ObjectMapper();
JsonNode inferenceJson;
try {
inferenceJson = mapper.readTree(learnGeomString);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
this.geometry = inferenceJson;
if (inferenceJson.isObject()) {
((ObjectNode) inferenceJson).remove("crs");
}
}
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class InferenceProperties {
@Schema(description = "beforeClass", example = "WASTE")
private String beforeClass;
@Schema(description = "afterClass", example = "LAND")
private String afterClass;
}
}
@Schema(name = "LearnDataGeometry", description = "LearnDataGeometry")
@Getter
@Setter
@NoArgsConstructor
public static class LearnDataGeometry {
private String type;
@JsonIgnore private String learnGeomString;
private JsonNode geometry;
private LearnProperties properties;
public LearnDataGeometry(String type, String learnGeomString, LearnProperties properties) {
this.type = type;
this.properties = properties;
ObjectMapper mapper = new ObjectMapper();
JsonNode learnJson;
try {
learnJson = mapper.readTree(learnGeomString);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
this.geometry = learnJson;
if (learnJson.isObject()) {
((ObjectNode) learnJson).remove("crs");
}
}
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public static class LearnProperties {
@Schema(description = "beforeClass", example = "WASTE")
private String beforeClass;
@Schema(description = "afterClass", example = "LAND")
private String afterClass;
}
}
@Schema(name = "searchReq", description = "검색 요청") @Schema(name = "searchReq", description = "검색 요청")
@Getter @Getter
@Setter @Setter
@@ -201,7 +287,7 @@ public class TrainingDataLabelDto {
private InspectionResultInfo inspectionResultInfo; private InspectionResultInfo inspectionResultInfo;
@Schema(description = "Geometry (GeoJSON)") @Schema(description = "Geometry (GeoJSON)")
private JsonNode geom; private InferenceDataGeometry geom;
@Schema(description = "변화 전 COG 이미지 URL") @Schema(description = "변화 전 COG 이미지 URL")
private String beforeCogUrl; private String beforeCogUrl;
@@ -213,7 +299,7 @@ public class TrainingDataLabelDto {
private JsonNode mapBox; private JsonNode mapBox;
@Schema(description = "라벨링 툴에서 그린 폴리곤") @Schema(description = "라벨링 툴에서 그린 폴리곤")
private JsonNode learnGeometry; private LearnDataGeometry learnGeometry;
} }
@Schema(name = "ChangeDetectionInfo", description = "변화탐지정보") @Schema(name = "ChangeDetectionInfo", description = "변화탐지정보")