| | |
| | | package com.lf.server.service.show; |
| | | |
| | | import com.lf.server.entity.ctrl.MarkJsonEntity; |
| | | import com.lf.server.entity.ctrl.ShpRecordEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.data.MetaEntity; |
| | | import com.lf.server.entity.show.MarkEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.*; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @throws Exception 异常 |
| | | */ |
| | | public String downloadShp(UserEntity ue, List<MarkJsonEntity> list, HttpServletRequest req, HttpServletResponse res) throws Exception { |
| | | String parent = pathHelper.getTempPath(ue.getId()); |
| | | String parent = pathHelper.getTempPath(); |
| | | |
| | | String path = createShapeFiles(ue, list, parent); |
| | | File[] files = new File(path).listFiles(); |
| | |
| | | |
| | | List<MarkJsonEntity> points = getMarkByType(list, "POINT"); |
| | | if (points.size() > 0) { |
| | | String pointFile = GdalHelper.createShp(points, path, "POINT"); |
| | | String pointFile = ShpHelper.createShp(points, path, "POINT"); |
| | | } |
| | | List<MarkJsonEntity> lines = getMarkByType(list, "LINESTRING"); |
| | | if (lines.size() > 0) { |
| | | String lineFile = GdalHelper.createShp(lines, path, "LINESTRING"); |
| | | String lineFile = ShpHelper.createShp(lines, path, "LINESTRING"); |
| | | } |
| | | List<MarkJsonEntity> polygons = getMarkByType(list, "POLYGON"); |
| | | if (polygons.size() > 0) { |
| | | String polygonFile = GdalHelper.createShp(polygons, path, "POLYGON"); |
| | | String polygonFile = ShpHelper.createShp(polygons, path, "POLYGON"); |
| | | } |
| | | |
| | | return path; |
| | |
| | | } |
| | | |
| | | private String getZip() { |
| | | String path = pathHelper.getDownloadFullPath() + File.separator + WebHelper.getRandomInt(100000, 1000000) + ".zip"; |
| | | String path = pathHelper.getDownloadFullPath() + File.separator + StringHelper.YMDHMS2_FORMAT.format(new Date()) + ".zip"; |
| | | |
| | | File file = new File(path); |
| | | if (file.exists() && !file.isDirectory()) { |
| | |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | | de.setType(1); |
| | | de.setSizes(FileHelper.sizeToMb(new File(file).length())); |
| | | de.setDepid(ue.getDepid()); |
| | | de.setDcount(0); |
| | | // de.setPwd(null) |
| | | de.setUrl(FileHelper.getRelativePath(file)); |
| | | de.setDescr("下载ShapeFile文件"); |
| | | de.setDescr("ShapeFile文件"); |
| | | de.setGuid(FileHelper.getFileMd5(file)); |
| | | de.setCreateUser(ue.getId()); |
| | | // de.setGeom(null) |
| | |
| | | * @param list ShapeFile文件列表 |
| | | * @return Mark实体类集合 |
| | | */ |
| | | public List<MarkJsonEntity> readShpForMarks(List<MetaFileEntity> list) { |
| | | public List<MarkJsonEntity> readShpForMarks(List<MetaEntity> list) { |
| | | String fileName = null; |
| | | for (MetaFileEntity mf : list) { |
| | | for (MetaEntity mf : list) { |
| | | if (mf.getName().toLowerCase().indexOf(".shp") > -1) { |
| | | fileName = mf.getPath(); |
| | | break; |
| | |
| | | return null; |
| | | } |
| | | |
| | | List<MarkJsonEntity> mjeList = GdalHelper.readShpForMarks(fileName); |
| | | List<MarkJsonEntity> mjeList = ShpHelper.readShpForMarks(fileName); |
| | | FileHelper.deleteFiles(list); |
| | | |
| | | return mjeList; |