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:
@@ -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,30 +460,24 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// 6. Geometry를 GeoJSON으로 변환
|
// 6. Geometry를 GeoJSON으로 변환
|
||||||
JsonNode geomJson = null;
|
InferenceDataGeometry inferData =
|
||||||
if (mapSheetAnalDataInferenceGeomEntityEntity.getGeom() != null) {
|
|
||||||
try {
|
|
||||||
String geomString =
|
|
||||||
queryFactory
|
queryFactory
|
||||||
.select(
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
InferenceDataGeometry.class,
|
||||||
|
Expressions.stringTemplate("{0}", "Feature"),
|
||||||
Expressions.stringTemplate(
|
Expressions.stringTemplate(
|
||||||
"ST_AsGeoJSON({0})", mapSheetAnalDataInferenceGeomEntity.geom))
|
"ST_AsGeoJSON({0})", mapSheetAnalDataInferenceGeomEntity.geom),
|
||||||
|
Projections.constructor(
|
||||||
|
InferenceProperties.class,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.classBeforeCd,
|
||||||
|
mapSheetAnalDataInferenceGeomEntity.classAfterCd)))
|
||||||
.from(mapSheetAnalDataInferenceGeomEntity)
|
.from(mapSheetAnalDataInferenceGeomEntity)
|
||||||
.where(
|
.where(
|
||||||
mapSheetAnalDataInferenceGeomEntity.geoUid.eq(
|
mapSheetAnalDataInferenceGeomEntity.geoUid.eq(
|
||||||
mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid()))
|
mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid()))
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
|
|
||||||
if (geomString != null) {
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
geomJson = mapper.readTree(geomString);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("GeoJSON parsing error: " + e.getMessage());
|
|
||||||
// JSON 파싱 실패 시 null 유지
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 도엽 bbox json으로 가져오기
|
// 도엽 bbox json으로 가져오기
|
||||||
JsonNode mapBbox = null;
|
JsonNode mapBbox = null;
|
||||||
if (mapSheetEntity.getGeom() != null) {
|
if (mapSheetEntity.getGeom() != null) {
|
||||||
@@ -500,37 +498,33 @@ public class TrainingDataLabelRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 7. 라벨링 저장한 Geometry를 GeoJSON으로 변환
|
// 7. 라벨링 저장한 Geometry를 GeoJSON으로 변환
|
||||||
JsonNode learnJson = null;
|
LearnDataGeometry learnData =
|
||||||
try {
|
|
||||||
String learnString =
|
|
||||||
queryFactory
|
queryFactory
|
||||||
.select(
|
.select(
|
||||||
|
Projections.constructor(
|
||||||
|
LearnDataGeometry.class,
|
||||||
|
Expressions.stringTemplate("{0}", "Feature"),
|
||||||
Expressions.stringTemplate(
|
Expressions.stringTemplate(
|
||||||
"ST_AsGeoJSON({0})", mapSheetLearnDataGeomEntity.geom))
|
"ST_AsGeoJSON({0})", mapSheetLearnDataGeomEntity.geom),
|
||||||
|
Projections.constructor(
|
||||||
|
LearnProperties.class,
|
||||||
|
mapSheetLearnDataGeomEntity.classBeforeCd,
|
||||||
|
mapSheetLearnDataGeomEntity.classAfterCd)))
|
||||||
.from(mapSheetLearnDataGeomEntity)
|
.from(mapSheetLearnDataGeomEntity)
|
||||||
.where(
|
.where(
|
||||||
mapSheetLearnDataGeomEntity.geoUid.eq(
|
mapSheetLearnDataGeomEntity.geoUid.eq(
|
||||||
mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid()))
|
mapSheetAnalDataInferenceGeomEntityEntity.getGeoUid()))
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
|
|
||||||
if (learnString != null) {
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
learnJson = mapper.readTree(learnString);
|
|
||||||
}
|
|
||||||
} 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) {
|
||||||
|
|||||||
@@ -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 = "변화탐지정보")
|
||||||
|
|||||||
Reference in New Issue
Block a user