Commit 0732ca21bab96c5072006ec41ccb41d1d6fc344d

Authored by 徐烜
2 parents 309ca91f 185d3f6a
src/main/java/com/bsth/service/impl/StationServiceImpl.java
... ... @@ -131,10 +131,12 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem
131 131  
132 132 Map<String, Object> resultSaveMapm = new HashMap<String,Object>();
133 133  
  134 + String baseRes = map.get("baseRes").equals("") ? "" : map.get("baseRes").toString();
  135 +
134 136 if(!stationJSON.equals("")) {
135 137  
136 138 // 保存站点与站点路由信息
137   - resultSaveMapm = savaStationAndStationRouteInfo( stationJSON, sectionDistance, sectionDuration, dbType,radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine);
  139 + resultSaveMapm = savaStationAndStationRouteInfo( stationJSON, sectionDistance, sectionDuration, dbType,radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine,baseRes);
138 140  
139 141 }
140 142  
... ... @@ -258,7 +260,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
258 260 */
259 261 public Map<String, Object> savaStationAndStationRouteInfo(String stationJSON,double sectionDistance,double sectionDuration,String dbType,
260 262  
261   - int radius,String shapesType,int destroy,int versions,double sumUpOrDownMileage,int directions,Line resultLine) throws Exception{
  263 + int radius,String shapesType,int destroy,int versions,double sumUpOrDownMileage,int directions,Line resultLine,String baseRes) throws Exception{
262 264  
263 265 Map<String, Object> paramsMeleageAndDistncDura = new HashMap<String,Object>();
264 266  
... ... @@ -302,9 +304,6 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
302 304 // 百度坐标纬度
303 305 String bLatx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lat").toString();
304 306  
305   - // 百度经纬度
306   - bJwpoints = bLonx + " " + bLatx;
307   -
308 307 List<Object[]> stationNameList = repository.findStationName(stationName);
309 308  
310 309 boolean isHave = isHaveStationname(bJwpoints,stationNameList);
... ... @@ -343,10 +342,84 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
343 342  
344 343 float gLaty = 0.0f;
345 344  
346   - /** to WGS坐标 */
347   - Location resultPoint = FromBDPointToWGSPoint(bLonx,bLatx);
  345 + Location resultPoint = null;
  346 +
  347 + if(baseRes.equals("No")){
  348 +
  349 + /** BD to WGS坐标 */
  350 + resultPoint = FromBDPointToWGSPoint(bLonx,bLatx);
  351 +
  352 + if(gLonxStr==null)
  353 + gLonx = (float)resultPoint.getLng();
  354 + else
  355 + gLonx = Float.valueOf(gLonxStr);
  356 +
  357 + if(gLatyStr==null)
  358 + gLaty = (float)resultPoint.getLat();
  359 + else
  360 + gLaty = Float.valueOf(gLatyStr);
  361 +
  362 + arg0.setgLonx(gLonx);
  363 +
  364 + arg0.setgLaty(gLaty);
  365 +
  366 + // 百度经纬度
  367 + bJwpoints = bLonx + " " + bLatx;
  368 +
  369 + arg0.setbJwpoints(bJwpoints);
  370 +
  371 + }else if(baseRes.equals("GCJ02")){
  372 +
  373 + Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
  374 +
  375 + Location location = TransGPS.bd_encrypt(bdLoc);
  376 +
  377 + String GCJLng = String.valueOf(location.getLng());
  378 +
  379 + String GCJLat = String.valueOf(location.getLat());
  380 +
  381 + resultPoint = FromBDPointToWGSPoint(GCJLng,GCJLat);
  382 +
  383 + bJwpoints = GCJLng + " " +GCJLat;
  384 +
  385 + arg0.setgLonx((float)location.getLng());
  386 +
  387 + arg0.setgLaty((float)location.getLat());
  388 +
  389 + arg0.setbJwpoints(bJwpoints);
  390 +
  391 +
  392 + }else if(baseRes.equals("BD09")){
  393 +
  394 + resultPoint = FromBDPointToWGSPoint(gLonxStr, gLatyStr);
  395 +
  396 + bJwpoints = gLonxStr+ " " + gLatyStr;
  397 +
  398 + arg0.setgLonx((float)resultPoint.getLng());
  399 +
  400 + arg0.setgLaty((float)resultPoint.getLat());
  401 +
  402 + }else if(baseRes.equals("WGS84")){
  403 +
  404 + Location bdLoc = TransGPS.LocationMake(Double.valueOf(gLonxStr), Double.valueOf(gLatyStr));
  405 +
  406 + Location gcjLoc = TransGPS.transformFromWGSToGCJ(bdLoc);
  407 +
  408 + Location bdEn = TransGPS.bd_encrypt(gcjLoc);
  409 +
  410 + bJwpoints = String.valueOf(bdEn.getLng()) + " " + String.valueOf(bdEn.getLat());
  411 +
  412 + arg0.setbJwpoints(bJwpoints);
  413 +
  414 + arg0.setgLonx(Float.valueOf(gLonxStr));
  415 +
  416 + arg0.setgLaty(Float.valueOf(gLatyStr));
  417 +
  418 + }
  419 +
  420 +
348 421  
349   - if(gLonxStr==null)
  422 + /* if(gLonxStr==null)
350 423 gLonx = (float)resultPoint.getLng();
351 424 else
352 425 gLonx = Float.valueOf(gLonxStr);
... ... @@ -358,7 +431,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
358 431  
359 432 arg0.setgLonx(gLonx);
360 433  
361   - arg0.setgLaty(gLaty);
  434 + arg0.setgLaty(gLaty);*/
362 435  
363 436 // 站点地理位置WGS坐标经度
364 437 // String gLonx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("WGSpotion").toString()).get("Lng").toString();
... ... @@ -379,7 +452,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
379 452 // 版本号
380 453 arg0.setVersions(versions);
381 454  
382   - arg0.setbJwpoints(bJwpoints);
  455 + /*arg0.setbJwpoints(bJwpoints);*/
383 456  
384 457 // 插入站点信息
385 458 repository.save(arg0);
... ... @@ -1280,6 +1353,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1280 1353  
1281 1354 }
1282 1355  
  1356 +
