Merge pull request 'feat/demo-20251205' (#30) from feat/demo-20251205 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/30
This commit is contained in:
@@ -84,7 +84,7 @@ public class ChangeDetectionApiController {
|
||||
|
||||
@Operation(summary = "변화탐지 결과 Point", description = "변화탐지 결과 Point")
|
||||
@GetMapping("/point")
|
||||
public ApiResponseDto<List<ChangeDetectionDto.PointFeature>> getChangeDetectionPointList(
|
||||
public ApiResponseDto<ChangeDetectionDto.PointFeatureList> getChangeDetectionPointList(
|
||||
@Parameter(description = "년도목록 id", example = "1") @RequestParam Long analUid,
|
||||
@Parameter(description = "도엽번호", example = "34602060") @RequestParam String mapSheetNum) {
|
||||
return ApiResponseDto.ok(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.changedetection.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -87,7 +88,16 @@ public class ChangeDetectionDto {
|
||||
public static class PolygonFeatureList {
|
||||
private String type;
|
||||
private List<PolygonFeature> features; // Point 값
|
||||
private String classCd; // after 분류
|
||||
}
|
||||
|
||||
@Schema(name = "PointFeatureList", description = "Geometry 리턴 객체")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class PointFeatureList {
|
||||
private String type;
|
||||
private List<PointFeature> features; // Point 값
|
||||
}
|
||||
|
||||
@Schema(name = "PolygonFeature", description = "Geometry 리턴 객체")
|
||||
@@ -97,8 +107,26 @@ public class ChangeDetectionDto {
|
||||
@AllArgsConstructor
|
||||
public static class PolygonFeature {
|
||||
private String type;
|
||||
private Geometry geometry; // after 분류
|
||||
private PolygonProperties properties; // Point 값
|
||||
private JsonNode geometry; // after 분류
|
||||
private PolygonProperties properties; //
|
||||
}
|
||||
|
||||
@Schema(name = "PolygonFeature", description = "Geometry 리턴 객체")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class PolygonQueryData {
|
||||
private String type;
|
||||
private String geometry; // geoJson String
|
||||
private Long geoUid;
|
||||
private Double area; // 면적
|
||||
private Integer beforeYear; // 기준년도
|
||||
private Double beforeConfidence; // 기준 신뢰도(확률)
|
||||
private String beforeClass; // 기준 분류
|
||||
private Integer afterYear; // 비교년도
|
||||
private Double afterConfidence; // 비교 신뢰도(확률)
|
||||
private String afterClass;
|
||||
}
|
||||
|
||||
@Schema(name = "PointFeature", description = "Geometry 리턴 객체")
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ChangeDetectionService {
|
||||
return changeDetectionCoreService.getChangeDetectionPolygonList(analUid, mapSheetNum);
|
||||
}
|
||||
|
||||
public List<ChangeDetectionDto.PointFeature> getChangeDetectionPointList(
|
||||
public ChangeDetectionDto.PointFeatureList getChangeDetectionPointList(
|
||||
Long analUid, String mapSheetNum) {
|
||||
return changeDetectionCoreService.getChangeDetectionPointList(analUid, mapSheetNum);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ChangeDetectionCoreService {
|
||||
return changeDetectionRepository.getChangeDetectionPolygonList(analUid, mapSheetNum);
|
||||
}
|
||||
|
||||
public List<ChangeDetectionDto.PointFeature> getChangeDetectionPointList(
|
||||
public ChangeDetectionDto.PointFeatureList getChangeDetectionPointList(
|
||||
Long analUid, String mapSheetNum) {
|
||||
return changeDetectionRepository.getChangeDetectionPointList(analUid, mapSheetNum);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ public interface ChangeDetectionRepositoryCustom {
|
||||
ChangeDetectionDto.PolygonFeatureList getChangeDetectionPolygonList(
|
||||
Long analUid, String mapSheetNum);
|
||||
|
||||
List<ChangeDetectionDto.PointFeature> getChangeDetectionPointList(
|
||||
Long analUid, String mapSheetNum);
|
||||
ChangeDetectionDto.PointFeatureList getChangeDetectionPointList(Long analUid, String mapSheetNum);
|
||||
|
||||
List<ChangeDetectionDto.MapSheetList> getChangeDetectionMapSheetList(Long analUid);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataGeomEntity
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalEntity.mapSheetAnalEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalSttcEntity.mapSheetAnalSttcEntity;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity;
|
||||
import com.querydsl.core.types.Projections;
|
||||
@@ -16,6 +19,7 @@ import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.core.types.dsl.StringExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
|
||||
public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
@@ -107,22 +111,80 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
public ChangeDetectionDto.PolygonFeatureList getChangeDetectionPolygonList(
|
||||
Long analUid, String mapSheetNum) {
|
||||
|
||||
List<ChangeDetectionDto.PolygonFeature> result =
|
||||
List<ChangeDetectionDto.PolygonQueryData> list =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ChangeDetectionDto.PolygonFeature.class,
|
||||
ChangeDetectionDto.PolygonQueryData.class,
|
||||
Expressions.stringTemplate("{0}", "Feature"),
|
||||
mapSheetAnalDataGeomEntity.geom, // polygon
|
||||
Expressions.stringTemplate(
|
||||
"ST_AsGeoJSON({0})", mapSheetAnalDataGeomEntity.geom),
|
||||
mapSheetAnalDataGeomEntity.id,
|
||||
mapSheetAnalDataGeomEntity.area,
|
||||
mapSheetAnalDataGeomEntity.compareYyyy,
|
||||
mapSheetAnalDataGeomEntity.classBeforeProb,
|
||||
mapSheetAnalDataGeomEntity.classBeforeCd.toUpperCase(),
|
||||
mapSheetAnalDataGeomEntity.targetYyyy,
|
||||
mapSheetAnalDataGeomEntity.classAfterProb,
|
||||
mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase()))
|
||||
.from(mapSheetAnalDataGeomEntity)
|
||||
.innerJoin(mapSheetAnalDataEntity)
|
||||
.on(mapSheetAnalDataGeomEntity.dataUid.eq(mapSheetAnalDataEntity.id))
|
||||
.innerJoin(mapSheetAnalEntity)
|
||||
.on(mapSheetAnalEntity.id.eq(mapSheetAnalDataEntity.analUid))
|
||||
.where(
|
||||
mapSheetAnalEntity.id.eq(analUid),
|
||||
mapSheetAnalDataGeomEntity.mapSheetNum.eq(Long.valueOf(mapSheetNum)))
|
||||
.fetch();
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
List<ChangeDetectionDto.PolygonFeature> result =
|
||||
list.stream()
|
||||
.map(
|
||||
data -> {
|
||||
String geoJson = data.getGeometry();
|
||||
JsonNode jsonNode;
|
||||
try {
|
||||
jsonNode = mapper.readTree(geoJson);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
ChangeDetectionDto.PolygonProperties properties =
|
||||
new ChangeDetectionDto.PolygonProperties(
|
||||
data.getGeoUid(),
|
||||
data.getArea(),
|
||||
data.getBeforeYear(),
|
||||
data.getBeforeConfidence(),
|
||||
data.getBeforeClass(),
|
||||
data.getAfterYear(),
|
||||
data.getAfterConfidence(),
|
||||
data.getAfterClass());
|
||||
|
||||
return new ChangeDetectionDto.PolygonFeature(
|
||||
data.getType(), jsonNode, properties);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ChangeDetectionDto.PolygonFeatureList polygonList = new ChangeDetectionDto.PolygonFeatureList();
|
||||
polygonList.setType("FeatureCollection");
|
||||
polygonList.setFeatures(result);
|
||||
return polygonList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeDetectionDto.PointFeatureList getChangeDetectionPointList(
|
||||
Long analUid, String mapSheetNum) {
|
||||
List<ChangeDetectionDto.PointFeature> list =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ChangeDetectionDto.PointFeature.class,
|
||||
Expressions.stringTemplate("{0}", "Feature"),
|
||||
mapSheetAnalDataGeomEntity.geomCenter, // point
|
||||
Projections.constructor(
|
||||
ChangeDetectionDto.PolygonProperties.class,
|
||||
ChangeDetectionDto.PointProperties.class,
|
||||
mapSheetAnalDataGeomEntity.id,
|
||||
mapSheetAnalDataGeomEntity.area,
|
||||
mapSheetAnalDataGeomEntity.compareYyyy,
|
||||
mapSheetAnalDataGeomEntity.classBeforeProb,
|
||||
mapSheetAnalDataGeomEntity.classBeforeCd.toUpperCase(),
|
||||
mapSheetAnalDataGeomEntity.targetYyyy,
|
||||
mapSheetAnalDataGeomEntity.classAfterProb,
|
||||
mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())))
|
||||
.from(mapSheetAnalDataGeomEntity)
|
||||
.innerJoin(mapSheetAnalDataEntity)
|
||||
@@ -134,137 +196,7 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
mapSheetAnalDataGeomEntity.mapSheetNum.eq(Long.valueOf(mapSheetNum)))
|
||||
.fetch();
|
||||
|
||||
// List<Tuple> list =
|
||||
// queryFactory
|
||||
// .select(
|
||||
// Expressions.stringTemplate(
|
||||
// "ST_AsGeoJSON(ST_Transform({0}, 4326))", mapSheetAnalDataGeomEntity.geom),
|
||||
// mapSheetAnalDataGeomEntity.id,
|
||||
// mapSheetAnalDataGeomEntity.area,
|
||||
// mapSheetAnalDataGeomEntity.compareYyyy,
|
||||
// mapSheetAnalDataGeomEntity.classBeforeProb,
|
||||
// mapSheetAnalDataGeomEntity.classBeforeCd.toUpperCase(),
|
||||
// mapSheetAnalDataGeomEntity.targetYyyy,
|
||||
// mapSheetAnalDataGeomEntity.classAfterProb,
|
||||
// mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())
|
||||
// .from(QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity)
|
||||
// .where(
|
||||
// QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity.dataUid.in(
|
||||
// JPAExpressions.select(QMapSheetAnalDataEntity.mapSheetAnalDataEntity.id)
|
||||
// .from(QMapSheetAnalDataEntity.mapSheetAnalDataEntity)
|
||||
//
|
||||
// .where(QMapSheetAnalDataEntity.mapSheetAnalDataEntity.analUid.eq(analUid))),
|
||||
// QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity.mapSheetNum.eq(
|
||||
// Long.valueOf(mapSheetNum)))
|
||||
// .fetch();
|
||||
//
|
||||
// GeoJsonReader reader = new GeoJsonReader();
|
||||
//
|
||||
// List<ChangeDetectionDto.PolygonFeature> result =
|
||||
// list.stream()
|
||||
// .map(
|
||||
// tuple -> {
|
||||
// String geojson = tuple.get(0, String.class);
|
||||
// Geometry geom;
|
||||
// try {
|
||||
// geom = reader.read(geojson);
|
||||
// } catch (Exception ex) {
|
||||
// throw new RuntimeException("GeoJSON -> Geometry 변환 실패", ex);
|
||||
// }
|
||||
// ChangeDetectionDto.PolygonProperties properties =
|
||||
// new ChangeDetectionDto.PolygonProperties(
|
||||
// tuple.get(mapSheetAnalDataGeomEntity.id).longValue(),
|
||||
// tuple.get(mapSheetAnalDataGeomEntity.area).doubleValue(),
|
||||
// tuple.get(mapSheetAnalDataGeomEntity.compareYyyy).intValue(),
|
||||
// tuple.get(mapSheetAnalDataGeomEntity.classBeforeProb).doubleValue(),
|
||||
// tuple
|
||||
// .get(mapSheetAnalDataGeomEntity.classBeforeCd.toUpperCase())
|
||||
// .toString(),
|
||||
// tuple.get(mapSheetAnalDataGeomEntity.targetYyyy).intValue(),
|
||||
// tuple.get(mapSheetAnalDataGeomEntity.classAfterProb).doubleValue(),
|
||||
// tuple
|
||||
// .get(mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())
|
||||
// .toString());
|
||||
// return new ChangeDetectionDto.PolygonFeature("Feature", geom, properties);
|
||||
// })
|
||||
// .collect(Collectors.toList());
|
||||
|
||||
ChangeDetectionDto.PolygonFeatureList polygonList = new ChangeDetectionDto.PolygonFeatureList();
|
||||
polygonList.setType("FeatureCollection");
|
||||
polygonList.setFeatures(result);
|
||||
|
||||
// list.clear(); // List<Tuple> 사용 참조 해제
|
||||
|
||||
return polygonList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ChangeDetectionDto.PointFeature> getChangeDetectionPointList(
|
||||
Long analUid, String mapSheetNum) {
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ChangeDetectionDto.PointFeature.class,
|
||||
Expressions.stringTemplate("{0}", "Feature"),
|
||||
mapSheetAnalDataGeomEntity.geomCenter, // point
|
||||
Projections.constructor(
|
||||
ChangeDetectionDto.PointProperties.class,
|
||||
mapSheetAnalDataGeomEntity.id,
|
||||
mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())))
|
||||
.from(mapSheetAnalDataGeomEntity)
|
||||
.innerJoin(mapSheetAnalDataEntity)
|
||||
.on(mapSheetAnalDataGeomEntity.dataUid.eq(mapSheetAnalDataEntity.id))
|
||||
.innerJoin(mapSheetAnalEntity)
|
||||
.on(mapSheetAnalEntity.id.eq(mapSheetAnalDataEntity.analUid))
|
||||
.where(
|
||||
mapSheetAnalEntity.id.eq(analUid),
|
||||
mapSheetAnalDataGeomEntity.mapSheetNum.eq(Long.valueOf(mapSheetNum)))
|
||||
.fetch();
|
||||
|
||||
// List<Tuple> list =
|
||||
// queryFactory
|
||||
// .select(
|
||||
// Expressions.stringTemplate(
|
||||
// "ST_AsGeoJSON(ST_Transform({0}, 4326))",
|
||||
// mapSheetAnalDataGeomEntity.geomCenter),
|
||||
// mapSheetAnalDataGeomEntity.id,
|
||||
// mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())
|
||||
// .from(mapSheetAnalDataGeomEntity)
|
||||
// .where(
|
||||
// mapSheetAnalDataGeomEntity.dataUid.in(
|
||||
// JPAExpressions.select(mapSheetAnalDataEntity.id)
|
||||
// .from(mapSheetAnalDataEntity)
|
||||
// .where(mapSheetAnalDataEntity.analUid.eq(analUid))),
|
||||
// mapSheetAnalDataGeomEntity.mapSheetNum.eq(Long.valueOf(mapSheetNum)))
|
||||
// .fetch();
|
||||
//
|
||||
// GeoJsonReader reader = new GeoJsonReader();
|
||||
// List<ChangeDetectionDto.PointFeature> result =
|
||||
// list.stream()
|
||||
// .map(
|
||||
// tuple -> {
|
||||
// String geojson = tuple.get(0, String.class);
|
||||
// Geometry geom;
|
||||
// try {
|
||||
// geom = reader.read(geojson);
|
||||
// } catch (Exception ex) {
|
||||
// throw new RuntimeException("GeoJSON -> Geometry 변환 실패", ex);
|
||||
// }
|
||||
//
|
||||
// Long geoUid = tuple.get(mapSheetAnalDataGeomEntity.id).longValue();
|
||||
// String classCd =
|
||||
//
|
||||
// tuple.get(mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase()).toString();
|
||||
//
|
||||
// return new ChangeDetectionDto.PointFeature(
|
||||
// "Feature", geom, new ChangeDetectionDto.PointProperties(geoUid,
|
||||
// classCd));
|
||||
// })
|
||||
// .collect(Collectors.toList());
|
||||
//
|
||||
// list.clear(); // List<Tuple> 사용 참조 해제
|
||||
//
|
||||
// return result;
|
||||
return new ChangeDetectionDto.PointFeatureList("FeatureCollection", list);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user