Commit 62581fade9da0bd8670045a1ae1361c2474c5a0a

Authored by 潘钊
1 parent ce14e4e1

update...

src/main/java/com/bsth/controller/geo_data/GeoDataController.java
@@ -48,6 +48,12 @@ public class GeoDataController { @@ -48,6 +48,12 @@ public class GeoDataController {
48 return geoDataService.addNewStationRoute(lineCode, upDown, versions, stationName, lat, lng, prevRouteId); 48 return geoDataService.addNewStationRoute(lineCode, upDown, versions, stationName, lat, lng, prevRouteId);
49 } 49 }
50 50
  51 + @RequestMapping(value = "addNewRoadRoute",method = RequestMethod.POST)
  52 + public Map<String, Object> addNewRoadRoute(@RequestParam String lineCode,@RequestParam int versions,@RequestParam int upDown
  53 + ,@RequestParam String sectionName,@RequestParam String crosesRoad,@RequestParam String coords,@RequestParam int prevRouteId){
  54 + return geoDataService.addNewRoadRoute(lineCode, upDown, versions, sectionName, crosesRoad, coords, prevRouteId);
  55 + }
  56 +
51 @RequestMapping(value = "destroyStation",method = RequestMethod.POST) 57 @RequestMapping(value = "destroyStation",method = RequestMethod.POST)
52 public Map<String, Object> destroyStation(GeoStation station){ 58 public Map<String, Object> destroyStation(GeoStation station){
53 return geoDataService.destroyStation(station); 59 return geoDataService.destroyStation(station);
@@ -57,4 +63,9 @@ public class GeoDataController { @@ -57,4 +63,9 @@ public class GeoDataController {
57 public Map<String, Object> updateRoadInfo(GeoRoad road){ 63 public Map<String, Object> updateRoadInfo(GeoRoad road){
58 return geoDataService.updateRoadInfo(road); 64 return geoDataService.updateRoadInfo(road);
59 } 65 }
  66 +
  67 + @RequestMapping(value = "destroyRoad",method = RequestMethod.POST)
  68 + public Map<String, Object> destroyRoad(GeoRoad road){
  69 + return geoDataService.destroyRoad(road);
  70 + }
60 } 71 }
61 \ No newline at end of file 72 \ No newline at end of file
src/main/java/com/bsth/service/geo_data/GeoDataService.java
@@ -25,4 +25,8 @@ public interface GeoDataService { @@ -25,4 +25,8 @@ public interface GeoDataService {
25 Map<String,Object> destroyStation(GeoStation station); 25 Map<String,Object> destroyStation(GeoStation station);
26 26
27 Map<String,Object> updateRoadInfo(GeoRoad road); 27 Map<String,Object> updateRoadInfo(GeoRoad road);
  28 +
  29 + Map<String,Object> destroyRoad(GeoRoad road);
  30 +
  31 + Map<String,Object> addNewRoadRoute(String lineCode, int upDown, int versions, String sectionName,String crosesRoad, String coords, int prevRouteId);
28 } 32 }
src/main/java/com/bsth/service/geo_data/impl/GeoDataServiceImpl.java
@@ -168,7 +168,7 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -168,7 +168,7 @@ public class GeoDataServiceImpl implements GeoDataService {
168 } 168 }
169 169
170 @Override 170 @Override
171 - public Map<String, Object> addNewStationRoute(String lineCode, int upDown, int versions, String stationName, Float lat, Float lng, int prevRouteId) { 171 + public Map<String, Object> addNewRoadRoute(String lineCode, int upDown, int versions, String sectionName,String crosesRoad, String coords, int prevRouteId) {
172 Map<String, Object> rs = new HashMap<>(); 172 Map<String, Object> rs = new HashMap<>();
173 173
174 //编程式事务 174 //编程式事务
@@ -180,11 +180,111 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -180,11 +180,111 @@ public class GeoDataServiceImpl implements GeoDataService {
180 //根据站点编码,查询站点ID 180 //根据站点编码,查询站点ID
181 int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class); 181 int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class);
182 182
183 - String sql = "select * from bsth_c_ls_stationroute where line_code='"+lineCode+"' and line="+lineId+" and directions="+upDown+" and destroy=0 and versions=" + versions; 183 + String sql = "select * from bsth_c_ls_sectionroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions;
  184 + List<SaveRoadRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveRoadRouteDTO.class));
  185 +
  186 + Collections.sort(routes, new RoadRouteComp());
  187 +
  188 + long sCode = GetUIDAndCode.getSectionId();
  189 + //转wgs
  190 + String wgsCoord = "LINESTRING(" + bdPolygon2Wgs(coords) + ")";
  191 + String bdCooed = "LINESTRING(" + coords + ")";
  192 + //insert 路段
  193 + sql = "insert into bsth_c_section(id, section_code, section_name, croses_road, bsection_vector, gsection_vector, create_date, update_date, versions) " +
  194 + " values(?,?,?,?,ST_GeomFromText('"+wgsCoord+"'),ST_GeomFromText('"+bdCooed+"'),sysdate(),sysdate(),?)";
  195 +
  196 + jdbcTemplate.update(sql, sCode, sCode, sectionName, crosesRoad, 1);
  197 +
  198 +
  199 + SaveRoadRouteDTO srr;
  200 + int currentNo = -1,
  201 + no = 100, step = 100;
  202 +
  203 + if (prevRouteId == -1) {
  204 + //起点站
  205 + currentNo = no;
  206 + no += step;
  207 + }
  208 + //重新排序路由
  209 + for (int i = 0, size = routes.size(); i < size; i++) {
  210 + srr = routes.get(i);
  211 + srr.setSectionrouteCode(no += step);
  212 + if (srr.getId().intValue() == prevRouteId) {
  213 + no += step;
  214 + currentNo = no;
  215 + }
  216 + }
  217 +
  218 + srr = new SaveRoadRouteDTO();
  219 + srr.setLine(lineId);
  220 + srr.setLineCode(lineCode);
  221 + srr.setDirections(upDown);
  222 + srr.setVersions(versions);
  223 +
  224 + srr.setSectionrouteCode(currentNo);
  225 + srr.setSection(sCode);
  226 + srr.setSectionCode(sCode + "");
  227 + srr.setIsRoadeSpeed(0);
  228 + srr.setDestroy(0);
  229 + Date d = new Date();
  230 + srr.setCreateDate(d);
  231 + srr.setUpdateDate(d);
  232 +
  233 + final List<SaveRoadRouteDTO> saveList = routes;
  234 + //insert 新路由 (ID自增)
  235 + jdbcTemplate.update("insert into bsth_c_ls_sectionroute(line_code, section_code, sectionroute_code, directions, line, section, create_date,update_date,versions,destroy,is_roade_speed)" +
  236 + " values(?,?,?,?,?,?,?,?,?,?,?)", srr.getLineCode(), srr.getSectionCode(), srr.getSectionrouteCode(), srr.getDirections(), srr.getLine(), srr.getSection(), srr.getCreateDate(), srr.getUpdateDate(), versions, srr.getDestroy(), srr.getIsRoadeSpeed());
  237 +
  238 + // update 原路由
  239 + jdbcTemplate.batchUpdate("update bsth_c_ls_sectionroute set sectionroute_code=? where id=?"
  240 + , new BatchPreparedStatementSetter() {
  241 + @Override
  242 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  243 + SaveRoadRouteDTO srr = saveList.get(i);
  244 + ps.setInt(1, srr.getSectionrouteCode());
  245 + ps.setInt(2, srr.getId());
  246 + }
  247 +
  248 + @Override
  249 + public int getBatchSize() {
  250 + return saveList.size();
  251 + }
  252 + });
  253 +
  254 + tran.commit(status);
  255 +
  256 + //返回更新之后的数据
  257 + List<GeoRoad> list = findRoadByUpdown(lineCode, upDown, versions);
  258 + rs.put("list", list);
  259 + rs.put("upDown", upDown);
  260 + rs.put("status", ResponseCode.SUCCESS);
  261 + } catch (Exception e) {
  262 + tran.rollback(status);
  263 + logger.error("", e);
  264 + rs.put("status", ResponseCode.ERROR);
  265 + rs.put("msg", "服务器出现异常");
  266 + }
  267 + return rs;
  268 + }
  269 +
  270 + @Override
  271 + public Map<String, Object> addNewStationRoute(String lineCode, int upDown, int versions, String stationName, Float lat, Float lng, int prevRouteId) {
  272 + Map<String, Object> rs = new HashMap<>();
  273 +
  274 + //编程式事务
  275 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  276 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  277 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  278 + TransactionStatus status = tran.getTransaction(def);
  279 + try {
  280 + //根据线路编码,查询线路ID
  281 + int lineId = jdbcTemplate.queryForObject("select id from bsth_c_line where line_code=" + lineCode, Integer.class);
  282 +
  283 + String sql = "select * from bsth_c_ls_stationroute where line_code='" + lineCode + "' and line=" + lineId + " and directions=" + upDown + " and destroy=0 and versions=" + versions;
184 List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class)); 284 List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class));
185 285
186 - for(SaveStationRouteDTO s : routes){  
187 - if(s.getStationName().equals(stationName)){ 286 + for (SaveStationRouteDTO s : routes) {
  287 + if (s.getStationName().equals(stationName)) {
188 288
189 rs.put("status", ResponseCode.ERROR); 289 rs.put("status", ResponseCode.ERROR);
190 rs.put("msg", "重复的站点路由名称!"); 290 rs.put("msg", "重复的站点路由名称!");
@@ -205,19 +305,19 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -205,19 +305,19 @@ public class GeoDataServiceImpl implements GeoDataService {
205 305
206 SaveStationRouteDTO sr; 306 SaveStationRouteDTO sr;
207 int currentNo = -1, 307 int currentNo = -1,
208 - no = 100, step = 100; 308 + no = 100, step = 100;
209 309
210 - if(prevRouteId == -1){ 310 + if (prevRouteId == -1) {
211 //起点站 311 //起点站
212 currentNo = no; 312 currentNo = no;
213 no += step; 313 no += step;
214 } 314 }
215 //重新排序路由 315 //重新排序路由
216 - for(int i = 0, size = routes.size(); i < size; i ++){ 316 + for (int i = 0, size = routes.size(); i < size; i++) {
217 sr = routes.get(i); 317 sr = routes.get(i);
218 - sr.setStationRouteCode(no+=step);  
219 - if(sr.getId().intValue() == prevRouteId){  
220 - no+=step; 318 + sr.setStationRouteCode(no += step);
  319 + if (sr.getId().intValue() == prevRouteId) {
  320 + no += step;
221 currentNo = no; 321 currentNo = no;
222 } 322 }
223 } 323 }
@@ -242,7 +342,7 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -242,7 +342,7 @@ public class GeoDataServiceImpl implements GeoDataService {
242 342
243 //重新标记mark 343 //重新标记mark
244 Collections.sort(routes, new StationRouteComp()); 344 Collections.sort(routes, new StationRouteComp());
245 - for(int i = 0, size = routes.size(); i < size; i ++){ 345 + for (int i = 0, size = routes.size(); i < size; i++) {
246 routes.get(i).setStationMark("Z"); 346 routes.get(i).setStationMark("Z");
247 } 347 }
248 routes.get(0).setStationMark("B"); 348 routes.get(0).setStationMark("B");
@@ -251,39 +351,39 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -251,39 +351,39 @@ public class GeoDataServiceImpl implements GeoDataService {
251 final List<SaveStationRouteDTO> saveList = routes; 351 final List<SaveStationRouteDTO> saveList = routes;
252 //insert 新路由 (ID自增) 352 //insert 新路由 (ID自增)
253 jdbcTemplate.update("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)" 353 jdbcTemplate.update("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
254 - ,nsr.getLine(),nsr.getStation(),nsr.getStationName(),nsr.getStationRouteCode(),nsr.getLineCode(),nsr.getStationCode(),nsr.getStationMark()  
255 - ,nsr.getDistances(),nsr.getToTime(),nsr.getDestroy(),nsr.getVersions(),nsr.getCreateDate(),nsr.getUpdateDate(),nsr.getDirections()); 354 + , nsr.getLine(), nsr.getStation(), nsr.getStationName(), nsr.getStationRouteCode(), nsr.getLineCode(), nsr.getStationCode(), nsr.getStationMark()
  355 + , nsr.getDistances(), nsr.getToTime(), nsr.getDestroy(), nsr.getVersions(), nsr.getCreateDate(), nsr.getUpdateDate(), nsr.getDirections());
256 356
257 // update 原路由 357 // update 原路由
258 jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," + 358 jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," +
259 - "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" + 359 + "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" +
260 " where id=?" 360 " where id=?"
261 , new BatchPreparedStatementSetter() { 361 , new BatchPreparedStatementSetter() {
262 - @Override  
263 - public void setValues(PreparedStatement ps, int i) throws SQLException {  
264 - SaveStationRouteDTO sr = saveList.get(i);  
265 - ps.setInt(1, sr.getLine());  
266 - ps.setLong(2, sr.getStation());  
267 - ps.setString(3, sr.getStationName());  
268 - ps.setInt(4, sr.getStationRouteCode());  
269 - ps.setString(5, sr.getLineCode());  
270 - ps.setString(6, sr.getStationCode());  
271 - ps.setString(7, sr.getStationMark());  
272 - ps.setDouble(8, sr.getDistances());  
273 - ps.setDouble(9, sr.getToTime());  
274 - ps.setInt(10, sr.getDestroy());  
275 - ps.setInt(11, sr.getVersions());  
276 - ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime()));  
277 - ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime()));  
278 - ps.setInt(14, sr.getDirections());  
279 - ps.setInt(15, sr.getId());  
280 - }  
281 -  
282 - @Override  
283 - public int getBatchSize() {  
284 - return saveList.size();  
285 - }  
286 - }); 362 + @Override
  363 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  364 + SaveStationRouteDTO sr = saveList.get(i);
  365 + ps.setInt(1, sr.getLine());
  366 + ps.setLong(2, sr.getStation());
  367 + ps.setString(3, sr.getStationName());
  368 + ps.setInt(4, sr.getStationRouteCode());
  369 + ps.setString(5, sr.getLineCode());
  370 + ps.setString(6, sr.getStationCode());
  371 + ps.setString(7, sr.getStationMark());
  372 + ps.setDouble(8, sr.getDistances());
  373 + ps.setDouble(9, sr.getToTime());
  374 + ps.setInt(10, sr.getDestroy());
  375 + ps.setInt(11, sr.getVersions());
  376 + ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime()));
  377 + ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime()));
  378 + ps.setInt(14, sr.getDirections());
  379 + ps.setInt(15, sr.getId());
  380 + }
  381 +
  382 + @Override
  383 + public int getBatchSize() {
  384 + return saveList.size();
  385 + }
  386 + });
