| | |
| | | package com.lf.server.service.show; |
| | | |
| | | import com.lf.server.entity.ctrl.MarkJsonEntity; |
| | | import com.lf.server.entity.show.MarkEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.GdalHelper; |
| | | import com.lf.server.helper.PathHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.mapper.show.MarkMapper; |
| | | import com.lf.server.service.data.UploaderService; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * 标绘 |
| | |
| | | public class MarkService implements MarkMapper { |
| | | @Autowired |
| | | MarkMapper markMapper; |
| | | |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | | |
| | | @Override |
| | | public Integer selectCount(Integer uid) { |
| | |
| | | public Integer updates(List<MarkEntity> list) { |
| | | return markMapper.updates(list); |
| | | } |
| | | |
| | | public void downloadShp(UserEntity ue, List<MarkJsonEntity> list, HttpServletRequest req, HttpServletResponse res) { |
| | | String path = getShpDir(ue); |
| | | |
| | | List<MarkJsonEntity> points = getMarkByType(list, "POINT"); |
| | | if (points.size() > 0) { |
| | | String pointFile = GdalHelper.createShp(points, path, "POINT"); |
| | | } |
| | | List<MarkJsonEntity> lines = getMarkByType(list, "LINESTRING"); |
| | | if (lines.size() > 0) { |
| | | String lineFile = GdalHelper.createShp(lines, path, "LINESTRING"); |
| | | } |
| | | List<MarkJsonEntity> polygons = getMarkByType(list, "POLYGON"); |
| | | if (polygons.size() > 0) { |
| | | String polygonFile = GdalHelper.createShp(polygons, path, "POLYGON"); |
| | | } |
| | | |
| | | // |
| | | } |
| | | |
| | | private String getShpDir(UserEntity ue) { |
| | | String path = pathHelper.getTempPath(ue.getId()) + File.separator + WebHelper.getRandomInt(100000, 1000000); |
| | | |
| | | File file = new File(path); |
| | | if (!file.exists() && !file.isDirectory()) { |
| | | file.mkdirs(); |
| | | } |
| | | |
| | | return path; |
| | | } |
| | | |
| | | private List<MarkJsonEntity> getMarkByType(List<MarkJsonEntity> list, String type) { |
| | | List<MarkJsonEntity> rs = new ArrayList<MarkJsonEntity>(); |
| | | for (MarkJsonEntity mark : list) { |
| | | if (StringHelper.isEmpty(mark.getWkt())) { |
| | | continue; |
| | | } |
| | | if (mark.getWkt().indexOf(type) > -1) { |
| | | rs.add(mark); |
| | | } |
| | | } |
| | | |
| | | return rs; |
| | | } |
| | | } |