Commit d4bc0d488b3a9510f10e8f15facab2418e9045f7
1 parent
642984d4
1
Showing
1 changed file
with
66 additions
and
93 deletions
src/main/resources/static/pages/base/stationroute/addstationstemplate.html
| @@ -85,30 +85,6 @@ | @@ -85,30 +85,6 @@ | ||
| 85 | </div> | 85 | </div> |
| 86 | <script type="text/javascript"> | 86 | <script type="text/javascript"> |
| 87 | 87 | ||
| 88 | - // xml方式上传是,处理转成txt格式的方法 | ||
| 89 | - var getXmlSection = function (xml) { | ||
| 90 | - // var xml = $("#xmlText").val(); | ||
| 91 | - var stationPointList = getXmlNode(xml); | ||
| 92 | - var sListSize = stationPointList.length; | ||
| 93 | - var sectionPointListStr = stationPointList[stationPointList.length - 1]; | ||
| 94 | - var sectionPointList = sectionPointListStr.split(" "); | ||
| 95 | - | ||
| 96 | - // var sectionStr = ""; | ||
| 97 | - var sections = []; | ||
| 98 | - var mapping = nearestSectionPoint(stationPointList, sectionPointList); | ||
| 99 | - for (var i = 0; i < sectionPointList.length; i++) { | ||
| 100 | - var pointStr = sectionPointList[i], | ||
| 101 | - point = pointStr.split(","); | ||
| 102 | - | ||
| 103 | - if (mapping[pointStr]) { | ||
| 104 | - sections.push(point[0] + " " + point[1] + " " + point[2] + " Stop"); | ||
| 105 | - } else { | ||
| 106 | - sections.push(point[0] + " " + point[1] + " " + point[2]); | ||
| 107 | - } | ||
| 108 | - } | ||
| 109 | - return sections; | ||
| 110 | - }; | ||
| 111 | - | ||
| 112 | $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,ajaxd,dir,line,fun){ | 88 | $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,ajaxd,dir,line,fun){ |
| 113 | 89 | ||
| 114 | 90 | ||
| @@ -178,45 +154,34 @@ $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,a | @@ -178,45 +154,34 @@ $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,a | ||
| 178 | }, | 154 | }, |
| 179 | 155 | ||
| 180 | submitHandler : function(f) { | 156 | submitHandler : function(f) { |
| 181 | - // 隐藏弹出层 | ||
| 182 | - $('#edit_route_mobal').modal('hide'); | ||
| 183 | - // 原坐标类型 | ||
| 184 | - var baseRes = "WGS84"; | 157 | + debugger; |
| 158 | + // 隐藏手动规划弹出层 | ||
| 159 | + $('#add_station_template_mobal').modal('hide'); | ||
| 160 | + var directionData = dir; | ||
| 185 | // 定义线路名称 | 161 | // 定义线路名称 |
| 186 | var lineNameV = $('.portlet-title .caption').text(); | 162 | var lineNameV = $('.portlet-title .caption').text(); |
| 187 | var dirStr = ''; | 163 | var dirStr = ''; |
| 188 | - // 路线方向 | ||
| 189 | - var directionData = dir; | ||
| 190 | - | ||
| 191 | - var type = $("input[name='typeCheck']:checked").val(); | ||
| 192 | - | 164 | + // 上行 |
| 165 | + if(directionData==0){ | ||
| 166 | + dirStr = '上行路段'; | ||
| 167 | + // 隐藏上行规划 | ||
| 168 | + $('#upToolsMobal').hide(); | ||
| 169 | + // 下行 | ||
| 170 | + }else if(directionData==1){ | ||
| 171 | + dirStr = '下行路段'; | ||
| 172 | + // 隐藏上行规划 | ||
| 173 | + $('#downToolsMobal').hide(); | ||
| 174 | + } | ||
| 193 | // 弹出正在加载层 | 175 | // 弹出正在加载层 |
| 194 | - var i = layer.load(2); | 176 | + var i = layer.load(0,{offset:['200px', '280px']}); |
| 195 | // 表单序列化 | 177 | // 表单序列化 |
| 196 | var paramsForm = form.serializeJSON(); | 178 | var paramsForm = form.serializeJSON(); |
| 197 | - var array = []; | ||
| 198 | - if(type == 1){ | ||
| 199 | - array = getXmlSection(paramsForm.points); | ||
| 200 | - } else { | ||
| 201 | - // 切割坐标点 | ||
| 202 | - array = paramsForm.points.split('\r\n'); | ||
| 203 | - } | ||
| 204 | - // 把坐标点转换为站点或路段 | 179 | + var baseResValue = paramsForm.baseRes; |
| 180 | + // 站点名称字符串切割 | ||
| 181 | + var array = paramsForm.stations.split('\r\n'); | ||
| 205 | var arrayFormat = inputStationValueFormat(array); | 182 | var arrayFormat = inputStationValueFormat(array); |
| 206 | - var stationList = arrayFormat.stationList; | ||
| 207 | - var sectionListTemp = arrayFormat.sectionList; | ||
| 208 | - var sectionList = []; | ||
| 209 | - // 隔30个取一个点(相当于30s) | ||
| 210 | - var typeNum = type == 0 ? 30:1; | ||
| 211 | - for(var i = 0; i*typeNum < sectionListTemp.length; i++) { | ||
| 212 | - sectionList[i] = sectionListTemp[i*typeNum]; | ||
| 213 | - } | ||
| 214 | - sectionList[sectionList.length] = sectionListTemp[sectionListTemp.length-1]; | ||
| 215 | - | ||
| 216 | - var sectionListFinal = []; | ||
| 217 | - sectionListFinal.push({sectionName : lineNameV, points : sectionList}); | ||
| 218 | // 根据站点名称获取百度坐标 | 183 | // 根据站点名称获取百度坐标 |
| 219 | - map.stationsPointsToLibraryPoint(stationList,function(resultJson) { | 184 | + map.stationsNameToPoints(arrayFormat,function(resultJson) { |
| 220 | // 根据坐标点获取两点之间的时间与距离 | 185 | // 根据坐标点获取两点之间的时间与距离 |
| 221 | map.getDistanceAndDuration(resultJson,function(stationdataList) { | 186 | map.getDistanceAndDuration(resultJson,function(stationdataList) { |
| 222 | // 设置第一个站的距离 | 187 | // 设置第一个站的距离 |
| @@ -225,15 +190,14 @@ $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,a | @@ -225,15 +190,14 @@ $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,a | ||
| 225 | stationdataList[0].duration = ''; | 190 | stationdataList[0].duration = ''; |
| 226 | // 定义站点信息JSON字符串 | 191 | // 定义站点信息JSON字符串 |
| 227 | var stationJSON = JSON.stringify(stationdataList); | 192 | var stationJSON = JSON.stringify(stationdataList); |
| 193 | + var addLine = line.getLineObj(); | ||
| 228 | // 参数集合 | 194 | // 参数集合 |
| 229 | var params = {}; | 195 | var params = {}; |
| 230 | - params.baseRes = baseRes; | ||
| 231 | - // 是否添加该站点 | ||
| 232 | - | 196 | + params.baseRes = baseResValue; |
| 233 | // 站点信息JSON字符串 | 197 | // 站点信息JSON字符串 |
| 234 | params.stationJSON = stationJSON; | 198 | params.stationJSON = stationJSON; |
| 235 | // 线路ID | 199 | // 线路ID |
| 236 | - params.lineId = line.id; | 200 | + params.lineId = addLine.id; |
| 237 | // 方向 | 201 | // 方向 |
| 238 | params.directions = directionData; | 202 | params.directions = directionData; |
| 239 | // 原始坐标类型 | 203 | // 原始坐标类型 |
| @@ -248,55 +212,64 @@ $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,a | @@ -248,55 +212,64 @@ $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,a | ||
| 248 | params.destroy = '0'; | 212 | params.destroy = '0'; |
| 249 | // versions:版本号 | 213 | // versions:版本号 |
| 250 | params.versions = '1'; | 214 | params.versions = '1'; |
| 251 | - // 定义路段信息字符串 | ||
| 252 | - var sectionJSON = JSON.stringify(sectionListFinal); | ||
| 253 | - // 路段信息JSON字符串 | ||
| 254 | - params.sectionJSON = sectionJSON; | ||
| 255 | - addSave(params,line.id,directionData); | ||
| 256 | - }); | 215 | + map.lineInfoPanl(lineNameV,directionData,function(BusLine){ |
| 216 | + // 如果线路信息不为空 | ||
| 217 | + if(BusLine && Polygon){ | ||
| 218 | + // 获取公交线几何对象, 仅当结果自动添加到地图上时有效 | ||
| 219 | + var Polygon = BusLine.getPolyline(); | ||
| 220 | + // 返回多边型的点数组(自1.2新增) | ||
| 221 | + var polyGonArray = Polygon.getPath(); | ||
| 222 | + var jsonArray = [{sectionName:lineNameV+dirStr,points:polyGonArray}]; | ||
| 223 | + // 定义路段信息字符串 | ||
| 224 | + var sectionJSON = JSON.stringify(jsonArray); | ||
| 225 | + // 路段信息JSON字符串 | ||
| 226 | + // if(sectionJSON != null && sectionJSON != "") { | ||
| 227 | + params.sectionJSON = sectionJSON; | ||
| 228 | + addSave(params,addLine.id,directionData); | ||
| 229 | + /* } else { | ||
| 230 | + layer.msg('百度地图上没有此线路的相应路段,请更换方式规划!!!'); | ||
| 231 | + } */ | ||
| 232 | + }else { | ||
| 233 | + // 根据坐标点获取两点之间的折线路段 | ||
| 234 | + map.getSectionListPlonly(stationdataList,function(sectiondata) { | ||
| 235 | + // 定义路段信息字符串 | ||
| 236 | + var sectionJSON = JSON.stringify(sectiondata); | ||
| 237 | + // 路段信息JSON字符串 | ||
| 238 | + //if(sectionJSON != null && sectionJSON != "") { | ||
| 239 | + params.sectionJSON = sectionJSON; | ||
| 240 | + addSave(params,addLine.id,directionData); | ||
| 241 | + /* } else { | ||
| 242 | + layer.msg('无法生成路段,请重试!'); | ||
| 243 | + return; | ||
| 244 | + } */ | ||
| 245 | + }); | ||
| 246 | + } | ||
| 247 | + }); | ||
| 248 | + | ||
| 249 | + }); | ||
| 257 | 250 | ||
| 258 | - }); | ||
| 259 | - }, | 251 | + }); |
| 252 | + | ||
| 253 | + } | ||
| 260 | 254 | ||
| 261 | - }); | 255 | + }); |
| 262 | 256 | ||
| 263 | function inputStationValueFormat(paramsStationsArray) { | 257 | function inputStationValueFormat(paramsStationsArray) { |
| 264 | var stationList = []; | 258 | var stationList = []; |
| 265 | - var sectionList = []; | ||
| 266 | - var routeList = {"stationList":stationList, "sectionList":sectionList}; | ||
| 267 | var len = paramsStationsArray.length; | 259 | var len = paramsStationsArray.length; |
| 268 | - // 处理相同站点判断值 | ||
| 269 | - var isPush = true; | ||
| 270 | for(var k =0;k<len;k++) { | 260 | for(var k =0;k<len;k++) { |
| 271 | if(paramsStationsArray[k]=="") | 261 | if(paramsStationsArray[k]=="") |
| 272 | continue; | 262 | continue; |
| 273 | var tempStr = paramsStationsArray[k].split('\t'); | 263 | var tempStr = paramsStationsArray[k].split('\t'); |
| 274 | - var tempPoint = transGpsLoc(tempStr[0],tempStr[1]); | ||
| 275 | - var point = {lng:tempPoint.lng, lat:tempPoint.lat}; | ||
| 276 | - if(tempStr.length < 4){ | ||
| 277 | - sectionList[k] = point; | ||
| 278 | - isPush = true; | 264 | + if(tempStr.length<2){ |
| 265 | + stationList.push({name:paramsStationsArray[k]+"公交车站",wgs:{x:'',y:''}}); | ||
| 279 | }else { | 266 | }else { |
| 280 | - if(isPush) { | ||
| 281 | - sectionList[k] = point; | ||
| 282 | - stationList.push({name:tempStr[3], potion:{lng:tempPoint.lng, lat:tempPoint.lat} , wgs:{x:tempStr[0], y:tempStr[1]}}); | ||
| 283 | - } else { | ||
| 284 | - sectionList[k] = point; | ||
| 285 | - } | ||
| 286 | - isPush = false; | 267 | + stationList.push({name:tempStr[0]+"公交车站",wgs:{x:tempStr[1], y:tempStr[2]}}); |
| 287 | } | 268 | } |
| 288 | } | 269 | } |
| 289 | - for(var i = 0 ;i<sectionList.length;i++) { | ||
| 290 | - if(sectionList[i] == "" || isNaN(sectionList[i].lng) || typeof(sectionList[i]) == "undefined" || sectionList[i] == null) { | ||
| 291 | - sectionList.splice(i,1);//删除数组中下表i-i+1之间的值 | ||
| 292 | - i= i-1; | ||
| 293 | - } | ||
| 294 | - | ||
| 295 | - } | ||
| 296 | - return routeList; | 270 | + return stationList; |
| 297 | } | 271 | } |
| 298 | 272 | ||
| 299 | - | ||
| 300 | function addSave(params,lineid,directionData) { | 273 | function addSave(params,lineid,directionData) { |
| 301 | 274 | ||
| 302 | 275 |