변화탐지 포인트 형식 수정, 폴리곤 json으로 리턴
This commit is contained in:
@@ -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