Merge pull request '변화탐지 point, cogUrl API 수정' (#42) from feat/dev_251201 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/42
This commit is contained in:
@@ -57,7 +57,19 @@ public class ChangeDetectionDto {
|
||||
|
||||
private String beforeCogUrl;
|
||||
private String afterCogUrl;
|
||||
private Geometry bbox;
|
||||
private JsonNode bbox;
|
||||
}
|
||||
|
||||
@Schema(name = "CogUrlDto", description = "COG Url 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class CogUrlData {
|
||||
|
||||
private String beforeCogUrl;
|
||||
private String afterCogUrl;
|
||||
private String bbox;
|
||||
}
|
||||
|
||||
@Schema(name = "AnalYearList", description = "년도(차수) 목록")
|
||||
@@ -140,6 +152,18 @@ public class ChangeDetectionDto {
|
||||
private Double cdProb; // 탐지정확도
|
||||
}
|
||||
|
||||
@Schema(name = "PointFeature", description = "Geometry 리턴 객체")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class PointQueryData {
|
||||
|
||||
private String type;
|
||||
private String geometry; // point
|
||||
private PointProperties properties; // Point 정보
|
||||
}
|
||||
|
||||
@Schema(name = "PointFeature", description = "Geometry 리턴 객체")
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -148,7 +172,7 @@ public class ChangeDetectionDto {
|
||||
public static class PointFeature {
|
||||
|
||||
private String type;
|
||||
private Geometry geometry; // point
|
||||
private JsonNode geometry; // point
|
||||
private PointProperties properties; // Point 정보
|
||||
}
|
||||
|
||||
|
||||
@@ -19,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.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
|
||||
@@ -71,24 +72,38 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
|
||||
@Override
|
||||
public ChangeDetectionDto.CogUrlDto getChangeDetectionCogUrl(ChangeDetectionDto.CogUrlReq req) {
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ChangeDetectionDto.CogUrlDto.class,
|
||||
makeCogUrl(req.getBeforeYear()).max().as("beforeCogUrl"),
|
||||
makeCogUrl(req.getAfterYear()).max().as("afterCogUrl"),
|
||||
mapInkx5kEntity.geom.as("bbox")))
|
||||
.from(imageryEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(imageryEntity.scene5k.eq(mapInkx5kEntity.mapidcdNo))
|
||||
.where(
|
||||
imageryEntity
|
||||
.year
|
||||
.eq(req.getBeforeYear())
|
||||
.or(imageryEntity.year.eq(req.getAfterYear())),
|
||||
imageryEntity.scene5k.eq(req.getMapSheetNum()))
|
||||
.groupBy(mapInkx5kEntity.geom)
|
||||
.fetchOne();
|
||||
ChangeDetectionDto.CogUrlData data =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ChangeDetectionDto.CogUrlData.class,
|
||||
makeCogUrl(req.getBeforeYear()).max().as("beforeCogUrl"),
|
||||
makeCogUrl(req.getAfterYear()).max().as("afterCogUrl"),
|
||||
Expressions.stringTemplate("ST_AsGeoJSON({0})", mapInkx5kEntity.geom)
|
||||
.as("bbox")))
|
||||
.from(imageryEntity)
|
||||
.innerJoin(mapInkx5kEntity)
|
||||
.on(imageryEntity.scene5k.eq(mapInkx5kEntity.mapidcdNo))
|
||||
.where(
|
||||
imageryEntity
|
||||
.year
|
||||
.eq(req.getBeforeYear())
|
||||
.or(imageryEntity.year.eq(req.getAfterYear())),
|
||||
imageryEntity.scene5k.eq(req.getMapSheetNum()))
|
||||
.groupBy(mapInkx5kEntity.geom)
|
||||
.fetchOne();
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String geoJson = Objects.requireNonNull(data).getBbox();
|
||||
JsonNode jsonNode;
|
||||
try {
|
||||
jsonNode = mapper.readTree(geoJson);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return new ChangeDetectionDto.CogUrlDto(
|
||||
data.getBeforeCogUrl(), data.getAfterCogUrl(), jsonNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,13 +192,14 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
@Override
|
||||
public ChangeDetectionDto.PointFeatureList getChangeDetectionPointList(
|
||||
Long analUid, String mapSheetNum) {
|
||||
List<ChangeDetectionDto.PointFeature> list =
|
||||
List<ChangeDetectionDto.PointQueryData> list =
|
||||
queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ChangeDetectionDto.PointFeature.class,
|
||||
ChangeDetectionDto.PointQueryData.class,
|
||||
Expressions.stringTemplate("{0}", "Feature"),
|
||||
mapSheetAnalDataGeomEntity.geomCenter, // point
|
||||
Expressions.stringTemplate(
|
||||
"ST_AsGeoJSON({0})", mapSheetAnalDataGeomEntity.geomCenter), // point
|
||||
Projections.constructor(
|
||||
ChangeDetectionDto.PointProperties.class,
|
||||
mapSheetAnalDataGeomEntity.id,
|
||||
@@ -198,7 +214,25 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
mapSheetAnalDataGeomEntity.mapSheetNum.eq(Long.valueOf(mapSheetNum)))
|
||||
.fetch();
|
||||
|
||||
return new ChangeDetectionDto.PointFeatureList("FeatureCollection", list);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
List<ChangeDetectionDto.PointFeature> result =
|
||||
list.stream()
|
||||
.map(
|
||||
data -> {
|
||||
String geoJson = data.getGeometry();
|
||||
JsonNode jsonNode;
|
||||
try {
|
||||
jsonNode = mapper.readTree(geoJson);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return new ChangeDetectionDto.PointFeature(
|
||||
data.getType(), jsonNode, data.getProperties());
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new ChangeDetectionDto.PointFeatureList("FeatureCollection", result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user