Commit ce14e4e11861000b2d7f330a6d833850a862858f
1 parent
e3b04d2f
update...
Showing
9 changed files
with
279 additions
and
31 deletions
src/main/java/com/bsth/controller/geo_data/GeoDataController.java
| 1 | package com.bsth.controller.geo_data; | 1 | package com.bsth.controller.geo_data; |
| 2 | 2 | ||
| 3 | +import com.bsth.entity.geo_data.GeoRoad; | ||
| 3 | import com.bsth.entity.geo_data.GeoStation; | 4 | import com.bsth.entity.geo_data.GeoStation; |
| 4 | import com.bsth.service.geo_data.GeoDataService; | 5 | import com.bsth.service.geo_data.GeoDataService; |
| 5 | import org.springframework.beans.factory.annotation.Autowired; | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -51,4 +52,9 @@ public class GeoDataController { | @@ -51,4 +52,9 @@ public class GeoDataController { | ||
| 51 | public Map<String, Object> destroyStation(GeoStation station){ | 52 | public Map<String, Object> destroyStation(GeoStation station){ |
| 52 | return geoDataService.destroyStation(station); | 53 | return geoDataService.destroyStation(station); |
| 53 | } | 54 | } |
| 55 | + | ||
| 56 | + @RequestMapping(value = "updateRoadInfo",method = RequestMethod.POST) | ||
| 57 | + public Map<String, Object> updateRoadInfo(GeoRoad road){ | ||
| 58 | + return geoDataService.updateRoadInfo(road); | ||
| 59 | + } | ||
| 54 | } | 60 | } |
| 55 | \ No newline at end of file | 61 | \ No newline at end of file |
src/main/java/com/bsth/service/geo_data/GeoDataService.java
| 1 | package com.bsth.service.geo_data; | 1 | package com.bsth.service.geo_data; |
| 2 | 2 | ||
| 3 | +import com.bsth.entity.geo_data.GeoRoad; | ||
| 3 | import com.bsth.entity.geo_data.GeoStation; | 4 | import com.bsth.entity.geo_data.GeoStation; |
| 4 | 5 | ||
| 5 | import java.util.Map; | 6 | import java.util.Map; |
| @@ -22,4 +23,6 @@ public interface GeoDataService { | @@ -22,4 +23,6 @@ public interface GeoDataService { | ||
| 22 | Map<String,Object> addNewStationRoute(String lineCode, int upDown,int versions, String stationName, Float lat, Float lng, int prevRouteId); | 23 | Map<String,Object> addNewStationRoute(String lineCode, int upDown,int versions, String stationName, Float lat, Float lng, int prevRouteId); |
| 23 | 24 | ||
| 24 | Map<String,Object> destroyStation(GeoStation station); | 25 | Map<String,Object> destroyStation(GeoStation station); |
| 26 | + | ||
| 27 | + Map<String,Object> updateRoadInfo(GeoRoad road); | ||
| 25 | } | 28 | } |
src/main/java/com/bsth/service/geo_data/impl/GeoDataServiceImpl.java
| @@ -334,6 +334,32 @@ public class GeoDataServiceImpl implements GeoDataService { | @@ -334,6 +334,32 @@ public class GeoDataServiceImpl implements GeoDataService { | ||
| 334 | return rs; | 334 | return rs; |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | + @Override | ||
| 338 | + public Map<String, Object> updateRoadInfo(GeoRoad road) { | ||
| 339 | + Map<String, Object> rs = new HashMap<>(); | ||
| 340 | + | ||
| 341 | + try { | ||
| 342 | + //坐标转换 | ||
| 343 | + String bdPolyline = "LINESTRING(" + road.getGsectionVector() + ")"; | ||
| 344 | + String wgsPolyline = "LINESTRING(" + bdPolygon2Wgs(road.getGsectionVector()) + ")"; | ||
| 345 | + | ||
| 346 | + String sql = "update bsth_c_section set section_name=?, croses_road=?, bsection_vector=ST_GeomFromText('" + bdPolyline + "'),gsection_vector=ST_GeomFromText('" + wgsPolyline + "'),update_date=sysdate() where section_code=?"; | ||
| 347 | + | ||
| 348 | + int rsCount = jdbcTemplate.update(sql, road.getSectionName(), road.getCrosesRoad(), road.getSectionCode()); | ||
| 349 | + | ||
| 350 | + //从数据库里重新查询对象 | ||
| 351 | + if (rsCount > 0) { | ||
| 352 | + rs.put("road", findOneRoad(road.getId())); | ||
| 353 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 354 | + } | ||
| 355 | + } catch (Exception e) { | ||
| 356 | + logger.error("", e); | ||
| 357 | + rs.put("status", ResponseCode.ERROR); | ||
| 358 | + rs.put("msg", "服务器出现异常"); | ||
| 359 | + } | ||
| 360 | + return rs; | ||
| 361 | + } | ||
| 362 | + | ||
| 337 | 363 | ||
| 338 | /** | 364 | /** |
| 339 | * 根据路由ID 获取站点 | 365 | * 根据路由ID 获取站点 |
| @@ -352,6 +378,16 @@ public class GeoDataServiceImpl implements GeoDataService { | @@ -352,6 +378,16 @@ public class GeoDataServiceImpl implements GeoDataService { | ||
| 352 | return s; | 378 | return s; |
| 353 | } | 379 | } |
| 354 | 380 | ||
| 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"; | ||
| 383 | + List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class)); | ||
| 384 | + | ||
| 385 | + for (GeoRoad road : list) { | ||
| 386 | + road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2)); | ||
| 387 | + } | ||
| 388 | + return list.size() > 0 ?list.get(0):null; | ||
| 389 | + } | ||
| 390 | + | ||
| 355 | private String bdPolygon2Wgs(String bdPolygon) { | 391 | private String bdPolygon2Wgs(String bdPolygon) { |
| 356 | StringBuilder wgsPolygon = new StringBuilder(); | 392 | StringBuilder wgsPolygon = new StringBuilder(); |
| 357 | List<String> list = Splitter.on(",").splitToList(bdPolygon); | 393 | List<String> list = Splitter.on(",").splitToList(bdPolygon); |
src/main/resources/static/pages/base/geo_data_edit/css/mian.css
| @@ -479,4 +479,15 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root { | @@ -479,4 +479,15 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root { | ||
| 479 | 479 | ||
| 480 | .add_station_search_point_wrap .buffer_edit_body .ct_row { | 480 | .add_station_search_point_wrap .buffer_edit_body .ct_row { |
| 481 | margin-top: 8px; | 481 | margin-top: 8px; |
| 482 | +} | ||
| 483 | + | ||
| 484 | +.road_edit_panel{ | ||
| 485 | + position: absolute; | ||
| 486 | + z-index: 999; | ||
| 487 | + top: 10px; | ||
| 488 | + left: calc(50% - 190px); | ||
| 489 | + width: 380px; | ||
| 490 | + background: #fff; | ||
| 491 | + height: 120px; | ||
| 492 | + box-shadow: 5px 5px 15px rgba(90, 90, 90, 0.48); | ||
| 482 | } | 493 | } |
| 483 | \ No newline at end of file | 494 | \ No newline at end of file |
src/main/resources/static/pages/base/geo_data_edit/fragments/f_road_route.html
| @@ -35,4 +35,37 @@ | @@ -35,4 +35,37 @@ | ||
| 35 | </li> | 35 | </li> |
| 36 | </ul> | 36 | </ul> |
| 37 | </script> | 37 | </script> |
| 38 | + | ||
| 39 | + <script id="geo_d_e_road_edit_panel-temp" type="text/html"> | ||
| 40 | + <div class="road_edit_panel uk-animation-slide-top-small"> | ||
| 41 | + <div class="buffer_edit_body" > | ||
| 42 | + <h6 class="name">{{sectionName}} (路段编辑)</h6> | ||
| 43 | + <form> | ||
| 44 | + <input type="hidden" value="{{id}}" name="id"> | ||
| 45 | + <input type="hidden" value="{{sectionCode}}" name="sectionCode"> | ||
| 46 | + | ||
| 47 | + <div class="ct_row"> | ||
| 48 | + <div class="uk-inline"> | ||
| 49 | + <span class="uk-form-icon uk-form-icon-flip" >路段名</span> | ||
| 50 | + <input class="uk-input" name="sectionName" type="text" value="{{sectionName}}" > | ||
| 51 | + </div> | ||
| 52 | + <div class="uk-inline"> | ||
| 53 | + <span class="uk-form-icon uk-form-icon-flip" >交叉路</span> | ||
| 54 | + <input class="uk-input" name="crosesRoad" type="text" value="{{crosesRoad}}" style="font-size: 13px;"> | ||
| 55 | + </div> | ||
| 56 | + </div> | ||
| 57 | + | ||
| 58 | + <div class="ct_row"> | ||
| 59 | + <div class="uk-inline" > | ||
| 60 | + <kbd>长度: <span></span> 米</kbd> | ||
| 61 | + </div> | ||
| 62 | + <div class="uk-inline btns"> | ||
| 63 | + <button class="uk-button uk-button-primary submit">确定</button> | ||
| 64 | + <button class="uk-button uk-button-default cancel">取消</button> | ||
| 65 | + </div> | ||
| 66 | + </div> | ||
| 67 | + </form> | ||
| 68 | + </div> | ||
| 69 | + </div> | ||
| 70 | + </script> | ||
| 38 | </div> | 71 | </div> |
| 39 | \ No newline at end of file | 72 | \ No newline at end of file |
src/main/resources/static/pages/base/geo_data_edit/js/map.js
| @@ -103,11 +103,12 @@ var gb_ct_map = function () { | @@ -103,11 +103,12 @@ var gb_ct_map = function () { | ||
| 103 | map.addOverlay(polyline); | 103 | map.addOverlay(polyline); |
| 104 | 104 | ||
| 105 | polyline.addEventListener('mouseover', function () { | 105 | polyline.addEventListener('mouseover', function () { |
| 106 | - this.setStrokeColor('#20bd26'); | 106 | + if (map_status != 1) |
| 107 | + this.setStrokeColor('#20bd26'); | ||
| 107 | }); | 108 | }); |
| 108 | polyline.addEventListener('mouseout', function () { | 109 | polyline.addEventListener('mouseout', function () { |
| 109 | - if (this != road_win_show_p) | ||
| 110 | - this.setStrokeColor(color); | 110 | + if (map_status != 1 && this != road_win_show_p) |
| 111 | + this.setStrokeColor(updownColor(this.ct_data.directions)); | ||
| 111 | }); | 112 | }); |
| 112 | polyline.addEventListener('click', function (e) { | 113 | polyline.addEventListener('click', function (e) { |
| 113 | if (map_status != 1) | 114 | if (map_status != 1) |
| @@ -116,7 +117,7 @@ var gb_ct_map = function () { | @@ -116,7 +117,7 @@ var gb_ct_map = function () { | ||
| 116 | _pLines.push(polyline); | 117 | _pLines.push(polyline); |
| 117 | }); | 118 | }); |
| 118 | 119 | ||
| 119 | - roadPolylines.push(_pLines); | 120 | + roadPolylines[routes[0].directions]= _pLines; |
| 120 | }; | 121 | }; |
| 121 | 122 | ||
| 122 | var road_win_show_p; | 123 | var road_win_show_p; |
| @@ -127,15 +128,19 @@ var gb_ct_map = function () { | @@ -127,15 +128,19 @@ var gb_ct_map = function () { | ||
| 127 | 128 | ||
| 128 | //close event | 129 | //close event |
| 129 | win.addEventListener('close', function (e) { | 130 | win.addEventListener('close', function (e) { |
| 130 | - p.setStrokeColor(p.ct_data.oldColor); | ||
| 131 | - gb_road_route.clearFocus(); | ||
| 132 | - road_win_show_p = null; | 131 | + if(map_status != 1) { |
| 132 | + p.setStrokeColor(updownColor(p.ct_data.directions)); | ||
| 133 | + gb_road_route.clearFocus(); | ||
| 134 | + road_win_show_p = null; | ||
| 135 | + } | ||
| 133 | }); | 136 | }); |
| 134 | //open event | 137 | //open event |
| 135 | win.addEventListener('open', function (e) { | 138 | win.addEventListener('open', function (e) { |
| 136 | - gb_road_route.focus(data); | ||
| 137 | - p.setStrokeColor('#20bd26'); | ||
| 138 | - road_win_show_p = p; | 139 | + if(map_status !=1){ |
| 140 | + gb_road_route.focus(data); | ||
| 141 | + p.setStrokeColor('#20bd26'); | ||
| 142 | + road_win_show_p = p; | ||
| 143 | + } | ||
| 139 | }); | 144 | }); |
| 140 | 145 | ||
| 141 | map.openInfoWindow(win, point); | 146 | map.openInfoWindow(win, point); |
| @@ -287,18 +292,7 @@ var gb_ct_map = function () { | @@ -287,18 +292,7 @@ var gb_ct_map = function () { | ||
| 287 | } | 292 | } |
| 288 | } | 293 | } |
| 289 | 294 | ||
| 290 | - var cp = calcCenterPoint(p.ct_data.bdCoords); | ||
| 291 | - openRoadInfoWin(p, new BMap.Point(cp.longitude, cp.latitude)); | ||
| 292 | - }; | ||
| 293 | - | ||
| 294 | - var calcCenterPoint = function (coords) { | ||
| 295 | - var array = [], strs; | ||
| 296 | - for (var i = 0, item; item = coords[i++];) { | ||
| 297 | - strs = item.split(' '); | ||
| 298 | - array.push({latitude: strs[1], longitude: strs[0]}); | ||
| 299 | - } | ||
| 300 | - | ||
| 301 | - return geolib.getCenter(array); | 295 | + openRoadInfoWin(p, new BMap.Point(p.ct_data.cp.longitude, p.ct_data.cp.latitude)); |
| 302 | }; | 296 | }; |
| 303 | 297 | ||
| 304 | var exitEditBufferStatus = function (s) { | 298 | var exitEditBufferStatus = function (s) { |
| @@ -651,6 +645,74 @@ var gb_ct_map = function () { | @@ -651,6 +645,74 @@ var gb_ct_map = function () { | ||
| 651 | _renderStationMarket(gb_station_route.getData()[upDown]); | 645 | _renderStationMarket(gb_station_route.getData()[upDown]); |
| 652 | }; | 646 | }; |
| 653 | 647 | ||
| 648 | + | ||
| 649 | + /** | ||
| 650 | + * 进入路段编辑模式 | ||
| 651 | + * @param road | ||
| 652 | + */ | ||
| 653 | + var editPolyline; | ||
| 654 | + var start_edit_road= function (road) { | ||
| 655 | + map.closeInfoWindow();//关闭infoWindow | ||
| 656 | + map_status = 1; | ||
| 657 | + gb_road_route.focus(road); | ||
| 658 | + | ||
| 659 | + //居中 | ||
| 660 | + console.log('road.cproad.cp', road.cp); | ||
| 661 | + map.centerAndZoom(new BMap.Point(road.cp.longitude, road.cp.latitude), 20); | ||
| 662 | + | ||
| 663 | + //路段变色 | ||
| 664 | + var polyline = getRoadPolyline(road.sectionCode, road.directions); | ||
| 665 | + polyline.setStrokeColor('#E91E63'); | ||
| 666 | + | ||
| 667 | + editPolyline = polyline; | ||
| 668 | + //路段可编辑 | ||
| 669 | + polyline.enableEditing(); | ||
| 670 | + | ||
| 671 | + //lineupdate,计算长度 mouseup | ||
| 672 | + gb_road_route.showPathLength(geolib.getPathLength(polyline.getPath())); | ||
| 673 | + polyline.addEventListener('lineupdate', reCalcPathLength); | ||
| 674 | + } | ||
| 675 | + | ||
| 676 | + /** | ||
| 677 | + * 计算并显示路段长度 | ||
| 678 | + * @param p | ||
| 679 | + */ | ||
| 680 | + var reCalcPathLength = function () { | ||
| 681 | + var len = geolib.getPathLength(this.getPath()); | ||
| 682 | + gb_road_route.showPathLength(len); | ||
| 683 | + }; | ||
| 684 | + | ||
| 685 | + var getRoadPolyline = function (code, updown) { | ||
| 686 | + var array = roadPolylines[updown], | ||
| 687 | + polyline; | ||
| 688 | + for (var i = 0, p; p = array[i++];) { | ||
| 689 | + if (p.ct_data.sectionCode == code) { | ||
| 690 | + polyline = p; | ||
| 691 | + break; | ||
| 692 | + } | ||
| 693 | + } | ||
| 694 | + return polyline; | ||
| 695 | + }; | ||
| 696 | + | ||
| 697 | + /** | ||
| 698 | + * 退出路段编辑模式 | ||
| 699 | + */ | ||
| 700 | + var exitEditRoadStatus = function (road) { | ||
| 701 | + map_status = 0; | ||
| 702 | + $('.main_left_panel_m_layer').hide(); | ||
| 703 | + $('.road_edit_panel').remove(); | ||
| 704 | + | ||
| 705 | + editPolyline.removeEventListener('lineupdate', reCalcPathLength); | ||
| 706 | + | ||
| 707 | + //polyline | ||
| 708 | + var polyline = getRoadPolyline(road.sectionCode, road.directions); | ||
| 709 | + polyline.disableEditing(); | ||
| 710 | + polyline.ct_data = road; | ||
| 711 | + polyline.setStrokeColor(updownColor(road.directions)); | ||
| 712 | + | ||
| 713 | + openRoadInfoWin(polyline, new BMap.Point(road.cp.longitude, road.cp.latitude)); | ||
| 714 | + }; | ||
| 715 | + | ||
| 654 | res_load_ep.emitLater('load_map'); | 716 | res_load_ep.emitLater('load_map'); |
| 655 | return { | 717 | return { |
| 656 | _render: _render, | 718 | _render: _render, |
| @@ -666,6 +728,9 @@ var gb_ct_map = function () { | @@ -666,6 +728,9 @@ var gb_ct_map = function () { | ||
| 666 | getDrawPolygon: function () { | 728 | getDrawPolygon: function () { |
| 667 | return editPolygon; | 729 | return editPolygon; |
| 668 | }, | 730 | }, |
| 731 | + getDrawPolyline: function () { | ||
| 732 | + return editPolyline; | ||
| 733 | + }, | ||
| 669 | updateDragRadius: updateDragRadius, | 734 | updateDragRadius: updateDragRadius, |
| 670 | closeInfoWin: closeInfoWin, | 735 | closeInfoWin: closeInfoWin, |
| 671 | showAddPointPanel: showAddPointPanel, | 736 | showAddPointPanel: showAddPointPanel, |
| @@ -675,6 +740,8 @@ var gb_ct_map = function () { | @@ -675,6 +740,8 @@ var gb_ct_map = function () { | ||
| 675 | map.removeEventListener('dblclick', pickupPoint); | 740 | map.removeEventListener('dblclick', pickupPoint); |
| 676 | map.enableDoubleClickZoom(); | 741 | map.enableDoubleClickZoom(); |
| 677 | }, | 742 | }, |
| 678 | - reDrawStation: reDrawStation | 743 | + reDrawStation: reDrawStation, |
| 744 | + edit_road: start_edit_road, | ||
| 745 | + exitEditRoadStatus: exitEditRoadStatus | ||
| 679 | }; | 746 | }; |
| 680 | }(); | 747 | }(); |
| 681 | \ No newline at end of file | 748 | \ No newline at end of file |
src/main/resources/static/pages/base/geo_data_edit/js/road_route.js
| @@ -10,7 +10,6 @@ var gb_road_route = function () { | @@ -10,7 +10,6 @@ var gb_road_route = function () { | ||
| 10 | var ep = EventProxy.create("data", "temp", function (data, temp) { | 10 | var ep = EventProxy.create("data", "temp", function (data, temp) { |
| 11 | road_maps = data; | 11 | road_maps = data; |
| 12 | temps = temp; | 12 | temps = temp; |
| 13 | - console.log('roads', road_maps); | ||
| 14 | 13 | ||
| 15 | //按顺序,名称分组 | 14 | //按顺序,名称分组 |
| 16 | var ups = _group(road_maps[0]); | 15 | var ups = _group(road_maps[0]); |
| @@ -29,6 +28,11 @@ var gb_road_route = function () { | @@ -29,6 +28,11 @@ var gb_road_route = function () { | ||
| 29 | rs.list.sort(function (a, b) { | 28 | rs.list.sort(function (a, b) { |
| 30 | return parseInt(a.sectionrouteCode) - parseInt(b.sectionrouteCode); | 29 | return parseInt(a.sectionrouteCode) - parseInt(b.sectionrouteCode); |
| 31 | }); | 30 | }); |
| 31 | + //计算路段中心点 | ||
| 32 | + //var cp = calcCenterPoint(p.ct_data.bdCoords); | ||
| 33 | + $.each(rs.list, function () { | ||
| 34 | + this.cp = calcCenterPoint(this.bdCoords); | ||
| 35 | + }); | ||
| 32 | ep.emit('data', gb_common.groupBy(rs.list, 'directions')); | 36 | ep.emit('data', gb_common.groupBy(rs.list, 'directions')); |
| 33 | }); | 37 | }); |
| 34 | 38 | ||
| @@ -69,6 +73,7 @@ var gb_road_route = function () { | @@ -69,6 +73,7 @@ var gb_road_route = function () { | ||
| 69 | }; | 73 | }; |
| 70 | 74 | ||
| 71 | var focus = function (data) { | 75 | var focus = function (data) { |
| 76 | + clearFocus(); | ||
| 72 | //sectionCode | 77 | //sectionCode |
| 73 | var elem = $('.up_down_route_list>li>.road_route .r_r_item a[data-code='+data.sectionCode+']'); | 78 | var elem = $('.up_down_route_list>li>.road_route .r_r_item a[data-code='+data.sectionCode+']'); |
| 74 | elem = elem.parent(); | 79 | elem = elem.parent(); |
| @@ -89,20 +94,42 @@ var gb_road_route = function () { | @@ -89,20 +94,42 @@ var gb_road_route = function () { | ||
| 89 | return elem.offset().top < wrap.height() + 122 && elem.offset().top > 122; | 94 | return elem.offset().top < wrap.height() + 122 && elem.offset().top > 122; |
| 90 | }; | 95 | }; |
| 91 | 96 | ||
| 97 | + /** | ||
| 98 | + * 路段编辑 | ||
| 99 | + * @param road | ||
| 100 | + */ | ||
| 101 | + var edit_road = function (road) { | ||
| 102 | + $('.main_left_panel_m_layer').show(); | ||
| 103 | + //弹出编辑面板 | ||
| 104 | + var $editPanel = temps['geo_d_e_road_edit_panel-temp'](road); | ||
| 105 | + $('body').append($editPanel); | ||
| 106 | + | ||
| 107 | + gb_ct_map.edit_road(road); | ||
| 108 | + }; | ||
| 109 | + | ||
| 110 | + var showPathLength = function (len) { | ||
| 111 | + $('.road_edit_panel kbd>span').text(len); | ||
| 112 | + }; | ||
| 113 | + | ||
| 114 | + var realEditRoad; | ||
| 115 | + var callbackHandler = { | ||
| 116 | + edit: edit_road | ||
| 117 | + }; | ||
| 92 | //$('.up_down_route_list>li>.road_route .r_r_item a[data-code='+data.sectionCode+']') | 118 | //$('.up_down_route_list>li>.road_route .r_r_item a[data-code='+data.sectionCode+']') |
| 93 | $.contextMenu({ | 119 | $.contextMenu({ |
| 94 | selector: '.up_down_route_list>li>.road_route .r_r_item a[data-code]', | 120 | selector: '.up_down_route_list>li>.road_route .r_r_item a[data-code]', |
| 95 | className: 'station-route-ct-menu', | 121 | className: 'station-route-ct-menu', |
| 96 | callback: function (key, options) { | 122 | callback: function (key, options) { |
| 97 | - /*var aLink = options.$trigger; | 123 | + var aLink = options.$trigger; |
| 98 | var code = aLink.data('code'), | 124 | var code = aLink.data('code'), |
| 99 | updown = aLink.data('updown'); | 125 | updown = aLink.data('updown'); |
| 100 | - var station = getStation(code, updown); | ||
| 101 | - realEditStation = station; | ||
| 102 | - callbackHandler[key] && callbackHandler[key](station);*/ | 126 | + |
| 127 | + var road = getRoad(code, updown); | ||
| 128 | + realEditRoad = road; | ||
| 129 | + callbackHandler[key] && callbackHandler[key](road); | ||
| 103 | }, | 130 | }, |
| 104 | items: { | 131 | items: { |
| 105 | - 'edit_buffer': { | 132 | + 'edit': { |
| 106 | name: '编辑' | 133 | name: '编辑' |
| 107 | }, | 134 | }, |
| 108 | 'sep1': '---------', | 135 | 'sep1': '---------', |
| @@ -118,6 +145,39 @@ var gb_road_route = function () { | @@ -118,6 +145,39 @@ var gb_road_route = function () { | ||
| 118 | } | 145 | } |
| 119 | }); | 146 | }); |
| 120 | 147 | ||
| 148 | + var getRoad = function (code, updown) { | ||
| 149 | + var array = road_maps[updown]; | ||
| 150 | + for(var i=0,r;r=array[i++];){ | ||
| 151 | + if(r.sectionCode==code) | ||
| 152 | + return r; | ||
| 153 | + } | ||
| 154 | + return null; | ||
| 155 | + }; | ||
| 156 | + | ||
| 157 | + var calcCenterPoint = function (coords) { | ||
| 158 | + var array = [], strs; | ||
| 159 | + for (var i = 0, item; item = coords[i++];) { | ||
| 160 | + strs = item.split(' '); | ||
| 161 | + array.push({latitude: strs[1], longitude: strs[0]}); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + return geolib.getCenter(array); | ||
| 165 | + }; | ||
| 166 | + | ||
| 167 | + var update = function (road) { | ||
| 168 | + road.cp = calcCenterPoint(road.bdCoords); | ||
| 169 | + var array = road_maps[road.directions]; | ||
| 170 | + for(var i=0,item; item=array[i++];){ | ||
| 171 | + if(item.sectionCode==road.sectionCode){ | ||
| 172 | + array.splice(i - 1, 1, road); | ||
| 173 | + break; | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + //重新渲染 | ||
| 178 | + 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); | ||
| 180 | + }; | ||
| 121 | 181 | ||
| 122 | res_load_ep.emitLater('load_road_route'); | 182 | res_load_ep.emitLater('load_road_route'); |
| 123 | return { | 183 | return { |
| @@ -128,6 +188,8 @@ var gb_road_route = function () { | @@ -128,6 +188,8 @@ var gb_road_route = function () { | ||
| 128 | return temps; | 188 | return temps; |
| 129 | }, | 189 | }, |
| 130 | clearFocus: clearFocus, | 190 | clearFocus: clearFocus, |
| 131 | - focus: focus | 191 | + focus: focus, |
| 192 | + showPathLength: showPathLength, | ||
| 193 | + update: update | ||
| 132 | }; | 194 | }; |
| 133 | }(); | 195 | }(); |
| 134 | \ No newline at end of file | 196 | \ No newline at end of file |
src/main/resources/static/pages/base/geo_data_edit/js/station_route.js
| @@ -154,7 +154,7 @@ var gb_station_route = function () { | @@ -154,7 +154,7 @@ var gb_station_route = function () { | ||
| 154 | var is_duplication = function (name) { | 154 | var is_duplication = function (name) { |
| 155 | var array = station_maps[getUpDown()]; | 155 | var array = station_maps[getUpDown()]; |
| 156 | for(var i=0, s; s=array[i++];){ | 156 | for(var i=0, s; s=array[i++];){ |
| 157 | - if(s.stationName==name) | 157 | + if(s.stationName==$.trim(name)) |
| 158 | return true; | 158 | return true; |
| 159 | } | 159 | } |
| 160 | return false; | 160 | return false; |
src/main/resources/static/pages/base/geo_data_edit/js/submit.js
| @@ -66,6 +66,7 @@ var gb_data_submit = function () { | @@ -66,6 +66,7 @@ var gb_data_submit = function () { | ||
| 66 | $(document).on('click', '.add_station_search_point_wrap .buffer_edit_body button.submit', function (e) { | 66 | $(document).on('click', '.add_station_search_point_wrap .buffer_edit_body button.submit', function (e) { |
| 67 | var f = $(this).parents('form'); | 67 | var f = $(this).parents('form'); |
| 68 | var data = f.serializeJSON(); | 68 | var data = f.serializeJSON(); |
| 69 | + data.stationName = $.trim(data.stationName); | ||
| 69 | 70 | ||
| 70 | UIkit.modal.confirm('确定新增站点【'+data.stationName+'】?').then(function() { | 71 | UIkit.modal.confirm('确定新增站点【'+data.stationName+'】?').then(function() { |
| 71 | data.lineCode = storage.getItem('geo_data_edit_line_code'); | 72 | data.lineCode = storage.getItem('geo_data_edit_line_code'); |
| @@ -88,6 +89,35 @@ var gb_data_submit = function () { | @@ -88,6 +89,35 @@ var gb_data_submit = function () { | ||
| 88 | return false; | 89 | return false; |
| 89 | }); | 90 | }); |
| 90 | 91 | ||
| 92 | + /** | ||
| 93 | + * 路段编辑提交 | ||
| 94 | + */ | ||
| 95 | + $(document).on('click', '.road_edit_panel .buffer_edit_body button.submit', function (e) { | ||
| 96 | + var f = $(this).parents('form'); | ||
| 97 | + var data = f.serializeJSON(); | ||
| 98 | + | ||
| 99 | + var polyline = gb_ct_map.getDrawPolyline(); | ||
| 100 | + var pos = polyline.getPath(); | ||
| 101 | + var gsectionVector = ''; | ||
| 102 | + for(var i=0,p;p=pos[i++];){ | ||
| 103 | + gsectionVector += (p.lng + " " + p.lat + ","); | ||
| 104 | + } | ||
| 105 | + data.gsectionVector = gsectionVector.substr(0, gsectionVector.length - 1); | ||
| 106 | + | ||
| 107 | + console.log('data', data); | ||
| 108 | + UIkit.modal.confirm('确定保存编辑的【'+data.sectionName+'】?').then(function() { | ||
| 109 | + show_run_text('正在保存...'); | ||
| 110 | + | ||
| 111 | + gb_common.$post('/_geo_data/updateRoadInfo', data, function (rs) { | ||
| 112 | + hide_run_text(); | ||
| 113 | + UIkit.notification("修改成功!", {status: 'success'}); | ||
| 114 | + gb_road_route.update(rs.road); | ||
| 115 | + | ||
| 116 | + gb_ct_map.exitEditRoadStatus(rs.road); | ||
| 117 | + }); | ||
| 118 | + }); | ||
| 119 | + }); | ||
| 120 | + | ||
| 91 | var show_run_text = function (t) { | 121 | var show_run_text = function (t) { |
| 92 | $('.text', $loadPanel).text(t); | 122 | $('.text', $loadPanel).text(t); |
| 93 | $loadPanel.show(); | 123 | $loadPanel.show(); |