287 387
288 tran.commit(status); 388 tran.commit(status);
289 389
@@ -302,9 +402,9 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -302,9 +402,9 @@ public class GeoDataServiceImpl implements GeoDataService {
302 return rs; 402 return rs;
303 } 403 }
304 404
305 - private List<GeoStation> findByUpdown(String lineCode, int upDown, int versions){ 405 + private List<GeoStation> findByUpdown(String lineCode, int upDown, int versions) {
306 //返回更新之后的数据 406 //返回更新之后的数据
307 - String sql = "select t1.*,t2.g_lonx,g_laty,ST_AsText(g_polygon_grid) as g_polygon_grid,radius,shapes_type from (select id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions from bsth_c_ls_stationroute where line=" + lineCode + " and directions="+upDown+" and destroy=0 and versions="+versions+") t1 LEFT JOIN bsth_c_station t2 on t1.station_code=t2.station_cod"; 407 + String sql = "select t1.*,t2.g_lonx,g_laty,ST_AsText(g_polygon_grid) as g_polygon_grid,radius,shapes_type from (select id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions from bsth_c_ls_stationroute where line=" + lineCode + " and directions=" + upDown + " and destroy=0 and versions=" + versions + ") t1 LEFT JOIN bsth_c_station t2 on t1.station_code=t2.station_cod";
308 List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class)); 408 List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class));
309 409
310 for (GeoStation station : list) { 410 for (GeoStation station : list) {
@@ -314,6 +414,17 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -314,6 +414,17 @@ public class GeoDataServiceImpl implements GeoDataService {
314 return list; 414 return list;
315 } 415 }
316 416
  417 + private List<GeoRoad> findRoadByUpdown(String lineCode, int upDown, int versions) {
  418 + //返回更新之后的数据
  419 + String sql = "select t1.*,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector from (select id,sectionroute_code,directions,line_code,section_code,versions from bsth_c_ls_sectionroute where line='" + lineCode + "' and directions=" + upDown + " and destroy=0 and versions=" + versions + ") t1 LEFT JOIN bsth_c_section t2 on t1.section_code=t2.section_code";
  420 + List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class));
  421 +
  422 + for (GeoRoad road : list) {
  423 + road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2));
  424 + }
  425 + return list;
  426 + }
  427 +