1283 1357 @Override
1284 1358 public Map<String, Object> manualSave(Map<String, Object> map) {
1285 1359  
... ... @@ -1331,10 +1405,12 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1331 1405  
1332 1406 Map<String, Object> resultSaveMapm = new HashMap<String,Object>();
1333 1407  
  1408 + String baseRes = map.get("baseRes").equals("") ? "" : map.get("baseRes").toString();
  1409 +
1334 1410 if(!stationJSON.equals("")) {
1335 1411  
1336 1412 // 保存站点与站点路由信息
1337   - // resultSaveMapm = savaStationAndStationRouteInfo( stationJSON, sectionDistance, sectionDuration, dbType,radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine);
  1413 + resultSaveMapm = savaStationAndStationRouteInfo( stationJSON, sectionDistance, sectionDuration, dbType,radius, shapesType, destroy, versions, sumUpOrDownMileage, directions, resultLine,baseRes);
1338 1414  
1339 1415 }
1340 1416  
... ... @@ -1347,7 +1423,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1347 1423 // 如果路段信息JSON字符串不为空
1348 1424 if(!sectionJSON.equals("")) {
1349 1425  
1350   - // manualSaveSectionAndSectionRoute(sectionJSON, speedLimitStr, sectionDistance, sectionDuration, dbType, versions, resultLine, destroy, directions);
  1426 + manualSaveSectionAndSectionRoute(sectionJSON, speedLimitStr, sectionDistance, sectionDuration, dbType, versions, resultLine, destroy, directions);
1351 1427  
1352 1428 }
1353 1429  
... ...
src/main/resources/static/pages/base/stationroute/addstationstemplate.html
... ... @@ -40,10 +40,10 @@
40 40 <input type="radio" class="icheck" name="baseRes" value='No'> 暂无坐标系
41 41 </label>
42 42 <label>
43   - <input type="radio" class="icheck" name="baseRes" value='GCJ-02' > 火星坐标系
  43 + <input type="radio" class="icheck" name="baseRes" value='GCJ02' > 火星坐标系
44 44 </label>
45 45 <label >
46   - <input type="radio" class="icheck" name="baseRes" value='BD-09'> 百度坐标系
  46 + <input type="radio" class="icheck" name="baseRes" value='BD09'> 百度坐标系
47 47 </label>
48 48 <label >
49 49 <input type="radio" class="icheck" name="baseRes" value='WGS84' checked> WGS84坐标系
... ... @@ -59,7 +59,6 @@
59 59 <span class="help-block" style="color:#1bbc9b;">
60 60 &nbsp;请在文本域中按站点顺序依次输入站点名称(如果已有站点GPS坐标,请将坐标跟在站点名称后面用【Tab】键隔开),每输入完一个站名时请按回车键【Enter】换行.
61 61 例如:<br><br>
62   - <!-- <HR style="FILTER: alpha(opacity=0,finishopacity=100,style=1)" width="80%" color=#987cb9 SIZE=3> -->
63 62 浦东大道金桥路 121.496612 31.238960<br>
64 63 浦东大道居家桥路 121.496618 31.238957<br>
65 64 浦东大道德平路 121.496622 31.238948<br>
... ... @@ -80,6 +79,8 @@
80 79  
81 80 $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,ajaxd,dir,line,fun){
82 81  
  82 +
  83 +
83 84 // 延迟加载显示mobal
84 85 setTimeout(function(){$('#add_station_template_mobal').modal({show : true,backdrop: 'static', keyboard: false});},200);
85 86  
... ... @@ -149,15 +150,24 @@ $(&#39;#add_station_template_mobal&#39;).on(&#39;AddStationTempMobal.show&#39;, function(e,map,a
149 150  
150 151 var directionData = dir;
151 152  
  153 + // 定义线路名称
  154 + var lineNameV = $('.portlet-title .caption').text();
  155 +
  156 + var dirStr = '';
  157 +
152 158 // 上行
153 159 if(directionData==0){
154 160  
  161 + dirStr = '上行路段';
  162 +
155 163 // 隐藏上行规划
156 164 $('#upToolsMobal').hide();
157 165  
158 166 // 下行
159 167 }else if(directionData==1){
160 168  
  169 + dirStr = '下行路段';
  170 +
161 171 // 隐藏上行规划
162 172 $('#downToolsMobal').hide();
163 173  
... ... @@ -167,163 +177,181 @@ $(&#39;#add_station_template_mobal&#39;).on(&#39;AddStationTempMobal.show&#39;, function(e,map,a
167 177 var i = layer.load(0,{offset:['200px', '280px']});
168 178  
169 179 // 表单序列化
170   - var params = form.serializeJSON();
  180 + var paramsForm = form.serializeJSON();
171 181  
172   - var baseResValue = params.baseRes;
  182 + var baseResValue = paramsForm.baseRes;
173 183  
174 184 // 站点名称字符串切割
175   - var paramsStationsArray = params.stations.split('\r\n');
  185 + var array = paramsForm.stations.split('\r\n');
176 186  
177   - var len = paramsStationsArray.length;
  187 + var arrayFormat = inputStationValueFormat(array);
178 188  
179   - if(baseResValue=='No'){
180   -
181   - debugger;
182   -
183   - var stationList = [];
184   -
185   - for(var k =0;k<len;k++)
186   - stationList.push({name:paramsStationsArray[k]+'公交车站'});
187   -
188   -
189   - console.log(stationList);
190   -
191   - return;
  189 +
  190 + // 根据站点名称获取百度坐标
  191 + map.stationsNameToPoints(arrayFormat,function(resultJson) {
192 192  
193   - // 根据站点名称获取百度坐标
194   - map.stationsNameToPoints(stationList,function(resultJson) {
  193 + // 根据坐标点获取两点之间的时间与距离
  194 + map.getDistanceAndDuration(resultJson,function(stationdataList) {
  195 +
  196 + // 设置第一个站的距离
  197 + stationdataList[0].distance = '';
  198 +
  199 + // 设置第一个站的时间
  200 + stationdataList[0].duration = '';
  201 +
  202 + // 定义站点信息JSON字符串
  203 + var stationJSON = JSON.stringify(stationdataList);
  204 +
  205 + var addLine = line.getLineObj();
  206 +
  207 + // 参数集合
  208 + var params = {};
  209 +
  210 + params.baseRes = baseResValue;
  211 +
  212 + // 站点信息JSON字符串
  213 + params.stationJSON = stationJSON;
  214 +
  215 + // 线路ID
  216 + params.lineId = addLine.id;
  217 +
  218 + // 方向
  219 + params.directions = directionData;
  220 +
  221 + // 原始坐标类型
  222 + params.dbType = 'b';
  223 +
  224 + // 圆形半径
  225 + params.radius = '100';
  226 +
  227 + // 限速
  228 + params.speedLimit = '60';
195 229  
196   - // 根据坐标点获取两点之间的时间与距离
197   - map.getDistanceAndDuration(resultJson,function(stationdataList) {
  230 + // 图形类型(r:圆形;p:多边形)
  231 + params.shapesType = 'r';
  232 +
  233 + // destroy:是否撤销
  234 + params.destroy = '0';
  235 +
  236 + // versions:版本号
  237 + params.versions = '1';
  238 +
  239 + map.lineInfoPanl(lineNameV,directionData,function(BusLine){
198 240  
199   - // 根据坐标点获取两点之间的折线路段
200   - map.getSectionListPlonly(stationdataList,function(sectiondata) {
201   -
202   - var addLine = LineObj.getLineObj();
203   -
204   - // 设置第一个站的距离
205   - stationdataList[0].distance = '';
206   -
207   - // 设置第一个站的时间
208   - stationdataList[0].duration = '';
209   -
210   - // 定义站点信息JSON字符串
211   - var stationJSON = JSON.stringify(stationdataList);
212   -
213   - // 定义路段信息字符串
214   - var sectionJSON = JSON.stringify(sectiondata);
215   -
216   - // 参数集合
217   - var params = {};
218   -
219   - // 站点信息JSON字符串
220   - params.stationJSON = stationJSON;
221   -
222   - // 线路ID
223   - params.lineId = addLine.id;
224   -
225   - // 方向
226   - params.directions = directionData;
  241 + // 如果线路信息不为空
  242 + if(BusLine){
227 243  
228   - // 原始坐标类型
229   - params.dbType = 'b';
230   -
231   - // 圆形半径
232   - params.radius = '100';
233   -
234   - // 限速
235   - params.speedLimit = '60';
236   -
237   - // 图形类型(r:圆形;p:多边形)
238   - params.shapesType = 'r';
239   -
240   - // destroy:是否撤销
241   - params.destroy = '0';
242   -
243   - // versions:版本号
244   - params.versions = '1';
245   -
246   - // 路段信息JSON字符串
247   - params.sectionJSON = sectionJSON;
248   -
249   - // 保存
250   - ajaxd.manualSave(params,function(rd) {
251   -
252   - if(rd.status='SUCCESS') {
  244 + if(BusLine.zB.length == 0){
  245 +
  246 + // 根据坐标点获取两点之间的折线路段
  247 + map.getSectionListPlonly(stationdataList,function(sectiondata) {
253 248  
254   - layer.msg('保存成功!');
  249 + // 定义路段信息字符串
  250 + var sectionJSON = JSON.stringify(sectiondata);
255 251  
256   - }else {
  252 + // 路段信息JSON字符串
  253 + params.sectionJSON = sectionJSON;
257 254  
258   - layer.msg('保存失败!');
  255 + addSave(params,addLine.id,directionData);
259 256  
260   - }
  257 + });
261 258  
262   - // 关闭弹出层
263   - layer.closeAll();
264 259  
265   - // 清除地图覆盖物
266   - map.clearMarkAndOverlays();
267 260  
268   - // 刷新树
269   - fun.resjtreeDate(addLine.id,directionData);
  261 + }else {
270 262  
271   - // 查询上行路段信息
272   - ajaxd.getSectionRouteInfo(addLine.id,directionData,function(data) {
273   -
274   - // 在地图上画出线路走向
275   - fun.linePanlThree(data,directionData);
276   -
277   - });
  263 + // 获取公交线几何对象, 仅当结果自动添加到地图上时有效
  264 + var Polygon = BusLine.getPolyline();
278 265  
279   - });
280   -
281   - });
282   -
283   - });
  266 + // 返回多边型的点数组(自1.2新增)
  267 + var polyGonArray = Polygon.getPath();
  268 +
  269 + var jsonArray = [{sectionName:lineNameV+dirStr,points:polyGonArray}];
  270 +
  271 + // 定义路段信息字符串
  272 + var sectionJSON = JSON.stringify(jsonArray);
  273 +
  274 + // 路段信息JSON字符串
  275 + params.sectionJSON = sectionJSON;
  276 +
  277 + addSave(params,addLine.id,directionData);
  278 +
  279 + }
  280 + }
  281 + });
284 282  
285 283 });
286 284  
287   - }else {
288   -
  285 + });
  286 +
  287 + }
  288 +
  289 + });
  290 +
  291 + function inputStationValueFormat(paramsStationsArray) {
  292 +
  293 + var stationList = [];
  294 +
  295 + var len = paramsStationsArray.length;
  296 +
  297 + for(var k =0;k<len;k++) {
  298 +
  299 + if(paramsStationsArray[k]=="")
  300 + continue;
  301 +
  302 + var tempStr = paramsStationsArray[k].split('\t');
  303 +
  304 + if(tempStr.length<2){
289 305  
  306 + stationList.push({name:paramsStationsArray[k]+"公交车站",wgs:{x:'',y:''}});
  307 +
  308 + }else {
290 309  
  310 + stationList.push({name:tempStr[0]+"公交车站",wgs:{x:tempStr[1], y:tempStr[2]}});
291 311  
292 312 }
293   -
294   -
295   - /* if(len>0) {
296   -
297   - for(var k =0;k<len;k++) {
298   -
299   - if(paramsStationsArray[k]=="")
300   - continue;
301   -
302   - var tempStr = paramsStationsArray[k].split('\t');
303 313  
304   - if(tempStr.length<2){
305   -
306   - stationList.push({name:paramsStationsArray[k]+"公交车站",wgs:{x:'',y:''}});
307   -
308   - }else {
309   -
310   - stationList.push({name:tempStr[0]+"公交车站",wgs:{x:tempStr[1], y:tempStr[2]}});
311   -
312   - }
313   -
314   - }
  314 + }
  315 +
  316 + return stationList;
  317 +
  318 + }
  319 +
  320 + function addSave(params,lineid,directionData) {
  321 +
  322 + // 保存
  323 + ajaxd.manualSave(params,function(rd) {
  324 +
  325 + if(rd.status='SUCCESS') {
  326 +
  327 + layer.msg('保存成功!');
315 328  
316 329 }else {
317 330  
318   - layer.msg('请按说明规则输入站点!');
  331 + layer.msg('保存失败!');
319 332  
320   - return;
  333 + }
  334 +
  335 + // 关闭弹出层
  336 + layer.closeAll();
  337 +
  338 + // 清除地图覆盖物
  339 + map.clearMarkAndOverlays();
  340 +
  341 + // 刷新树
  342 + fun.resjtreeDate(lineid,directionData);
  343 +
  344 + // 查询上行路段信息
  345 + ajaxd.getSectionRouteInfo(lineid,directionData,function(data) {
  346 +
  347 + // 在地图上画出线路走向
  348 + fun.linePanlThree(lineid,data,directionData);
321 349  
322   - } */
  350 + });
323 351  
324   - }
  352 + });
325 353  
326   - });
  354 + }
