| | |
| | | select * from bs.m_pipesegment; |
| | | select gid, pipename, segname from bs.m_pipesegment order by pipename, segname; |
| | | |
| | | select * from bd.dlg_25w_hydl; |
| | | select * from bd.dlg_25w_lrdl; |
| | | select * from bd.dlg_25w_lrrl; |
| | | select * from bd.dlg_25w_hyda; |
| | | select * from bd.dlg_25w_hydl limit 10; |
| | | select * from bd.dlg_25w_lrdl limit 10; |
| | | select * from bd.dlg_25w_lrrl limit 10; |
| | | select * from bd.dlg_25w_hyda limit 10; |
| | | select * from bs.m_pipesegment limit 10; |
| | | |
| | | select ST_SRID(geom), ST_GeometryType(geom) from bd.dlg_25w_hydl limit 1; |
| | | select ST_SRID(geom), ST_GeometryType(geom) from bd.dlg_25w_lrdl limit 1; |
| | | select ST_SRID(geom), ST_GeometryType(geom) from bd.dlg_25w_lrrl limit 1; |
| | | select ST_SRID(geom), ST_GeometryType(geom) from bd.dlg_25w_hyda limit 1; |
| | | select ST_SRID(geom), ST_GeometryType(geom) from bs.m_pipesegment limit 1; |
| | | |
| | | SELECT a.name as acrossName, |
| | | b.segname as segName, |
| | |
| | | where ST_Intersects(a.geom, b.geom) |
| | | |
| | | select * from lf.sys_download where type=4; |
| | | |
| | | |
| | | select * from bs.m_pipesegment; |
| | | |
| | | |
| | | |
| | |
| | | return fail("密码不符合要求"); |
| | | } |
| | | |
| | | Map<String, List<?>> map = new HashMap<>(4); |
| | | Map<String, List<PipelineEntity>> map = new HashMap<>(4); |
| | | for (String tab : pe.getTabs()) { |
| | | List<?> rs = pipelineService.selectPipeAnalysis(tab, pe.getGid()); |
| | | List<PipelineEntity> rs = pipelineService.selectPipeAnalysis(tab, pe.getGid()); |
| | | if (null != rs && rs.size() > 0) { |
| | | map.put(tab, rs); |
| | | } |
| | |
| | | public final static String EQ = "="; |
| | | |
| | | /** |
| | | * Object对象 |
| | | */ |
| | | public final static String OBJECT = "java.lang.Object"; |
| | | |
| | | /** |
| | | * 插入排除字段 |
| | | */ |
| | | public final static List<String> INSERT_EXCLUDE_FIELDS = new ArrayList<>(Arrays.asList("gid", "objectid", "updateuser", "updatetime", "shape_leng", "shape_area", "serialVersionUID", "dirName", "depName", "verName", "createName", "updateName")); |
| | |
| | | public class GdbHelper { |
| | | private final static Log log = LogFactory.getLog(GdbHelper.class); |
| | | |
| | | private final static String OBJECT = "java.lang.Object"; |
| | | |
| | | /** |
| | | * 销毁资源 |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | if (!OBJECT.equals(clazz.getSuperclass().getName())) { |
| | | if (!StaticData.OBJECT.equals(clazz.getSuperclass().getName())) { |
| | | getFieldMapper(clazz.getSuperclass(), layer, map); |
| | | } |
| | | } catch (Exception ex) { |
| | |
| | | String geo = "null"; |
| | | if (null != f.GetGeometryRef()) { |
| | | String wkt = f.GetGeometryRef().ExportToWkt(); |
| | | // noinspection AlibabaRemoveCommentedCode |
| | | switch (f.GetGeometryRef().GetGeometryType()) { |
| | | //case 1: |
| | | // wkt = wkt.replace("POINT", "MULTIPOINT"); |
| | | // break; |
| | | case 2: |
| | | wkt = wkt.replace("LINESTRING (", "MULTILINESTRING ((") + ")"; |
| | | break; |
| | |
| | | |
| | | Integer srid = baseMapper.selectSrid(tab); |
| | | SpatialReference sr = new SpatialReference(); |
| | | sr.ImportFromEPSG(null == srid ? 4326 : srid); |
| | | sr.ImportFromEPSG(null == srid ? 4490 : srid); |
| | | |
| | | return dataSource.CreateLayer(tab, sr, getGeomType(geomType), null); |
| | | } |
| | |
| | | switch (geomType) { |
| | | case "ST_Point": |
| | | return ogr.wkbPoint; |
| | | case "ST_MultiPoint": |
| | | return ogr.wkbMultiPoint; |
| | | case "ST_LineString": |
| | | return ogr.wkbLineString; |
| | | case "ST_MultiLineString": |
| | |
| | | list.add(f); |
| | | } |
| | | |
| | | if (!OBJECT.equals(clazz.getSuperclass().getName())) { |
| | | if (!StaticData.OBJECT.equals(clazz.getSuperclass().getName())) { |
| | | getFields(clazz.getSuperclass(), list); |
| | | } |
| | | } catch (Exception ex) { |
| | |
| | | /** |
| | | * 添加图层字段 |
| | | */ |
| | | private static void addLayerField(Layer layer, List<Field> list) { |
| | | public static void addLayerField(Layer layer, List<Field> list) { |
| | | for (int i = 0, c = list.size(); i < c; i++) { |
| | | Field f = list.get(i); |
| | | |
| | |
| | | Geometry geom = Geometry.CreateFromWkt(geoEntity.getGeom()); |
| | | f.SetGeometry(geom); |
| | | |
| | | for (int i = 0, c = fields.size(); i < c; i++) { |
| | | Field field = fields.get(i); |
| | | Object val = field.get(t); |
| | | if (null == val) { |
| | | continue; |
| | | } |
| | | |
| | | switch (field.getType().getName()) { |
| | | case "java.math.BigDecimal": |
| | | BigDecimal big = (BigDecimal) val; |
| | | f.SetField(i, big.doubleValue()); |
| | | break; |
| | | case "java.lang.Double": |
| | | case "double": |
| | | double d = (double) val; |
| | | f.SetField(i, d); |
| | | break; |
| | | case "java.lang.Long": |
| | | case "long": |
| | | long l = (long) val; |
| | | f.SetField(i, l); |
| | | break; |
| | | case "java.lang.Integer": |
| | | case "int": |
| | | int n = (int) val; |
| | | f.SetField(i, n); |
| | | break; |
| | | case "java.sql.Timestamp": |
| | | Timestamp timestamp = (Timestamp) field.get(t); |
| | | setTimestamp(f, i, timestamp); |
| | | break; |
| | | case "java.time.LocalDate": |
| | | LocalDate localDate = (LocalDate) field.get(t); |
| | | setLocalDate(f, i, localDate); |
| | | break; |
| | | default: |
| | | String str = (String) val; |
| | | f.SetField(i, str); |
| | | break; |
| | | } |
| | | } |
| | | setFeatureData(f, fields, t); |
| | | layer.CreateFeature(f); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置要素的数据 |
| | | */ |
| | | public static <T> void setFeatureData(Feature f, List<Field> fields, T t) throws Exception { |
| | | for (int i = 0, c = fields.size(); i < c; i++) { |
| | | Field field = fields.get(i); |
| | | Object val = field.get(t); |
| | | if (null == val) { |
| | | continue; |
| | | } |
| | | |
| | | switch (field.getType().getName()) { |
| | | case "java.math.BigDecimal": |
| | | BigDecimal big = (BigDecimal) val; |
| | | f.SetField(i, big.doubleValue()); |
| | | break; |
| | | case "java.lang.Double": |
| | | case "double": |
| | | double d = (double) val; |
| | | f.SetField(i, d); |
| | | break; |
| | | case "java.lang.Long": |
| | | case "long": |
| | | long l = (long) val; |
| | | f.SetField(i, l); |
| | | break; |
| | | case "java.lang.Integer": |
| | | case "int": |
| | | int n = (int) val; |
| | | f.SetField(i, n); |
| | | break; |
| | | case "java.sql.Timestamp": |
| | | Timestamp timestamp = (Timestamp) field.get(t); |
| | | setTimestamp(f, i, timestamp); |
| | | break; |
| | | case "java.time.LocalDate": |
| | | LocalDate localDate = (LocalDate) field.get(t); |
| | | setLocalDate(f, i, localDate); |
| | | break; |
| | | default: |
| | | String str = (String) val; |
| | | f.SetField(i, str); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置Timestamp |
| | | */ |
| | | private static void setTimestamp(Feature f, int i, Timestamp time) { |
| | |
| | | package com.lf.server.service.show; |
| | | |
| | | import com.lf.server.entity.all.BaseGeoEntity; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.show.PipelineEntity; |
| | |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import com.lf.server.mapper.data.DownloadMapper; |
| | | import com.lf.server.mapper.show.PipelineMapper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import net.lingala.zip4j.ZipFile; |
| | | import net.lingala.zip4j.model.FileHeader; |
| | | import net.lingala.zip4j.model.ZipParameters; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.gdal.ogr.DataSource; |
| | | import org.gdal.ogr.Driver; |
| | | import org.gdal.ogr.Layer; |
| | | import org.gdal.ogr.ogr; |
| | | import org.gdal.ogr.*; |
| | | import org.gdal.osr.SpatialReference; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.File; |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | * @param pwd 密码 |
| | | * @return 下载文件GUID |
| | | */ |
| | | public String createZipFile(UserEntity ue, Map<String, List<?>> map, String pwd) throws Exception { |
| | | public String createZipFile(UserEntity ue, Map<String, List<PipelineEntity>> map, String pwd) throws Exception { |
| | | if (map.size() == 0) { |
| | | return null; |
| | | } |
| | |
| | | if (file.exists() && file.isDirectory()) { |
| | | FileHelper.deleteDir(filePath); |
| | | } |
| | | //createGdb(filePath, map); |
| | | createGdb(filePath, map); |
| | | |
| | | String zipName = tempName + ".gdb.zip"; |
| | | String zipFile = pathHelper.getDownloadFullPath() + File.separator + zipName; |
| | |
| | | /** |
| | | * 创建GDB |
| | | */ |
| | | public static void createGdb(String filePath, Map<String, List<?>> map) throws Exception { |
| | | public static void createGdb(String filePath, Map<String, List<PipelineEntity>> map) throws Exception { |
| | | Driver driver = null; |
| | | DataSource dataSource = null; |
| | | try { |
| | |
| | | for (String key : map.keySet()) { |
| | | Layer layer = null; |
| | | try { |
| | | List<PipelineEntity> list = map.get(key); |
| | | layer = createLayer(dataSource, key, list.get(0)); |
| | | |
| | | // layer = createLayer(dataSource, baseMapper); |
| | | // if (null == layer) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // String className = ClassHelper.getClassName(baseMapper); |
| | | // Class clazz = ClassHelper.getEntityClass(className); |
| | | // if (null == clazz) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // List<Field> fields = new ArrayList<>(); |
| | | // // fields.add(getGeomField(clazz)) |
| | | // getFields(clazz, fields); |
| | | // addLayerField(layer, fields); |
| | | // |
| | | // setLayerData(layer, fields, map.get(key)); |
| | | List<Field> fields = new ArrayList<>(); |
| | | getFields(PipelineEntity.class, fields); |
| | | |
| | | GdbHelper.addLayerField(layer, fields); |
| | | setLayerData(layer, fields, list); |
| | | } finally { |
| | | if (null != layer) { |
| | | layer.delete(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 创建图层 |
| | | */ |
| | | private static Layer createLayer(DataSource dataSource, String tab, PipelineEntity pe) { |
| | | int geomType = pe.getWkt().contains("POINT") ? ogr.wkbMultiPoint : ogr.wkbMultiLineString; |
| | | |
| | | SpatialReference sr = new SpatialReference(); |
| | | sr.ImportFromEPSG(4490); |
| | | |
| | | return dataSource.CreateLayer(tab, sr, geomType, null); |
| | | } |
| | | |
| | | /** |
| | | * 获取字段 |
| | | */ |
| | | private static void getFields(Class clazz, List<Field> list) { |
| | | try { |
| | | Field[] fields = clazz.getDeclaredFields(); |
| | | for (Field f : fields) { |
| | | if (StaticData.GDB_EXCLUDE_FIELDS.contains(f.getName())) { |
| | | continue; |
| | | } |
| | | |
| | | f.setAccessible(true); |
| | | list.add(f); |
| | | } |
| | | |
| | | if (!StaticData.OBJECT.equals(clazz.getSuperclass().getName())) { |
| | | getFields(clazz.getSuperclass(), list); |
| | | } |
| | | } catch (Exception ex) { |
| | | // |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置图层数据 |
| | | */ |
| | | private static void setLayerData(Layer layer, List<Field> fields, List<PipelineEntity> list) throws Exception { |
| | | for (PipelineEntity t : list) { |
| | | Feature f = new Feature(layer.GetLayerDefn()); |
| | | |
| | | String wkt = t.getWkt(); |
| | | if (!wkt.contains("MULTI")) { |
| | | wkt = wkt.replace("POINT", "MULTIPOINT").replace("LINESTRING", "MULTILINESTRING(") + (wkt.contains("LINESTRING") ? ")" : ""); |
| | | } |
| | | |
| | | Geometry geom = Geometry.CreateFromWkt(wkt); |
| | | f.SetGeometry(geom); |
| | | |
| | | GdbHelper.setFeatureData(f, fields, t); |
| | | layer.CreateFeature(f); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加Zip文件 |
| | | */ |
| | | private void addZipFiles(ZipFile zip, ZipParameters params, File[] files) { |