| | |
| | | and optime group by to_char(optime, 'yyyy-mm-dd') order by to_char(optime, 'yyyy-mm-dd') asc; |
| | | ----------------------------------------------------------------------------------------------------- |
| | | select a.*,coalesce(a.native,'') from lf.sys_user a; |
| | | select * from lf.sys_menu order by id; |
| | | |
| | | select * from lf.sys_blacklist where type = 1; |
| | | select * from lf.sys_operate where modular1 is null or modular2 is null; |
| | | select count(*) from bd.dlg_agnp; |
| | | select count(*) from bd.dlg_25w_aanp; |
| | | select ST_PointFromText('POINT(95.80461853400004 34.13862467200005)'); |
| | | select ST_LineFromText('LINESTRING(04.98985101830993 37.43840773692756,104.99318913447104 37.43883729720358)', 4326); |
| | | select ST_PolygonFromText('POLYGON((104.9907822932683 37.43532941961706,104.99088987736599 37.43532941961706,104.9908670336867 37.4349030213574,104.99078327712658 37.4349030213574,104.9907822932683 37.43532941961706))',4326); |
| | | |
| | | -- 114msï¼180/3248 |
| | | select count(1) from bd.dlg_agnp a where ST_Intersects(geom, |
| | |
| | | and ST_Intersects(geom, |
| | | ST_PolygonFromText('POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))', 4326)) |
| | | |
| | | select id,uname "name" from lf.sys_user where uname like '%室%' order by uname limit 10; |
| | | select id,name from lf.sys_dep where name like '%å¸%' order by order_num limit 10; |
| | | |
| | | select st_astext(geom) from bd.dlg_25w_hfcl limit 10; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.controller.all.BaseController; |
| | | import com.lf.server.entity.all.HttpStatus; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | 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.WebHelper; |
| | | import com.lf.server.service.show.MarkService; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return fail(ex.getMessage(), -1); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "ä¸ä¼ ShapeFileæä»¶") |
| | | @ResponseBody |
| | | @PostMapping(value = "/uploadShp", produces = "application/json; charset=UTF-8") |
| | | public ResponseMsg<List<MarkJsonEntity>> uploadShp(HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | List<MarkJsonEntity> list = null; |
| | | |
| | | return success(list); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "ä¸è½½ShapeFileæä»¶") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "list", value = "æ ç»JSONå®ä½ç±»éå", dataType = "MarkJsonEntity", paramType = "body") |
| | | }) |
| | | @ResponseBody |
| | | @PostMapping(value = "/downloadShp", produces = "application/json; charset=UTF-8") |
| | | public void downloadShp(@RequestBody List<MarkJsonEntity> list, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | if (ue == null) { |
| | | WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, "ç¨æ·æªç»å½")); |
| | | } |
| | | if (list == null || list.isEmpty()) { |
| | | WebHelper.write2Page(res, WebHelper.getErrJson(HttpStatus.BAD_REQUEST, "æ¾ä¸å°æ ç»å®ä½")); |
| | | } |
| | | |
| | | markService.downloadShp(ue, list, req, res); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.lf.server.entity.ctrl; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * æä»¶ä¿¡æ¯ |
| | | * @author WWW |
| | | */ |
| | | public class FileInfoEntity { |
| | | public class FileInfoEntity implements Serializable { |
| | | private static final long serialVersionUID = -674723262772248619L; |
| | | |
| | | private String fileName; |
| | | |
| | | private Long size; |
| | |
| | | package com.lf.server.entity.ctrl; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * ID-åç§°å®ä½ç±» |
| | | * @author WWW |
| | | */ |
| | | public class IdNameEntity { |
| | | public class IdNameEntity implements Serializable { |
| | | private static final long serialVersionUID = -8485687857643406110L; |
| | | |
| | | private Integer id; |
| | | |
| | | private String name; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.lf.server.entity.ctrl; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * æ ç»JSONå®ä½ç±» |
| | | * @author WWW |
| | | */ |
| | | public class MarkJsonEntity implements Serializable { |
| | | private static final long serialVersionUID = 7776629022021914001L; |
| | | |
| | | private Integer id; |
| | | |
| | | private String name; |
| | | |
| | | private String wkt; |
| | | |
| | | private String props; |
| | | |
| | | public MarkJsonEntity() { |
| | | } |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | | } |
| | | |
| | | public void setId(Integer id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getWkt() { |
| | | return wkt; |
| | | } |
| | | |
| | | public void setWkt(String wkt) { |
| | | this.wkt = wkt; |
| | | } |
| | | |
| | | public String getProps() { |
| | | return props; |
| | | } |
| | | |
| | | public void setProps(String props) { |
| | | this.props = props; |
| | | } |
| | | } |
| | |
| | | package com.lf.server.helper; |
| | | |
| | | import com.lf.server.entity.ctrl.MarkJsonEntity; |
| | | import com.lf.server.entity.ctrl.ShpRecordEntity; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | |
| | | import org.gdal.ogr.*; |
| | | import org.gdal.osr.SpatialReference; |
| | | |
| | | import java.io.File; |
| | | import java.sql.Time; |
| | | import java.sql.Timestamp; |
| | | import java.time.LocalDate; |
| | |
| | | |
| | | return new ShpRecordEntity(wkt, csid); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | log.error(ex.getMessage(), ex); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å建ShapeFileæä»¶ |
| | | * |
| | | * @param list æ ç»JSONå®ä½ç±»éå |
| | | * @param path è·¯å¾ |
| | | * @param type ç±»åï¼POINT,LINESTRING,POLYGON |
| | | * @return ShapeFileæä»¶å |
| | | */ |
| | | public static String createShp(List<MarkJsonEntity> list, String path, String type) { |
| | | try { |
| | | org.gdal.ogr.Driver driver = ogr.GetDriverByName("ESRI shapefile"); |
| | | if (driver == null) { |
| | | return null; |
| | | } |
| | | |
| | | String filePath = path + File.separator + type.toLowerCase() + ".shp"; |
| | | //DataSource ds = driver.Open(filePath, 0); |
| | | DataSource ds = driver.CreateDataSource(filePath, null); |
| | | |
| | | SpatialReference sr = new SpatialReference(); |
| | | sr.ImportFromEPSG(4326); |
| | | |
| | | int geoType = getGeometryType(type); |
| | | Layer layer = ds.CreateLayer(type.toLowerCase(), sr, geoType); |
| | | |
| | | FieldDefn fdName = new FieldDefn("name", ogr.OFTString); |
| | | fdName.SetWidth(50); |
| | | layer.CreateField(fdName, 0); |
| | | |
| | | FieldDefn fdProps = new FieldDefn("props", ogr.OFTString); |
| | | fdProps.SetWidth(1024); |
| | | // layer.DeleteField(layer.FindFieldIndex("name", 1)); |
| | | layer.CreateField(fdProps, 1); |
| | | |
| | | FeatureDefn featureDefn = layer.GetLayerDefn(); |
| | | for (MarkJsonEntity mje : list) { |
| | | Geometry geo = Geometry.CreateFromWkt(mje.getWkt()); |
| | | |
| | | Feature f = new Feature(featureDefn); |
| | | f.SetField(0, mje.getName()); |
| | | f.SetField(1, mje.getProps()); |
| | | f.SetGeometry(geo); |
| | | |
| | | layer.CreateFeature(f); |
| | | } |
| | | |
| | | layer.delete(); |
| | | ds.delete(); |
| | | driver.delete(); |
| | | |
| | | return filePath; |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åå¾å½¢ç±»å |
| | | */ |
| | | private static int getGeometryType(String type) { |
| | | switch (type) { |
| | | case "POINT": |
| | | return 1; |
| | | case "LINESTRING": |
| | | return 2; |
| | | case "POLYGON": |
| | | return 3; |
| | | default: |
| | | return -1; |
| | | } |
| | | } |
| | | |
| | |
| | | gdal.GDALDestroyDriverManager(); |
| | | } |
| | | |
| | | private static void writeShp(String filePath) { |
| | | try { |
| | | org.gdal.ogr.Driver driver = ogr.GetDriverByName("ESRI shapefile"); |
| | | if (driver == null) { |
| | | System.out.println(" ESRI shapefile驱å¨ä¸å¯ç¨ï¼\n"); |
| | | System.out.println("fail"); |
| | | } |
| | | |
| | | // Open()ç第äºä¸ªåæ°é»è®¤ä¸º0ï¼æ¯ä»¥åªè¯»æ¹å¼æå¼æä»¶ï¼1æ¯è¯»åæ¹å¼æå¼ |
| | | DataSource dSource = driver.Open(filePath, 0); |
| | | |
| | | Layer layer = dSource.GetLayerByIndex(0); |
| | | FieldDefn fieldDefn = new FieldDefn("name", ogr.OFTString); |
| | | fieldDefn.SetWidth(50); |
| | | layer.CreateField(fieldDefn, 1); |
| | | layer.DeleteField(layer.FindFieldIndex("name", 1)); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 读åshpæä»¶ |
| | | * |
| | | * @param filePath |
| | | */ |
| | | public static void readShp(String filePath) { |
| | |
| | | |
| | | /** |
| | | * 读ågdbæä»¶ |
| | | * |
| | | * @param filePath |
| | | */ |
| | | public static void readGdb(String filePath) { |
| | |
| | | package com.lf.server.helper; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.lf.server.entity.all.HttpStatus; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.all.SettingData; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | |
| | | import java.io.PrintWriter; |
| | | import java.sql.Timestamp; |
| | | import java.util.Calendar; |
| | | import java.util.Random; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | |
| | | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * è·åé误JSON |
| | | */ |
| | | public static String getErrJson(HttpStatus status, String msg) { |
| | | return JSON.toJSONString(new ResponseMsg<String>(status, msg)); |
| | | } |
| | | |
| | | /** |
| | | * è·åéæºæ´æ° |
| | | */ |
| | | public static int getRandomInt(int min, int max) { |
| | | return new Random().nextInt(max) % (max - min + 1) + min; |
| | | } |
| | | } |
| | |
| | | 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; |
| | | } |
| | | } |