317 @Override 428 @Override
318 public Map<String, Object> destroyStation(GeoStation station) { 429 public Map<String, Object> destroyStation(GeoStation station) {
319 Map<String, Object> rs = new HashMap<>(); 430 Map<String, Object> rs = new HashMap<>();
@@ -335,6 +446,26 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -335,6 +446,26 @@ public class GeoDataServiceImpl implements GeoDataService {
335 } 446 }
336 447
337 @Override 448 @Override
  449 + public Map<String, Object> destroyRoad(GeoRoad road) {
  450 + Map<String, Object> rs = new HashMap<>();
  451 +
  452 + try {
  453 + String sql = "update bsth_c_ls_sectionroute set destroy=1 where id=?";
  454 + jdbcTemplate.update(sql, road.getId());
  455 +
  456 + //返回更新之后的数据
  457 + List<GeoRoad> list = findRoadByUpdown(road.getLineCode(), road.getDirections(), road.getVersions());
  458 + rs.put("list", list);
  459 + rs.put("status", ResponseCode.SUCCESS);
  460 + } catch (Exception e) {
  461 + logger.error("", e);
  462 + rs.put("status", ResponseCode.ERROR);
  463 + rs.put("msg", "服务器出现异常");
  464 + }
  465 + return rs;
  466 + }
  467 +
  468 + @Override
338 public Map<String, Object> updateRoadInfo(GeoRoad road) { 469 public Map<String, Object> updateRoadInfo(GeoRoad road) {
339 Map<String, Object> rs = new HashMap<>(); 470 Map<String, Object> rs = new HashMap<>();
340 471
@@ -378,14 +509,14 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -378,14 +509,14 @@ public class GeoDataServiceImpl implements GeoDataService {
378 return s; 509 return s;
379 } 510 }
380 511
381 - private GeoRoad findOneRoad(int id){  
382 - String sql = "SELECT t1.*, t2.section_name,t2.croses_road,ST_AsText (t2.gsection_vector) AS gsection_vector FROM (SELECT id,sectionroute_code,directions,line_code,section_code,versions FROM bsth_c_ls_sectionroute WHERE id="+id+") t1 LEFT JOIN bsth_c_section t2 ON t1.section_code = t2.section_code"; 512 + private GeoRoad findOneRoad(int id) {
  513 + String sql = "SELECT t1.*, t2.section_name,t2.croses_road,ST_AsText (t2.gsection_vector) AS gsection_vector FROM (SELECT id,sectionroute_code,directions,line_code,section_code,versions FROM bsth_c_ls_sectionroute WHERE id=" + id + ") t1 LEFT JOIN bsth_c_section t2 ON t1.section_code = t2.section_code";
383 List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class)); 514 List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class));
384 515
385 for (GeoRoad road : list) { 516 for (GeoRoad road : list) {
386 road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2)); 517 road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2));
387 } 518 }
388 - return list.size() > 0 ?list.get(0):null; 519 + return list.size() > 0 ? list.get(0) : null;
389 } 520 }
390 521
391 private String bdPolygon2Wgs(String bdPolygon) { 522 private String bdPolygon2Wgs(String bdPolygon) {
@@ -434,4 +565,12 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -434,4 +565,12 @@ public class GeoDataServiceImpl implements GeoDataService {
434 return s1.getStationRouteCode() - s2.getStationRouteCode(); 565 return s1.getStationRouteCode() - s2.getStationRouteCode();
435 } 566 }
436 } 567 }
  568 +
  569 + private static class RoadRouteComp implements Comparator<SaveRoadRouteDTO> {
  570 +
  571 + @Override
  572 + public int compare(SaveRoadRouteDTO s1, SaveRoadRouteDTO s2) {
  573 + return s1.getSectionrouteCode() - s2.getSectionrouteCode();
  574 + }
  575 + }
437 } 576 }
438 \ No newline at end of file 577 \ No newline at end of file
src/main/java/com/bsth/service/geo_data/impl/SaveRoadRouteDTO.java 0 → 100644
  1 +package com.bsth.service.geo_data.impl;
  2 +
  3 +import java.util.Date;
  4 +
  5 +/**
  6 + * Created by panzhao on 2017/12/17.
  7 + */
  8 +public class SaveRoadRouteDTO {
  9 +
  10 + private Integer id;
  11 +
  12 + // 路段路由序号
  13 + private Integer sectionrouteCode;
  14 +
  15 + // 线路编号
  16 + private String lineCode;
  17 +
  18 + // 路段编号
  19 + private String sectionCode;
  20 +
  21 + // 路段路由方向
  22 + private Integer directions;
  23 +
  24 + // 版本号
  25 + private Integer versions;
  26 +
  27 + // 是否撤销
  28 + private Integer destroy;
  29 +
  30 + /** 是否有路段限速数据 <0:分段;1:未分段>*/
  31 + private Integer isRoadeSpeed;
  32 +
  33 + // 描述
  34 + private String descriptions;
  35 +
  36 + // 创建人
  37 + private Integer createBy;
  38 +
  39 + // 修改人
  40 + private Integer updateBy;
  41 +
  42 + // 创建日期
  43 + private Date createDate;
  44 +
  45 + // 修改日期
  46 + private Date updateDate;
  47 +
  48 + // 路段信息
  49 + private long section;
  50 +
  51 + // 线路ID
  52 + private int line;
  53 +
  54 + public Integer getId() {
  55 + return id;
  56 + }
  57 +
  58 + public void setId(Integer id) {
  59 + this.id = id;
  60 + }
  61 +
  62 + public Integer getSectionrouteCode() {
  63 + return sectionrouteCode;
  64 + }
  65 +
  66 + public void setSectionrouteCode(Integer sectionrouteCode) {
  67 + this.sectionrouteCode = sectionrouteCode;
  68 + }
  69 +
  70 + public String getLineCode() {
  71 + return lineCode;
  72 + }
  73 +
  74 + public void setLineCode(String lineCode) {
  75 + this.lineCode = lineCode;
  76 + }
  77 +
  78 + public String getSectionCode() {
  79 + return sectionCode;
  80 + }
  81 +
  82 + public void setSectionCode(String sectionCode) {
  83 + this.sectionCode = sectionCode;
  84 + }
  85 +
  86 + public Integer getDirections() {
  87 + return directions;
  88 + }
  89 +
  90 + public void setDirections(Integer directions) {
  91 + this.directions = directions;
  92 + }
  93 +
  94 + public Integer getVersions() {
  95 + return versions;
  96 + }
  97 +
  98 + public void setVersions(Integer versions) {
  99 + this.versions = versions;
  100 + }
  101 +
  102 + public Integer getDestroy() {
  103 + return destroy;
  104 + }
  105 +
  106 + public void setDestroy(Integer destroy) {
  107 + this.destroy = destroy;
  108 + }
  109 +
  110 + public Integer getIsRoadeSpeed() {
  111 + return isRoadeSpeed;
  112 + }
  113 +
  114 + public void setIsRoadeSpeed(Integer isRoadeSpeed) {
  115 + this.isRoadeSpeed = isRoadeSpeed;
  116 + }
  117 +
  118 + public String getDescriptions() {
  119 + return descriptions;
  120 + }
  121 +
  122 + public void setDescriptions(String descriptions) {
  123 + this.descriptions = descriptions;
  124 + }
  125 +
  126 + public Integer getCreateBy() {
  127 + return createBy;
  128 + }
  129 +
  130 + public void setCreateBy(Integer createBy) {
  131 + this.createBy = createBy;
  132 + }
  133 +
  134 + public Integer getUpdateBy() {
  135 + return updateBy;
  136 + }
  137 +
  138 + public void setUpdateBy(Integer updateBy) {
  139 + this.updateBy = updateBy;
  140 + }
  141 +
  142 + public Date getCreateDate() {
  143 + return createDate;
  144 + }
  145 +
  146 + public void setCreateDate(Date createDate) {
  147 + this.createDate = createDate;
  148 + }
  149 +
  150 + public Date getUpdateDate() {
  151 + return updateDate;
  152 + }
  153 +
  154 + public void setUpdateDate(Date updateDate) {
  155 + this.updateDate = updateDate;
  156 + }
  157 +
  158 + public long getSection() {
  159 + return section;
  160 + }
  161 +
  162 + public void setSection(long section) {
  163 + this.section = section;
  164 + }
  165 +
  166 + public int getLine() {
  167 + return line;
  168 + }
  169 +
  170 + public void setLine(int line) {
  171 + this.line = line;
  172 + }
  173 +}
