shp 파일 생성 수정
This commit is contained in:
@@ -123,8 +123,7 @@ public class GeoToolsShpWriter implements ShpWriter {
|
|||||||
* 생성된다. - geometry는 GeoTools GeometryJSON을 사용하여 직렬화한다.
|
* 생성된다. - geometry는 GeoTools GeometryJSON을 사용하여 직렬화한다.
|
||||||
*
|
*
|
||||||
* <p>GeoJSON 구조 예: { "type": "FeatureCollection", "name": "stage_input1_input2_mapId", "crs": {
|
* <p>GeoJSON 구조 예: { "type": "FeatureCollection", "name": "stage_input1_input2_mapId", "crs": {
|
||||||
* "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::5186" } }, "properties": { ...
|
* "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::5186" } }, "properties": { ... }, "features": [ ... ] }
|
||||||
* }, "features": [ ... ] }
|
|
||||||
*
|
*
|
||||||
* @param geoJsonPath 생성할 GeoJSON 파일의 전체 경로 (.geojson 포함)
|
* @param geoJsonPath 생성할 GeoJSON 파일의 전체 경로 (.geojson 포함)
|
||||||
* @param rows 동일 그룹(stage, mapId, input1, input2)의 데이터 목록
|
* @param rows 동일 그룹(stage, mapId, input1, input2)의 데이터 목록
|
||||||
@@ -273,14 +272,25 @@ public class GeoToolsShpWriter implements ShpWriter {
|
|||||||
return b.buildFeatureType();
|
return b.buildFeatureType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* .shp .shx .dbf .fix 파일 생성 (껍데기 생성)
|
||||||
|
*
|
||||||
|
* @param shpFile
|
||||||
|
* @param schema
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
private ShapefileDataStore createDataStore(File shpFile, SimpleFeatureType schema)
|
private ShapefileDataStore createDataStore(File shpFile, SimpleFeatureType schema)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
Map<String, Serializable> params = new HashMap<>();
|
Map<String, Serializable> params = new HashMap<>();
|
||||||
params.put("url", shpFile.toURI().toURL());
|
params.put("url", shpFile.toURI().toURL());
|
||||||
params.put("create spatial index", Boolean.TRUE);
|
|
||||||
|
// .fix 파일 생성 Boolean.TRUE, 미생성 Boolean.FALSE
|
||||||
|
params.put("create spatial index", Boolean.FALSE);
|
||||||
|
|
||||||
ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
|
ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
|
||||||
|
|
||||||
ShapefileDataStore dataStore = (ShapefileDataStore) factory.createNewDataStore(params);
|
ShapefileDataStore dataStore = (ShapefileDataStore) factory.createNewDataStore(params);
|
||||||
|
|
||||||
dataStore.setCharset(DBF_CHARSET);
|
dataStore.setCharset(DBF_CHARSET);
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ public class InferenceResultShpService {
|
|||||||
private final InferenceResultShpCoreService coreService;
|
private final InferenceResultShpCoreService coreService;
|
||||||
private final ShpWriter shpWriter;
|
private final ShpWriter shpWriter;
|
||||||
|
|
||||||
/** inference_results 테이블을 기준으로 분석 결과 테이블과 도형 테이블을 최신 상태로 반영한다. */
|
/**
|
||||||
|
* inference_results 테이블을 기준으로 분석 결과 테이블과 도형 테이블을 최신 상태로 반영한다.
|
||||||
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public InferenceResultShpDto.InferenceCntDto saveInferenceResultData() {
|
public InferenceResultShpDto.InferenceCntDto saveInferenceResultData() {
|
||||||
return coreService.buildInferenceData();
|
return coreService.buildInferenceData();
|
||||||
@@ -33,6 +35,7 @@ public class InferenceResultShpService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public InferenceResultShpDto.FileCntDto createShpFile() {
|
public InferenceResultShpDto.FileCntDto createShpFile() {
|
||||||
|
|
||||||
|
// TODO 파일 경로는 정해지면 수정, properties 사용
|
||||||
String baseDir = System.getProperty("user.home") + "/export";
|
String baseDir = System.getProperty("user.home") + "/export";
|
||||||
|
|
||||||
int batchSize = 100;
|
int batchSize = 100;
|
||||||
@@ -47,7 +50,7 @@ public class InferenceResultShpService {
|
|||||||
// 재생성을 위한 생성 상태 초기화
|
// 재생성을 위한 생성 상태 초기화
|
||||||
coreService.resetForRegenerate(dataUid);
|
coreService.resetForRegenerate(dataUid);
|
||||||
|
|
||||||
// 도형 데이터 조회
|
// 추론 데이터 조회
|
||||||
List<InferenceResultShpDto.Basic> dtoList = coreService.loadGeomDtos(dataUid, geomLimit);
|
List<InferenceResultShpDto.Basic> dtoList = coreService.loadGeomDtos(dataUid, geomLimit);
|
||||||
if (dtoList.isEmpty()) {
|
if (dtoList.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -64,7 +67,7 @@ public class InferenceResultShpService {
|
|||||||
String geoJsonPath = baseDir + "/geojson/" + baseName + ".geojson";
|
String geoJsonPath = baseDir + "/geojson/" + baseName + ".geojson";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 폴더 안 파일을 세지 않고, Writer가 "이번 호출에서 write한 개수"를 반환
|
// Writer가 "이번 호출에서 write한 개수"를 반환
|
||||||
total = total.plus(shpWriter.writeShp(shpBasePath, dtoList));
|
total = total.plus(shpWriter.writeShp(shpBasePath, dtoList));
|
||||||
total = total.plus(shpWriter.writeGeoJson(geoJsonPath, dtoList));
|
total = total.plus(shpWriter.writeGeoJson(geoJsonPath, dtoList));
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface ShpWriter {
|
public interface ShpWriter {
|
||||||
|
|
||||||
// SHP (.shp/.shx/.dbf)
|
// SHP (.shp/.shx/.dbf/.fix)
|
||||||
WriteCnt writeShp(String shpBasePath, List<InferenceResultShpDto.Basic> rows);
|
WriteCnt writeShp(String shpBasePath, List<InferenceResultShpDto.Basic> rows);
|
||||||
|
|
||||||
// GeoJSON (.geojson)
|
// GeoJSON (.geojson)
|
||||||
|
|||||||
Reference in New Issue
Block a user