|
|
@@ -5,6 +5,7 @@ import com.siwei.common.core.utils.StringUtils;
|
|
|
import com.siwei.common.core.utils.uuid.IdUtils;
|
|
|
import com.siwei.spatial.api.domain.file.TGeomDb;
|
|
|
import com.siwei.spatial.api.domain.file.TGeomDbDetails;
|
|
|
+import com.siwei.spatial.mapper.file.TGeomDbDetailsMapper;
|
|
|
import com.siwei.spatial.service.file.ISpatialFilesDbService;
|
|
|
import com.siwei.spatial.service.file.ITGeomDbDetailsService;
|
|
|
import com.siwei.spatial.service.file.ITGeomDbService;
|
|
|
@@ -15,6 +16,8 @@ import org.geotools.data.simple.SimpleFeatureCollection;
|
|
|
import org.geotools.data.simple.SimpleFeatureIterator;
|
|
|
import org.geotools.referencing.CRS;
|
|
|
import org.locationtech.jts.geom.Geometry;
|
|
|
+import org.locationtech.jts.io.ParseException;
|
|
|
+import org.locationtech.jts.io.WKTReader;
|
|
|
import org.opengis.feature.simple.SimpleFeature;
|
|
|
import org.opengis.feature.type.AttributeDescriptor;
|
|
|
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
|
|
@@ -28,8 +31,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.nio.charset.Charset;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class SpatialFilesDbServiceImpl implements ISpatialFilesDbService {
|
|
|
@@ -66,6 +71,12 @@ public class SpatialFilesDbServiceImpl implements ISpatialFilesDbService {
|
|
|
private ITGeomDbService itGeomDbService;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TGeomDbDetailsMapper tGeomDbDetailsMapper;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public TGeomDb readShpFile(String shpFileName, String shpFilePath, String fromRoute) throws IOException {
|
|
|
@@ -366,6 +377,83 @@ public class SpatialFilesDbServiceImpl implements ISpatialFilesDbService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ //todo 这里文件上传获取矢量处理
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public TGeomDb uploadAddShpFileV1(String filePath, String fromRoute, Integer fromtype) {
|
|
|
+ TGeomDb dto = new TGeomDb();
|
|
|
+ dto.setId(IdUtils.fastSimpleUUID());
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public TGeomDb uploadAddShpDrawV1(String geom, String fromRoute, Integer fromtype) {
|
|
|
+ String ewkt = "SRID=" + shpDbSRID + ";" + geom;
|
|
|
+ if (geom.toLowerCase().indexOf("srid") >= 0) {
|
|
|
+ ewkt = geom;
|
|
|
+ }
|
|
|
+ TGeomDb dto = new TGeomDb();
|
|
|
+ dto.setId(IdUtils.fastSimpleUUID());
|
|
|
+
|
|
|
+ dto.setName("");
|
|
|
+ dto.setShppath("");
|
|
|
+ dto.setFiletype("1");
|
|
|
+ dto.setFromroute(fromRoute);
|
|
|
+ dto.setGeom(ewkt);
|
|
|
+ dto.setGeomNumber(1L);
|
|
|
+ // 计算面积
|
|
|
+ String geomArea = "0";
|
|
|
+ WKTReader reader = new WKTReader();
|
|
|
+ Geometry geometry = null;
|
|
|
+ try {
|
|
|
+ geometry = reader.read(geom);
|
|
|
+ geomArea = String.valueOf(geometry.getArea());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ dto.setGeomArea(new BigDecimal(geomArea));
|
|
|
+ dto.setShpDbSRID(shpDbSRID);
|
|
|
+ dto.setShpAreaSRID(shpAreaSRID);
|
|
|
+ dto.setShpOutSRID(shpOutSRID);
|
|
|
+ dto.setShpAreaGeography(shpAreaGeography);
|
|
|
+ itGeomDbService.insertTGeomDb(dto);
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String,Object>> testReadShape(String shpFile) {
|
|
|
+ List<Map<String, Object>> shpFeaturesList = readShapeFile(new File(shpFile));
|
|
|
+ return shpFeaturesList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String testInsertShp(List<Map<String,Object>> shpDataMapList) {
|
|
|
+ //List<Map<String, Object>> shpFeaturesList = readShapeFile(new File(shpFile));
|
|
|
+ //shpDataMapList = shpDataMapList.stream().filter(map -> map.get("djqdm").equals("360122015")).collect(Collectors.toList());
|
|
|
+ //tGeomDbDetailsMapper.batchInsertDjq(shpDataMapList,4326);
|
|
|
+ tGeomDbDetailsMapper.batchInsertDjzq(shpDataMapList,4326);
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Map<String,Object>> testGetShpData(String tabeName) {
|
|
|
+ List<Map<String,Object>> geoms = tGeomDbDetailsMapper.selectTableDataAndGeom(tabeName);
|
|
|
+ return geoms;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|