Merge pull request 'feat/demo-20251205' (#28) from feat/demo-20251205 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/28
This commit is contained in:
@@ -10,19 +10,12 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalSttcEntity.map
|
|||||||
|
|
||||||
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto;
|
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity;
|
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity;
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataEntity;
|
|
||||||
import com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataGeomEntity;
|
|
||||||
import com.querydsl.core.Tuple;
|
|
||||||
import com.querydsl.core.types.Projections;
|
import com.querydsl.core.types.Projections;
|
||||||
import com.querydsl.core.types.dsl.CaseBuilder;
|
import com.querydsl.core.types.dsl.CaseBuilder;
|
||||||
import com.querydsl.core.types.dsl.Expressions;
|
import com.querydsl.core.types.dsl.Expressions;
|
||||||
import com.querydsl.core.types.dsl.StringExpression;
|
import com.querydsl.core.types.dsl.StringExpression;
|
||||||
import com.querydsl.jpa.JPAExpressions;
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import org.locationtech.jts.geom.Geometry;
|
|
||||||
import org.locationtech.jts.io.geojson.GeoJsonReader;
|
|
||||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||||
|
|
||||||
public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||||
@@ -114,65 +107,93 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
public ChangeDetectionDto.PolygonFeatureList getChangeDetectionPolygonList(
|
public ChangeDetectionDto.PolygonFeatureList getChangeDetectionPolygonList(
|
||||||
Long analUid, String mapSheetNum) {
|
Long analUid, String mapSheetNum) {
|
||||||
|
|
||||||
List<Tuple> list =
|
List<ChangeDetectionDto.PolygonFeature> result =
|
||||||
queryFactory
|
queryFactory
|
||||||
.select(
|
.select(
|
||||||
Expressions.stringTemplate(
|
Projections.constructor(
|
||||||
"ST_AsGeoJSON(ST_Transform({0}, 4326))", mapSheetAnalDataGeomEntity.geom),
|
ChangeDetectionDto.PolygonFeature.class,
|
||||||
mapSheetAnalDataGeomEntity.id,
|
Expressions.stringTemplate("{0}", "Feature"),
|
||||||
mapSheetAnalDataGeomEntity.area,
|
mapSheetAnalDataGeomEntity.geom, // polygon
|
||||||
mapSheetAnalDataGeomEntity.compareYyyy,
|
Projections.constructor(
|
||||||
mapSheetAnalDataGeomEntity.classBeforeProb,
|
ChangeDetectionDto.PolygonProperties.class,
|
||||||
mapSheetAnalDataGeomEntity.classBeforeCd.toUpperCase(),
|
mapSheetAnalDataGeomEntity.id,
|
||||||
mapSheetAnalDataGeomEntity.targetYyyy,
|
mapSheetAnalDataGeomEntity.area,
|
||||||
mapSheetAnalDataGeomEntity.classAfterProb,
|
mapSheetAnalDataGeomEntity.compareYyyy,
|
||||||
mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())
|
mapSheetAnalDataGeomEntity.classBeforeProb,
|
||||||
.from(QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity)
|
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(
|
.where(
|
||||||
QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity.dataUid.in(
|
mapSheetAnalEntity.id.eq(analUid),
|
||||||
JPAExpressions.select(QMapSheetAnalDataEntity.mapSheetAnalDataEntity.id)
|
mapSheetAnalDataGeomEntity.mapSheetNum.eq(Long.valueOf(mapSheetNum)))
|
||||||
.from(QMapSheetAnalDataEntity.mapSheetAnalDataEntity)
|
|
||||||
.where(QMapSheetAnalDataEntity.mapSheetAnalDataEntity.analUid.eq(analUid))),
|
|
||||||
QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity.mapSheetNum.eq(
|
|
||||||
Long.valueOf(mapSheetNum)))
|
|
||||||
.fetch();
|
.fetch();
|
||||||
|
|
||||||
GeoJsonReader reader = new GeoJsonReader();
|
// List<Tuple> list =
|
||||||
|
// queryFactory
|
||||||
List<ChangeDetectionDto.PolygonFeature> result =
|
// .select(
|
||||||
list.stream()
|
// Expressions.stringTemplate(
|
||||||
.map(
|
// "ST_AsGeoJSON(ST_Transform({0}, 4326))", mapSheetAnalDataGeomEntity.geom),
|
||||||
tuple -> {
|
// mapSheetAnalDataGeomEntity.id,
|
||||||
String geojson = tuple.get(0, String.class);
|
// mapSheetAnalDataGeomEntity.area,
|
||||||
Geometry geom;
|
// mapSheetAnalDataGeomEntity.compareYyyy,
|
||||||
try {
|
// mapSheetAnalDataGeomEntity.classBeforeProb,
|
||||||
geom = reader.read(geojson);
|
// mapSheetAnalDataGeomEntity.classBeforeCd.toUpperCase(),
|
||||||
} catch (Exception ex) {
|
// mapSheetAnalDataGeomEntity.targetYyyy,
|
||||||
throw new RuntimeException("GeoJSON -> Geometry 변환 실패", ex);
|
// mapSheetAnalDataGeomEntity.classAfterProb,
|
||||||
}
|
// mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())
|
||||||
ChangeDetectionDto.PolygonProperties properties =
|
// .from(QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity)
|
||||||
new ChangeDetectionDto.PolygonProperties(
|
// .where(
|
||||||
tuple.get(mapSheetAnalDataGeomEntity.id).longValue(),
|
// QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity.dataUid.in(
|
||||||
tuple.get(mapSheetAnalDataGeomEntity.area).doubleValue(),
|
// JPAExpressions.select(QMapSheetAnalDataEntity.mapSheetAnalDataEntity.id)
|
||||||
tuple.get(mapSheetAnalDataGeomEntity.compareYyyy).intValue(),
|
// .from(QMapSheetAnalDataEntity.mapSheetAnalDataEntity)
|
||||||
tuple.get(mapSheetAnalDataGeomEntity.classBeforeProb).doubleValue(),
|
//
|
||||||
tuple
|
// .where(QMapSheetAnalDataEntity.mapSheetAnalDataEntity.analUid.eq(analUid))),
|
||||||
.get(mapSheetAnalDataGeomEntity.classBeforeCd.toUpperCase())
|
// QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity.mapSheetNum.eq(
|
||||||
.toString(),
|
// Long.valueOf(mapSheetNum)))
|
||||||
tuple.get(mapSheetAnalDataGeomEntity.targetYyyy).intValue(),
|
// .fetch();
|
||||||
tuple.get(mapSheetAnalDataGeomEntity.classAfterProb).doubleValue(),
|
//
|
||||||
tuple
|
// GeoJsonReader reader = new GeoJsonReader();
|
||||||
.get(mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())
|
//
|
||||||
.toString());
|
// List<ChangeDetectionDto.PolygonFeature> result =
|
||||||
return new ChangeDetectionDto.PolygonFeature("Feature", geom, properties);
|
// list.stream()
|
||||||
})
|
// .map(
|
||||||
.collect(Collectors.toList());
|
// 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();
|
ChangeDetectionDto.PolygonFeatureList polygonList = new ChangeDetectionDto.PolygonFeatureList();
|
||||||
polygonList.setType("FeatureCollection");
|
polygonList.setType("FeatureCollection");
|
||||||
polygonList.setFeatures(result);
|
polygonList.setFeatures(result);
|
||||||
|
|
||||||
list.clear(); // List<Tuple> 사용 참조 해제
|
// list.clear(); // List<Tuple> 사용 참조 해제
|
||||||
|
|
||||||
return polygonList;
|
return polygonList;
|
||||||
}
|
}
|
||||||
@@ -180,47 +201,70 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
@Override
|
@Override
|
||||||
public List<ChangeDetectionDto.PointFeature> getChangeDetectionPointList(
|
public List<ChangeDetectionDto.PointFeature> getChangeDetectionPointList(
|
||||||
Long analUid, String mapSheetNum) {
|
Long analUid, String mapSheetNum) {
|
||||||
List<Tuple> list =
|
return queryFactory
|
||||||
queryFactory
|
.select(
|
||||||
.select(
|
Projections.constructor(
|
||||||
Expressions.stringTemplate(
|
ChangeDetectionDto.PointFeature.class,
|
||||||
"ST_AsGeoJSON(ST_Transform({0}, 4326))", mapSheetAnalDataGeomEntity.geomCenter),
|
Expressions.stringTemplate("{0}", "Feature"),
|
||||||
mapSheetAnalDataGeomEntity.id,
|
mapSheetAnalDataGeomEntity.geomCenter, // point
|
||||||
mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())
|
Projections.constructor(
|
||||||
.from(mapSheetAnalDataGeomEntity)
|
ChangeDetectionDto.PointProperties.class,
|
||||||
.where(
|
mapSheetAnalDataGeomEntity.id,
|
||||||
mapSheetAnalDataGeomEntity.dataUid.in(
|
mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())))
|
||||||
JPAExpressions.select(mapSheetAnalDataEntity.id)
|
.from(mapSheetAnalDataGeomEntity)
|
||||||
.from(mapSheetAnalDataEntity)
|
.innerJoin(mapSheetAnalDataEntity)
|
||||||
.where(mapSheetAnalDataEntity.analUid.eq(analUid))),
|
.on(mapSheetAnalDataGeomEntity.dataUid.eq(mapSheetAnalDataEntity.id))
|
||||||
mapSheetAnalDataGeomEntity.mapSheetNum.eq(Long.valueOf(mapSheetNum)))
|
.innerJoin(mapSheetAnalEntity)
|
||||||
.fetch();
|
.on(mapSheetAnalEntity.id.eq(mapSheetAnalDataEntity.analUid))
|
||||||
|
.where(
|
||||||
|
mapSheetAnalEntity.id.eq(analUid),
|
||||||
|
mapSheetAnalDataGeomEntity.mapSheetNum.eq(Long.valueOf(mapSheetNum)))
|
||||||
|
.fetch();
|
||||||
|
|
||||||
GeoJsonReader reader = new GeoJsonReader();
|
// List<Tuple> list =
|
||||||
List<ChangeDetectionDto.PointFeature> result =
|
// queryFactory
|
||||||
list.stream()
|
// .select(
|
||||||
.map(
|
// Expressions.stringTemplate(
|
||||||
tuple -> {
|
// "ST_AsGeoJSON(ST_Transform({0}, 4326))",
|
||||||
String geojson = tuple.get(0, String.class);
|
// mapSheetAnalDataGeomEntity.geomCenter),
|
||||||
Geometry geom;
|
// mapSheetAnalDataGeomEntity.id,
|
||||||
try {
|
// mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase())
|
||||||
geom = reader.read(geojson);
|
// .from(mapSheetAnalDataGeomEntity)
|
||||||
} catch (Exception ex) {
|
// .where(
|
||||||
throw new RuntimeException("GeoJSON -> Geometry 변환 실패", ex);
|
// mapSheetAnalDataGeomEntity.dataUid.in(
|
||||||
}
|
// JPAExpressions.select(mapSheetAnalDataEntity.id)
|
||||||
|
// .from(mapSheetAnalDataEntity)
|
||||||
Long geoUid = tuple.get(mapSheetAnalDataGeomEntity.id).longValue();
|
// .where(mapSheetAnalDataEntity.analUid.eq(analUid))),
|
||||||
String classCd =
|
// mapSheetAnalDataGeomEntity.mapSheetNum.eq(Long.valueOf(mapSheetNum)))
|
||||||
tuple.get(mapSheetAnalDataGeomEntity.classAfterCd.toUpperCase()).toString();
|
// .fetch();
|
||||||
|
//
|
||||||
return new ChangeDetectionDto.PointFeature(
|
// GeoJsonReader reader = new GeoJsonReader();
|
||||||
"Feature", geom, new ChangeDetectionDto.PointProperties(geoUid, classCd));
|
// List<ChangeDetectionDto.PointFeature> result =
|
||||||
})
|
// list.stream()
|
||||||
.collect(Collectors.toList());
|
// .map(
|
||||||
|
// tuple -> {
|
||||||
list.clear(); // List<Tuple> 사용 참조 해제
|
// String geojson = tuple.get(0, String.class);
|
||||||
|
// Geometry geom;
|
||||||
return result;
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user