src/main/resources/static/pages/base/geo_data_edit/css/mian.css
@@ -19,7 +19,7 @@ div#map_wrap{ @@ -19,7 +19,7 @@ div#map_wrap{
19 position: absolute; 19 position: absolute;
20 z-index: 999; 20 z-index: 999;
21 height: calc(100% - 20px); 21 height: calc(100% - 20px);
22 - width: 300px; 22 + width: 310px;
23 background: #fffffff5; 23 background: #fffffff5;
24 top: 7px; 24 top: 7px;
25 left: 5px; 25 left: 5px;
@@ -250,11 +250,11 @@ ul.uk-list.station_info_win&gt;li.s_name{ @@ -250,11 +250,11 @@ ul.uk-list.station_info_win&gt;li.s_name{
250 background: #91d9fa; 250 background: #91d9fa;
251 } 251 }
252 252
253 -.up_down_route_list li.ct_active.first_road_active{ 253 +.up_down_route_list li.ct_active.f_r_a{
254 background: #fff; 254 background: #fff;
255 } 255 }
256 256
257 -.up_down_route_list li.ct_active.first_road_active>a{ 257 +.up_down_route_list li.ct_active.f_r_a>a{
258 background: #91d9fa; 258 background: #91d9fa;
259 } 259 }
260 260
@@ -490,4 +490,68 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root { @@ -490,4 +490,68 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root {
490 background: #fff; 490 background: #fff;
491 height: 120px; 491 height: 120px;
492 box-shadow: 5px 5px 15px rgba(90, 90, 90, 0.48); 492 box-shadow: 5px 5px 15px rgba(90, 90, 90, 0.48);
  493 +}
  494 +
  495 +.road_li_transient .ul_li_input input:first-child{
  496 + width: 110px;
  497 + margin-left: 2px;
  498 +}
  499 +
  500 +.road_li_transient .ul_li_input input:nth-of-type(2){
  501 + width: 100px;
  502 + margin-left: 0;
  503 + font-size: 12px;
  504 +}
  505 +
  506 +.bks_list li.road_li_transient{
  507 + margin-left: -15px;
  508 +}
  509 +
  510 +.road_li_transient .search_point_icon_btn {
  511 + color: #FF9800;
  512 + margin-right: 5px;
  513 +}
  514 +
  515 +.road_li_transient .ul_li_input{
  516 + width: 100%;
  517 +
  518 +}
  519 +
  520 +.road_li_transient .ul_li_input input{
  521 + color: #c5862a;
  522 +}
  523 +
  524 +
  525 +.add_road_search_point_wrap{
  526 + width: 390px;
  527 + height: 120px;
  528 + position: absolute;
  529 + top: 10px;
  530 + left: calc(50% - 200px);
  531 + z-index: 999;
  532 + background: #ffface;
  533 + box-shadow: 5px 5px 15px rgba(90, 90, 90, 0.48);
  534 +}
  535 +
  536 +.add_road_search_point_wrap ._title {
  537 + text-align: center;
  538 + font-size: 17px;
  539 + color: #2b2b2b;
  540 + padding: 2px 0 0 0;
  541 + font-weight: 600;
  542 +}
  543 +
  544 +.add_road_search_point_wrap .buffer_edit_body .ct_row {
  545 + margin-top: 8px;
  546 +}
  547 +
  548 +.draw_polyline_switch{
  549 + display: inline-block;
  550 + font-size: 12px;
  551 + vertical-align: bottom;
  552 + margin-left: 5px;
  553 +}
  554 +
  555 +.draw_polyline_switch>a{
  556 + color: red;
493 } 557 }
494 \ No newline at end of file 558 \ No newline at end of file
src/main/resources/static/pages/base/geo_data_edit/fragments/f_road_route.html
@@ -2,19 +2,19 @@ @@ -2,19 +2,19 @@
2 <script id="geo_d_e_road_route-temp" type="text/html"> 2 <script id="geo_d_e_road_route-temp" type="text/html">
3 <ul class="uk-list"> 3 <ul class="uk-list">
4 {{each list as subArr i}} 4 {{each list as subArr i}}
5 - <li class="r_r_item first_road_active" > 5 + <li class="r_r_item f_r_a" data-id="{{subArr[0].id}}" data-code="{{subArr[0].sectionCode}}">
6 <a data-code="{{subArr[0].sectionCode}}" data-updown="{{subArr[0].directions}}">{{subArr[0].sectionName}}<span class="sub_name">{{subArr[0].crosesRoad}}</span></a> 6 <a data-code="{{subArr[0].sectionCode}}" data-updown="{{subArr[0].directions}}">{{subArr[0].sectionName}}<span class="sub_name">{{subArr[0].crosesRoad}}</span></a>
7 - 7 + <ul class="uk-list bks_list">
8 {{if subArr.length > 1}} 8 {{if subArr.length > 1}}
9 {{each subArr as obj j}} 9 {{each subArr as obj j}}
10 - <ul class="uk-list">  
11 {{if j > 0}} 10 {{if j > 0}}
12 - <li class="r_r_item"> 11 + <li class="r_r_item" data-id="{{obj.id}}" data-code="{{obj.sectionCode}}">
13 <a data-code="{{obj.sectionCode}}" data-updown="{{obj.directions}}">{{obj.sectionName}}<span class="sub_name">{{obj.crosesRoad}}</span></a></li> 12 <a data-code="{{obj.sectionCode}}" data-updown="{{obj.directions}}">{{obj.sectionName}}<span class="sub_name">{{obj.crosesRoad}}</span></a></li>
14 {{/if}} 13 {{/if}}
15 - </ul> 14 +
16 {{/each}} 15 {{/each}}
17 {{/if}} 16 {{/if}}
  17 + </ul>