327 355  
328 356 });
329 357 </script>
330 358 \ No newline at end of file
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-list-function.js
... ... @@ -249,7 +249,9 @@ var PublicFunctions = function () {
249 249 // 如果线路信息不为空
250 250 if(BusLine) {
251 251  
252   - if(BusLine.yB.length == 0){
  252 + console.log(BusLine);
  253 +
  254 + if(BusLine.zB.length == 0){
253 255  
254 256 layer.confirm('系统生成该线路【'+lineNameV+'】时获取站点与路段异常!请联系管理员或者检查网络连接是否异常!', {
255 257 btn : [ '确认' ]
... ... @@ -307,8 +309,7 @@ var PublicFunctions = function () {
307 309 stationInfo.push(tempM);
308 310  
309 311 }
310   - console.log(stationInfo);
311   - debugger;
  312 +
312 313 // 获取站点之间的距离与时间
313 314 WorldsBMap.getDistanceAndDuration(stationInfo,function(json) {
314 315  
... ... @@ -359,6 +360,8 @@ var PublicFunctions = function () {
359 360 // 限速
360 361 params.speedLimit = '60';
361 362  
  363 + params.baseRes = 'No';
  364 +
362 365 // 保存
363 366 GetAjaxData.collectionSave(params,function(rd) {
364 367  
... ...
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
... ... @@ -711,8 +711,8 @@ var WorldsBMap = function () {
711 711 if (index >= len) {
712 712  
713 713 callback && callback(stationList);
714   -
715   - return;
  714 +
  715 + return ;
716 716 }
717 717  
718 718 var f = arguments.callee;
... ... @@ -730,12 +730,12 @@ var WorldsBMap = function () {
730 730 if(poi) {
731 731  
732 732 /* stationList.push({name:arra[index],potion:{lng:poi.point.lng,lat:poi.point.lat}});*/
733   - stationList.push({name:arra[index].name.replace('公交站',''),wgs:arra[index].wgs,potion:{lng:poi.point.lng,lat:poi.point.lat}});
734   -
735   - f();
  733 + stationList.push({name:arra[index].name.replace('公交车站',''),wgs:arra[index].wgs,potion:{lng:poi.point.lng,lat:poi.point.lat}});
736 734  
737 735 }
738 736  
  737 + f();
  738 +
739 739 });
740 740 }else {
741 741  
... ...