18 </li> 18 </li>
19 {{/each}} 19 {{/each}}
20 </ul> 20 </ul>
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 57
58 <div class="ct_row"> 58 <div class="ct_row">
59 <div class="uk-inline" > 59 <div class="uk-inline" >
60 - <kbd>长度: <span></span> 米</kbd> 60 + <kbd>长度: <span>{{len}}</span> 米</kbd>
61 </div> 61 </div>
62 <div class="uk-inline btns"> 62 <div class="uk-inline btns">
63 <button class="uk-button uk-button-primary submit">确定</button> 63 <button class="uk-button uk-button-primary submit">确定</button>
@@ -68,4 +68,52 @@ @@ -68,4 +68,52 @@
68 </div> 68 </div>
69 </div> 69 </div>
70 </script> 70 </script>
  71 +
  72 + <script id="geo_d_e_add_road_panel-temp" type="text/html">
  73 + <li class="road_li_transient">
  74 + <div class="ul_li_input">
  75 + <form>
  76 + <input class="uk-input" value="{{sectionName}}" autocomplete="off" placeholder="路段名称" name="sectionName">
  77 + <input class="uk-input" value="{{crosesRoad}}" autocomplete="off" placeholder="交叉路" name="crosesRoad">
  78 + <span uk-icon="icon: location;ratio:.8" title="绘制路段" uk-tooltip class="search_point_icon_btn"></span>
  79 + <span uk-icon="icon: close;" title="取消" uk-tooltip class="cancel_icon_btn"></span>
  80 + </form>
  81 + </div>
  82 + </li>
  83 + </script>
  84 +
  85 +
  86 + <script id="geo_d_e_add_draw_polyline-temp" type="text/html">
  87 + <div class="add_road_search_point_wrap uk-animation-slide-top-small">
  88 + <div class="buffer_edit_body" >
  89 + <div class="_title">绘制 {{name}}({{cName}})</div>
  90 + <form>
  91 + <input type="hidden" value="{{id}}" name="id">
  92 + <input type="hidden" value="{{sectionCode}}" name="sectionCode">
  93 +
  94 + <div class="ct_row">
  95 + <div class="uk-inline">
  96 + <span class="uk-form-icon uk-form-icon-flip" >路段名</span>
  97 + <input class="uk-input" name="sectionName" type="text" value="{{name}}" >
  98 + </div>
  99 + <div class="uk-inline">
  100 + <span class="uk-form-icon uk-form-icon-flip" >交叉路</span>
  101 + <input class="uk-input" name="crosesRoad" type="text" value="{{cName}}" style="font-size: 13px;">
  102 + </div>
  103 + </div>
  104 +
  105 + <div class="ct_row">
  106 + <div class="uk-inline" >
  107 + <span class="draw_polyline_switch"><a>暂停绘制</a></span>
  108 + </div>
  109 +
  110 + <div class="uk-inline btns">
  111 + <button class="uk-button uk-button-primary submit">确定</button>
  112 + <button class="uk-button uk-button-default cancel">取消</button>
  113 + </div>
  114 + </div>
  115 + </form>
  116 + </div>
  117 + </div>
  118 + </script>
71 </div> 119 </div>
72 \ No newline at end of file 120 \ No newline at end of file
src/main/resources/static/pages/base/geo_data_edit/js/map.js
@@ -14,6 +14,16 @@ var gb_ct_map = function () { @@ -14,6 +14,16 @@ var gb_ct_map = function () {
14 } 14 }
15 }; 15 };
16 16
  17 + var styleOptions = {
  18 + strokeColor:"#E91E63", //边线颜色。
  19 + fillColor:"#E91E63", //填充颜色。当参数为空时,圆形将没有填充效果。
  20 + strokeWeight: 6, //边线的宽度,以像素为单位。
  21 + strokeOpacity: 0.8, //边线透明度,取值范围0 - 1。
  22 + fillOpacity: 0.6, //填充的透明度,取值范围0 - 1。
  23 + strokeStyle: 'solid' //边线的样式,solid或dashed。
  24 + }
  25 +
  26 +
17 /** 27 /**
18 * 地图状态 28 * 地图状态
19 * 1: 站点缓冲区编辑 29 * 1: 站点缓冲区编辑
@@ -443,7 +453,7 @@ var gb_ct_map = function () { @@ -443,7 +453,7 @@ var gb_ct_map = function () {
443 clearEditBuffer(); 453 clearEditBuffer();
444 454
445 if (v == 'd') { 455 if (v == 'd') {
446 - _drawingManager = new BMapLib.DrawingManager(map, {}); 456 + _drawingManager = new BMapLib.DrawingManager(map, {polygonOptions: styleOptions});
447 _drawingManager.open(); 457 _drawingManager.open();
448 _drawingManager.enableCalculate(); 458 _drawingManager.enableCalculate();
449 _drawingManager.setDrawingMode('polygon'); 459 _drawingManager.setDrawingMode('polygon');
@@ -528,6 +538,50 @@ var gb_ct_map = function () { @@ -528,6 +538,50 @@ var gb_ct_map = function () {
528 }; 538 };
529 539
530 /** 540 /**
  541 + * 绘制新增路段
  542 + * @param name
  543 + */
  544 + var showAddRoadPanel = function (name, cName) {
  545 + map_status = 1;
  546 +
  547 + var point;
  548 + var pId = gb_road_route.getAddPrevId();
  549 + if(pId){
  550 + //从上一个路段继续绘制
  551 + var prev = gb_road_route.getRoadById(pId),
  552 + coords = prev.bdCoords,
  553 + lastCoord = coords[coords.length-1].split(' ');
  554 +
  555 + point = new BMap.Point(lastCoord[0], lastCoord[1]);
  556 + }
  557 +
  558 + map.centerAndZoom(point, 18);
  559 +
  560 + //开启鼠标绘制
  561 + _drawingManager = new BMapLib.DrawingManager(map, {
  562 + polylineOptions: styleOptions
  563 + });
  564 +
  565 + _drawingManager.open();
  566 + //_drawingManager.enableCalculate();
  567 + _drawingManager.setDrawingMode('polyline');
  568 +
  569 + //绘制完成
  570 + _drawingManager.addEventListener('polylinecomplete', function (e) {
  571 + console.log('eee', e, e.getPath());
  572 + _drawingManager.close();
  573 +
  574 + var polyline = new BMap.Polyline(e.getPath(), {strokeWeight: 7, strokeColor: '#E91E63', strokeOpacity: .7});
  575 +
  576 + map.removeOverlay(e);
  577 + map.addOverlay(polyline);
  578 + polyline.enableEditing();
  579 +
  580 + editPolyline = polyline;
  581 + });
  582 + };
  583 +
  584 + /**
531 * 为新增的站点选择一个位置 585 * 为新增的站点选择一个位置
532 */ 586 */
533 var showAddPointPanel = function (name) { 587 var showAddPointPanel = function (name) {
@@ -592,7 +646,6 @@ var gb_ct_map = function () { @@ -592,7 +646,6 @@ var gb_ct_map = function () {
592 * 拾取坐标点位 646 * 拾取坐标点位
593 */ 647 */
594 var pickupPoint = function (e) { 648 var pickupPoint = function (e) {
595 - console.log('pickupPointpickupPoint', e);  
596 var point = e.point; 649 var point = e.point;
597 650
598 a_s_p_maeker.setPosition(point); 651 a_s_p_maeker.setPosition(point);
@@ -645,6 +698,21 @@ var gb_ct_map = function () { @@ -645,6 +698,21 @@ var gb_ct_map = function () {
645 _renderStationMarket(gb_station_route.getData()[upDown]); 698 _renderStationMarket(gb_station_route.getData()[upDown]);
646 }; 699 };
647 700
  701 + /**
  702 + * 重绘一个走向的路段
  703 + * @param upDown
  704 + */
  705 + var reDrawRoad = function (upDown) {
  706 + $.each(roadPolylines[upDown], function () {
  707 + map.removeOverlay(this);
  708 + });
  709 + roadPolylines[upDown] = [];
  710 +
  711 + clearOtherOverlay();
  712 +
  713 + _renderPolyline(gb_road_route.getData()[upDown], updownColor(upDown));
  714 + };
  715 +
648 716
649 /** 717 /**
650 * 进入路段编辑模式 718 * 进入路段编辑模式
@@ -669,8 +737,8 @@ var gb_ct_map = function () { @@ -669,8 +737,8 @@ var gb_ct_map = function () {
669 polyline.enableEditing(); 737 polyline.enableEditing();
670 738
671 //lineupdate,计算长度 mouseup 739 //lineupdate,计算长度 mouseup
672 - gb_road_route.showPathLength(geolib.getPathLength(polyline.getPath()));  
673 polyline.addEventListener('lineupdate', reCalcPathLength); 740 polyline.addEventListener('lineupdate', reCalcPathLength);
  741 + //gb_road_route.showPathLength(geolib.getPathLength(polyline.getPath()));
674 } 742 }
675 743
676 /** 744 /**
@@ -703,6 +771,7 @@ var gb_ct_map = function () { @@ -703,6 +771,7 @@ var gb_ct_map = function () {
703 $('.road_edit_panel').remove(); 771 $('.road_edit_panel').remove();
704 772
705 editPolyline.removeEventListener('lineupdate', reCalcPathLength); 773 editPolyline.removeEventListener('lineupdate', reCalcPathLength);
  774 + editPolyline = null;
706 775
707 //polyline 776 //polyline
708 var polyline = getRoadPolyline(road.sectionCode, road.directions); 777 var polyline = getRoadPolyline(road.sectionCode, road.directions);
@@ -741,7 +810,9 @@ var gb_ct_map = function () { @@ -741,7 +810,9 @@ var gb_ct_map = function () {
741 map.enableDoubleClickZoom(); 810 map.enableDoubleClickZoom();
742 }, 811 },
743 reDrawStation: reDrawStation, 812 reDrawStation: reDrawStation,
  813 + reDrawRoad: reDrawRoad,
744 edit_road: start_edit_road, 814 edit_road: start_edit_road,
745 - exitEditRoadStatus: exitEditRoadStatus 815 + exitEditRoadStatus: exitEditRoadStatus,
  816 + showAddRoadPanel: showAddRoadPanel
746 }; 817 };
747 }(); 818 }();
748 \ No newline at end of file 819 \ No newline at end of file
src/main/resources/static/pages/base/geo_data_edit/js/road_route.js
@@ -28,10 +28,12 @@ var gb_road_route = function () { @@ -28,10 +28,12 @@ var gb_road_route = function () {
28 rs.list.sort(function (a, b) { 28 rs.list.sort(function (a, b) {
29 return parseInt(a.sectionrouteCode) - parseInt(b.sectionrouteCode); 29 return parseInt(a.sectionrouteCode) - parseInt(b.sectionrouteCode);
30 }); 30 });
31 - //计算路段中心点  
32 - //var cp = calcCenterPoint(p.ct_data.bdCoords); 31 +
  32 + var _pos;
33 $.each(rs.list, function () { 33 $.each(rs.list, function () {
34 - this.cp = calcCenterPoint(this.bdCoords); 34 + _pos = cv_points(this.bdCoords);
  35 + this.cp = geolib.getCenter(_pos);
  36 + this.len = geolib.getPathLength(_pos);
35 }); 37 });
36 ep.emit('data', gb_common.groupBy(rs.list, 'directions')); 38 ep.emit('data', gb_common.groupBy(rs.list, 'directions'));
37 }); 39 });
@@ -101,19 +103,91 @@ var gb_road_route = function () { @@ -101,19 +103,91 @@ var gb_road_route = function () {
101 var edit_road = function (road) { 103 var edit_road = function (road) {
102 $('.main_left_panel_m_layer').show(); 104 $('.main_left_panel_m_layer').show();
103 //弹出编辑面板 105 //弹出编辑面板
104 - var $editPanel = temps['geo_d_e_road_edit_panel-temp'](road); 106 + var $editPanel = $(temps['geo_d_e_road_edit_panel-temp'](road));
105 $('body').append($editPanel); 107 $('body').append($editPanel);
106 108
107 gb_ct_map.edit_road(road); 109 gb_ct_map.edit_road(road);
  110 +
  111 + /**
  112 + * 点击取消
  113 + */
  114 + $('button.cancel', $editPanel).on('click', function () {
  115 + $('.main_left_panel_m_layer').hide();
  116 + $(this).parents('.buffer_edit_body').parent().remove();
  117 + gb_ct_map.resetMapStatus();
  118 + //debugger
  119 + gb_ct_map.exitEditRoadStatus(road);
  120 + });
108 }; 121 };
109 122
110 var showPathLength = function (len) { 123 var showPathLength = function (len) {
111 $('.road_edit_panel kbd>span').text(len); 124 $('.road_edit_panel kbd>span').text(len);
112 }; 125 };
113 126
  127 + var addPrevId;//添加路段路由的上一个路由ID
  128 + var insert_road_before = function (road) {
  129 + //在之前插入路段
  130 + var cell = getRoadLI(road);
  131 +
  132 + var addCell = $(temps['geo_d_e_add_road_panel-temp'](road));
  133 +
  134 + cell.before(addCell);
  135 +
  136 + add_road(addCell);
  137 + };
  138 +
  139 + var add_road = function (cell) {
  140 + gb_ct_map.closeInfoWin();
  141 + //焦点
  142 + var $nameInput = $('input[name=sectionName]', cell);
  143 + $nameInput.focus();
  144 +
  145 + //取消
  146 + $('.cancel_icon_btn', cell).on('click', function () {
  147 + cell.remove();
  148 + });
  149 +
  150 + //选择地图位置
  151 + $('.search_point_icon_btn', cell).on('click', function () {
  152 + $('.station_li_transient').removeClass('_search_point');
  153 + $(this).parents('.station_li_transient').addClass('_search_point');
  154 + var name = $nameInput.val();
  155 + if(!name)
  156 + return UIkit.notification("你必须输入路段名称!", {status: 'danger'});
  157 +
  158 + $('.main_left_panel_m_layer').show();
  159 + //gb_ct_map.showAddRoadPanel(name, $('input[name=crosesRoad]',cell).val());
  160 + showDrawPanel(name, $('input[name=crosesRoad]',cell).val());
  161 + });
  162 + //监听回车事件
  163 + $('[name=sectionName]', cell).on('keydown', function (e) {
  164 + if(event.keyCode == "13")
  165 + $('.search_point_icon_btn', cell).trigger('click');
  166 + });
  167 +
  168 + //上一个路段的ID
  169 + var $prev = cell.prev('.r_r_item');
  170 + if($prev.length > 0)
  171 + addPrevId = $prev.data('id');
  172 + else{
  173 + if(cell.parent().hasClass('bks_list'))
  174 + addPrevId = cell.parents('.r_r_item').data('id');
  175 + else
  176 + addPrevId = -1;
  177 + }
  178 + };
  179 +
  180 + var getRoadLI = function (r) {
  181 + return $('.up_down_route_list>li:eq('+r.directions+')>.road_route .r_r_item[data-code='+r.sectionCode+']');
  182 + };
  183 +
114 var realEditRoad; 184 var realEditRoad;
115 var callbackHandler = { 185 var callbackHandler = {
116 - edit: edit_road 186 + edit: edit_road,
  187 + insert_before: insert_road_before,
  188 + destroy: function (road) {
  189 + gb_data_submit.destroyRoad(road);
  190 + }
117 }; 191 };
118 //$('.up_down_route_list>li>.road_route .r_r_item a[data-code='+data.sectionCode+']') 192 //$('.up_down_route_list>li>.road_route .r_r_item a[data-code='+data.sectionCode+']')
119 $.contextMenu({ 193 $.contextMenu({
@@ -154,18 +228,19 @@ var gb_road_route = function () { @@ -154,18 +228,19 @@ var gb_road_route = function () {
154 return null; 228 return null;
155 }; 229 };
156 230
157 - var calcCenterPoint = function (coords) { 231 + var cv_points = function (coords) {
158 var array = [], strs; 232 var array = [], strs;
159 for (var i = 0, item; item = coords[i++];) { 233 for (var i = 0, item; item = coords[i++];) {
160 strs = item.split(' '); 234 strs = item.split(' ');
161 array.push({latitude: strs[1], longitude: strs[0]}); 235 array.push({latitude: strs[1], longitude: strs[0]});
162 } 236 }
163 -  
164 - return geolib.getCenter(array);  
165 - }; 237 + return array;
  238 + }
166 239
167 var update = function (road) { 240 var update = function (road) {
168 - road.cp = calcCenterPoint(road.bdCoords); 241 + var _pos = cv_points(this.bdCoords);
  242 + road.cp = geolib.getCenter(_pos);
  243 + road.len = geolib.getPathLength(_pos);
169 var array = road_maps[road.directions]; 244 var array = road_maps[road.directions];
170 for(var i=0,item; item=array[i++];){ 245 for(var i=0,item; item=array[i++];){
171 if(item.sectionCode==road.sectionCode){ 246 if(item.sectionCode==road.sectionCode){
@@ -178,6 +253,61 @@ var gb_road_route = function () { @@ -178,6 +253,61 @@ var gb_road_route = function () {
178 var htmlStr = temps['geo_d_e_road_route-temp']({list: _group(array)}); 253 var htmlStr = temps['geo_d_e_road_route-temp']({list: _group(array)});
179 $('.up_down_route_list>li:'+(road.directions==0?'first':'last')+'>.road_route').html(htmlStr); 254 $('.up_down_route_list>li:'+(road.directions==0?'first':'last')+'>.road_route').html(htmlStr);
180 }; 255 };
  256 +
  257 + var destroyEnd = function (list, road) {
  258 + list.sort(function (a, b) {
  259 + return parseInt(a.sectionrouteCode) - parseInt(b.sectionrouteCode);
  260 + });
  261 +
  262 + var _pos;
  263 + $.each(list, function () {
  264 + _pos = cv_points(this.bdCoords);
  265 + this.cp = geolib.getCenter(_pos);
  266 + this.len = geolib.getPathLength(_pos);
  267 + });
  268 +
  269 + road_maps[road.directions] = list;
  270 + //重新渲染
  271 + var htmlStr = temps['geo_d_e_road_route-temp']({list: _group(list)});
  272 + $('.up_down_route_list>li:'+(road.directions==0?'first':'last')+'>.road_route').html(htmlStr);
  273 +
  274 + gb_ct_map.reDrawRoad(road.directions);
  275 + };
  276 +
  277 + /**
  278 + * 根据ID获取路段
  279 + * @param id
  280 + */
  281 + var getRoadById = function (id) {
  282 + for(var i=0,s;s=road_maps[0][i++];){
  283 + if(s.id == id)
  284 + return s;
  285 + }
  286 + for(var i=0,s;s=road_maps[1][i++];){
  287 + if(s.id == id)
  288 + return s;
  289 + }
  290 + return null;
  291 + };
  292 +
  293 + var showDrawPanel = function (name, cName) {
  294 + var spp = $(temps['geo_d_e_add_draw_polyline-temp']({name: name, cName: cName}));
  295 + $('body').append(spp);
  296 + //暂停和开始绘制
  297 + $('.draw_polyline_switch>a', spp).on('click', function () {
  298 + var t = $(this).text();
  299 + if(t=='暂停绘制'){
  300 + gb_ct_map.exitDrawStatus();
  301 + $(this).text('开始绘制');
  302 + }
  303 + else{
  304 + gb_ct_map.openDrawStatus();
  305 + $(this).text('暂停绘制');
  306 + }
  307 + });
  308 +
  309 + gb_ct_map.showAddRoadPanel(name, cName);
  310 + };
181 311
182 res_load_ep.emitLater('load_road_route'); 312 res_load_ep.emitLater('load_road_route');
183 return { 313 return {
@@ -190,6 +320,11 @@ var gb_road_route = function () { @@ -190,6 +320,11 @@ var gb_road_route = function () {
190 clearFocus: clearFocus, 320 clearFocus: clearFocus,
191 focus: focus, 321 focus: focus,
192 showPathLength: showPathLength, 322 showPathLength: showPathLength,
193 - update: update 323 + update: update,
  324 + destroyEnd: destroyEnd,
  325 + getRoadById: getRoadById,
  326 + getAddPrevId: function () {
  327 + return addPrevId;
  328 + }
194 }; 329 };
195 }(); 330 }();
196 \ No newline at end of file 331 \ No newline at end of file
src/main/resources/static/pages/base/geo_data_edit/js/station_route.js
@@ -109,6 +109,14 @@ var gb_station_route = function () { @@ -109,6 +109,14 @@ var gb_station_route = function () {
109 add_station(addCell); 109 add_station(addCell);
110 }; 110 };
111 111
  112 +
  113 + //添加站点 取消按钮
  114 + $(document).on('click', '.add_station_search_point_wrap button.cancel', function () {
  115 + $('.main_left_panel_m_layer').hide();
  116 + $(this).parents('.buffer_edit_body').parent().remove();
  117 + gb_ct_map.resetMapStatus();
  118 + });
  119 +
112 var add_station = function (addCell) { 120 var add_station = function (addCell) {
113 gb_ct_map.closeInfoWin(); 121 gb_ct_map.closeInfoWin();
114 //焦点 122 //焦点
@@ -218,6 +226,72 @@ var gb_station_route = function () { @@ -218,6 +226,72 @@ var gb_station_route = function () {
218 var htmlStr = temps['geo_d_e_map_edit_buffer_panel-temp'](s); 226 var htmlStr = temps['geo_d_e_map_edit_buffer_panel-temp'](s);
219 $('.ct_page').append(htmlStr); 227 $('.ct_page').append(htmlStr);
220 $('.buffer_edit_panel').show(); 228 $('.buffer_edit_panel').show();
  229 +
  230 + //缓冲区编辑 取消
  231 + $('button.cancel', $editWrap).on('click', function (e) {
  232 + $('.main_left_panel_m_layer').hide();
  233 + $(this).parents('.buffer_edit_body').parent().remove();
  234 + gb_ct_map.resetMapStatus();
  235 +
  236 + var f = $(this).parents('form');
  237 + var data = f.serializeJSON();
  238 +
  239 + gb_ct_map.exitEditBufferStatus(data);
  240 + });
  241 +
  242 + var $editWrap = '.buffer_edit_panel>.buffer_edit_body';
  243 +
  244 + //缓冲区编辑 切换缓冲区类型(圆形,多边形)
  245 + $('select[name=shapesType]', $editWrap).on('change', function (e) {
  246 + var v = $(this).val();
  247 + if(v=='d'){
  248 + $('.buffer_edit_panel .shapes_type').addClass('st_d');
  249 + }
  250 + else{
  251 + $('.buffer_edit_panel .shapes_type').removeClass('st_d');
  252 + $('input[name=radius]', $editWrap).val(80);
  253 + }
  254 + gb_ct_map.changeShapeType(v);
  255 + });
  256 +
  257 + //半径修改
  258 + var update_radius_flag, update_radius;
  259 + $('input[name=radius]', $editWrap).on('input', function (e) {
  260 + update_radius = $(this).val();
  261 + if(update_radius_flag){
  262 + return;
  263 + }
  264 + update_radius_flag = true;
  265 + setTimeout(function () {
  266 + gb_ct_map.updateDragRadius(update_radius);
  267 + update_radius_flag = false;
  268 + }, 180);
  269 + });
  270 +
  271 + //缓冲区编辑 切换绘制模式
  272 + $('.draw_polygon_switch', $editWrap).on('input', function (e) {
  273 + var type = $(this).data('type');
  274 + if(type==1){
  275 + //退出绘制状态
  276 + gb_ct_map.exitDrawStatus();
  277 + $(this).data('type', 0).find('a').text('开始绘制');
  278 + }
  279 + else if(type==0 || type==2){
  280 + gb_ct_map.openDrawStatus();
  281 + $(this).data('type', 1).find('a').text('暂停绘制');
  282 + }
  283 + else if(type==3){
  284 + gb_ct_map.changeShapeType('d');
  285 + $(this).data('type', 1).find('a').text('暂停绘制');
  286 + }
  287 + });
  288 + };
  289 +
  290 + /**
  291 + * 绘制结束
  292 + */
  293 + var drawEnd = function () {
  294 + $('.buffer_edit_panel>.buffer_edit_body .draw_polygon_switch').data('type', 2).find('a').text('重新绘制');
221 }; 295 };
222 296
223 var edPanelRunFlag; 297 var edPanelRunFlag;
@@ -264,82 +338,11 @@ var gb_station_route = function () { @@ -264,82 +338,11 @@ var gb_station_route = function () {
264 }; 338 };
265 339
266 //取消按钮 340 //取消按钮
267 - $(document).on('click','.buffer_edit_body button.cancel', function (e) { 341 +/* $(document).on('click','.buffer_edit_body button.cancel', function (e) {
268 $('.main_left_panel_m_layer').hide(); 342 $('.main_left_panel_m_layer').hide();
269 $(this).parents('.buffer_edit_body').parent().remove(); 343 $(this).parents('.buffer_edit_body').parent().remove();
270 gb_ct_map.resetMapStatus(); 344 gb_ct_map.resetMapStatus();
271 - });  
272 -  
273 -  
274 - var $editWrap = '.buffer_edit_panel>.buffer_edit_body';  
275 - /**  
276 - * 缓冲区编辑 取消  
277 - */  
278 - $(document).on('click', $editWrap + ' button.cancel', function (e) {  
279 - var f = $(this).parents('form');  
280 - var data = f.serializeJSON();  
281 -  
282 - gb_ct_map.exitEditBufferStatus(data);  
283 - });  
284 -  
285 - /**  
286 - * 缓冲区编辑 切换缓冲区类型(圆形,多边形)  
287 - */  
288 - $(document).on('change', $editWrap +' select[name=shapesType]', function (e) {  
289 - var v = $(this).val();  
290 - if(v=='d'){  
291 - $('.buffer_edit_panel .shapes_type').addClass('st_d');  
292 - }  
293 - else{  
294 - $('.buffer_edit_panel .shapes_type').removeClass('st_d');  
295 - $('input[name=radius]', $editWrap).val(80);  
296 - }  
297 - gb_ct_map.changeShapeType(v);  
298 - });  
299 -  
300 - /**  
301 - * 半径修改  
302 - */  
303 - var update_radius_flag, update_radius;  
304 - $(document).on('input', $editWrap +' input[name=radius]', function (e) {  
305 - update_radius = $(this).val();  
306 - if(update_radius_flag){  
307 - return;  
308 - }  
309 - update_radius_flag = true;  
310 - setTimeout(function () {  
311 - gb_ct_map.updateDragRadius(update_radius);  
312 - update_radius_flag = false;  
313 - }, 180);  
314 - });  
315 -  
316 - /**  
317 - * 缓冲区编辑 切换绘制模式  
318 - */  
319 - var drawPolygonSwitch = $editWrap +' .draw_polygon_switch';  
320 - $(document).on('click', drawPolygonSwitch, function (e) {  
321 - var type = $(this).data('type');  
322 - if(type==1){  
323 - //退出绘制状态  
324 - gb_ct_map.exitDrawStatus();  
325 - $(this).data('type', 0).find('a').text('开始绘制');  
326 - }  
327 - else if(type==0 || type==2){  
328 - gb_ct_map.openDrawStatus();  
329 - $(this).data('type', 1).find('a').text('暂停绘制');  
330 - }  
331 - else if(type==3){  
332 - gb_ct_map.changeShapeType('d');  
333 - $(this).data('type', 1).find('a').text('暂停绘制');  
334 - }  
335 - });  
336 -  
337 - /**  
338 - * 绘制结束  
339 - */  
340 - var drawEnd = function () {  
341 - $(drawPolygonSwitch).data('type', 2).find('a').text('重新绘制');  
342 - }; 345 + });*/
343 346
344 347
345 var spcPanelRunFlag; 348 var spcPanelRunFlag;
src/main/resources/static/pages/base/geo_data_edit/js/submit.js
@@ -78,6 +78,7 @@ var gb_data_submit = function () { @@ -78,6 +78,7 @@ var gb_data_submit = function () {
78 78
79 delete data.gLonx; 79 delete data.gLonx;
80 delete data.gLaty; 80 delete data.gLaty;
  81 + show_run_text('正在提交数据...');
81 //添加 82 //添加
82 gb_common.$post('/_geo_data/addNewStationRoute', data, function (rs) { 83 gb_common.$post('/_geo_data/addNewStationRoute', data, function (rs) {
83 gb_station_route.addEnd(rs.list, rs.newStationRouteCode); 84 gb_station_route.addEnd(rs.list, rs.newStationRouteCode);
@@ -90,6 +91,41 @@ var gb_data_submit = function () { @@ -90,6 +91,41 @@ var gb_data_submit = function () {
90 }); 91 });
91 92
92 /** 93 /**
  94 + * 新增路段提交
  95 + */
  96 + $(document).on('click', '.add_road_search_point_wrap .buffer_edit_body button.submit', function (e) {
  97 + var f = $(this).parents('form');
  98 + var data = f.serializeJSON();
  99 +
  100 + UIkit.modal.confirm('确定新增路段【'+data.sectionName+'('+data.crosesRoad+')】?').then(function() {
  101 + data.lineCode = storage.getItem('geo_data_edit_line_code');
  102 + data.versions = storage.getItem('geo_data_edit_line_version');
  103 + data.upDown = getUpDown();
  104 +
  105 + data.prevRouteId = gb_road_route.getAddPrevId();
  106 +
  107 + var polyline = gb_ct_map.getDrawPolyline();
  108 + var pos = polyline.getPath();
  109 + var gsectionVector = '';
  110 + for(var i=0,p;p=pos[i++];){
  111 + gsectionVector += (p.lng + " " + p.lat + ",");
  112 + }
  113 + data.coords = gsectionVector.substr(0, gsectionVector.length - 1);
  114 +
  115 + console.log('road data', data);
  116 +
  117 + show_run_text('正在提交数据...');
  118 + //添加
  119 + gb_common.$post('/_geo_data/addNewRoadRoute', data, function (rs) {
  120 +
  121 + hide_run_text();
  122 + UIkit.notification("添加成功!", {status: 'success'});
  123 + });
  124 + });
  125 + return false;
  126 + });
  127 +
  128 + /**
93 * 路段编辑提交 129 * 路段编辑提交
94 */ 130 */
95 $(document).on('click', '.road_edit_panel .buffer_edit_body button.submit', function (e) { 131 $(document).on('click', '.road_edit_panel .buffer_edit_body button.submit', function (e) {
@@ -145,10 +181,31 @@ var gb_data_submit = function () { @@ -145,10 +181,31 @@ var gb_data_submit = function () {
145 }); 181 });
146 } 182 }
147 183
  184 + /**
  185 + * 撤销路段
  186 + * @param road
  187 + */
  188 + var destroyRoad = function (road) {
  189 + UIkit.modal.confirm('确定撤销路段【'+road.sectionName+'】?').then(function() {
  190 + show_run_text('正在撤销...');
  191 + console.log('road', road);
  192 +
  193 + delete road.bdCoords;
  194 + delete road.cp;
  195 + gb_common.$post("/_geo_data/destroyRoad", road, function (rs) {
  196 +
  197 + gb_road_route.destroyEnd(rs.list, road);
  198 + hide_run_text();
  199 + UIkit.notification("撤销成功!", {status: 'success'});
  200 + });
  201 + });
  202 + };
  203 +
148 function getUpDown(){ 204 function getUpDown(){
149 return $('._route_info_wrap>ul>li:first').hasClass('uk-active')?0:1; 205 return $('._route_info_wrap>ul>li:first').hasClass('uk-active')?0:1;
150 } 206 }
151 return { 207 return {
152 - destroyStation: destroyStation 208 + destroyStation: destroyStation,
  209 + destroyRoad: destroyRoad
153 }; 210 };
154 }(); 211 }();
155 \ No newline at end of file 212 \ No newline at end of file