station-positions-function.js 9.08 KB
/**
 * 函数
 */

var PositionsPublicFunctions = function () {
 
	var PubFun = {
			
			initStationInfo : function(id) {
				
				PositionsPublicFunctions.getStationRouteInfo(id,function(r) {
					
					var Station = r[0];
					
					PositionsStationObj.setAddStation(Station);
					
					var len = r.length;
					
					if(len>0) {
						
						console.log(r[0]);
						
						var markTypeStr = '';
						
						if(r[0].stationRouteStationMark=='B') {
							
							markTypeStr='起点站';
							
						}else if(r[0].stationRouteStationMark=='Z') {
							
							markTypeStr ='中途站';
							
							
						}else if(r[0].stationRouteStationMark=='E') {
							
							markTypeStr='终点站';
							
						}
						
						var stationShapesType = r[0].stationShapesType;
						
						// 获取中心坐标点字符串分割
						var BJwpoints = r[0].stationJwpoints.split(' ');
						
						// 中心坐标点
						var point = new BMap.Point(BJwpoints[0], BJwpoints[1]);
						
						var htm = 	'<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>'+
									'<span style="color:#DDD;font-size: 15px;">站点名称:' + r[0].stationName + '</span>' + 
									'<span class="help-block" style="color:#DDD;font-size: 15px;">站点编码:' + r[0].stationCode + '</span>' +
									'<span class="help-block" style="color:#DDD;font-size: 15px;">站点序号:' + r[0].stationRouteCode + '</span>' +
									'<span class="help-block" style="color:#DDD;font-size: 15px;">站点类型:' + markTypeStr + '</span>' +
									'<span class="help-block" style="color:#DDD;font-size: 15px;">纬度坐标:' + r[0].stationJwpoints + '</span>' +
									'<span class="help-block" style="color:#DDD;font-size: 15px;">到站时间:' + r[0].stationRouteToTime + '&nbsp;分钟</span>' +
									'<span class="help-block" style="color:#DDD;font-size: 15px;">到站距离:' + r[0].stationRouteDistances + '&nbsp;公里</span>' +
									'<span class="help-block" style="color:#DDD;font-size: 15px;">范围半径:' + r[0].stationRadius + '</span>' +
									'<span class="help-block" style="color:#DDD;font-size: 15px;">版本 号:' + r[0].stationRouteVersions + '</span>' +
									'<span class="help-block"  style="width: 100%;font-size: 15px;;color:#DDD;'+ 
									'overflow: hidden; white-space: nowrap;  text-overflow: ellipsis; " title="'+ 
									r[0].stationRouteDescriptions +'" >说明/描述:' + r[0].stationRouteDescriptions + '</span>' ;
						
						// 信息窗口参数属性
				  		var opts = {
				  				
									// 信息窗口宽度
									width : 200,
									
									// 信息窗口高度
									height : 450,
									
									// 信息窗位置偏移值。
									offset: new BMap.Size(500,80),
									
									//标题
									title : '<h4 style="color:#FFFFFF">'+r[0].stationName+'站详情</h4>',
									
									//设置不允许信窗发送短息
									enableMessage : false,
									
									//是否开启点击地图关闭信息窗口
									enableCloseOnClick : false,
									
									// 是否开启信息窗口打开时地图自动移动(默认开启)。(自 1.1 新增)
									enableAutoPan:true
							};
						
						if(stationShapesType == 'r') {
							
							// 画圆
							StationPositionsWorldsBMap.pointsCircle(r,point,htm,opts);
							
						}else if(stationShapesType == 'd'){
							
							// 画多边形
							StationPositionsWorldsBMap.pointsPolygon(r,point,htm,opts);
							
						}
						
					}
					
				});
			},
			
			editSeteditStationParmasValue : function(points,gLonx,gLaty,bPolygonGridValue,gPolygonGridVlaue,shapesTypeValue,radiusValue) {
				
				// 百度地图经纬度坐标中心点
				stationObj[0].stationJwpoints = points;
				
				// WGS经度
				stationObj[0].stationGlonx = gLonx;
				
				//  WGS经度
				stationObj[0].stationGlaty = gLaty;
				
				// 百度坐标点图形集合 
				stationObj[0].stationGPloyonGrid = gPolygonGridVlaue;
				
				// WGS坐标点图形集合
				stationObj[0].stationBPolyonGrid = bPolygonGridValue;
				
				// 图形类型
				stationObj[0].stationShapesType = shapesTypeValue;
				
				// 圆形半径
				stationObj[0].stationRadius = radiusValue;
				
			},
			
			// 原百度坐标转WGS坐标
			getFormPointEToWGS: function(points,callback) {
				
				// 获取长度
				var len = points.length;
				
				(function(){
					
					 if (!arguments.callee.count) {
						 
						 arguments.callee.count = 0;
						 
					 }
					 
					 arguments.callee.count++;
					 
					 var index = parseInt(arguments.callee.count) - 1;
					 
					 if (index >= len) {
						 
						 callback && callback(points);
			        	  
			              return;
			          }
					 
					 var f = arguments.callee;
					 
					 $.ajax({
						  
			              url: 'http://api.zdoz.net/bd2wgs.aspx',
			              
			              data: {lat: points[index].potion.lat , lng: points[index].potion.lng},
			              
			              dataType: 'jsonp',
			              
			              success: function(r){
			            	  
			            	  if(r) {
			            		  
			            		  points[index].WGSpotion = r;
			            		  
			            	  }
			            	  
			            	  f();
			              }
			          });
					
				})();
				
			},
			
			setFormValue : function(stationObj) {

				// 站点ID
				$('#stationIdInput').val(stationObj.stationId);
				
				// 站点路由ID
				$('#stationRouteIdInput').val(stationObj.stationRouteId);
				
				// 站点路由线路Id
				$('#stationRouteLineInput').val(stationObj.stationRouteLine);
				
				// 线路编码
				$('#lineCodeInput').val(stationObj.stationRouteLIneCode);
				
				// WGS坐标点图形集合
				$('#bPolygonGridInput').val(stationObj.stationBPolyonGrid);
				
				// 获取站点名称元素设值
				$('#stationNameInput').val(stationObj.stationName);
				
				// 获取站点编码元素设值
				$('#stationCodInput').val(stationObj.stationCode);
				
				// 获取站点类型元素设值
				$('#stationMarkSelect').val(stationObj.stationRouteStationMark);
				
				// 获取站点方向元素设值
				$('#stationdirSelect').val(stationObj.stationRoutedirections);
				
				// 获取站点道路编码元素设值
				$('#roadCodingCodInput').val(stationObj.stationRoadCoding);
				
				// 百度地图经纬度坐标中心点
				$('#bJwpointsInput').val(stationObj.stationJwpoints);
				
				// 获取图形类型元素,并添加值
				$('#shapesTypeSelect').val(stationObj.stationShapesType);
				
				// 获取半径元素,并添加值
				$('#radiusInput').val(stationObj.stationRadius);
				
				// 是否撤销
				$('#destroySelect').val(stationObj.stationRouteDestroy);
				
				// 到站时间
				$('#toTimeInput').val(stationObj.stationRouteToTime);
				
				// 到站距离
				$('#distancesInput').val(stationObj.stationRouteDistances);
				
				// 描述/说明
				$('#descriptionsTextarea').val(stationObj.stationRouteDescriptions);
				
			},
			
			// 树数据获取
			getStation : function(id_,dir_,callback) {
				
				var treeDateJson = [];
						
				$get('/stationroute/findStations',{'line.id_eq' : id_ , 'directions_eq' : dir_},function(resultdata) {
					
					treeDateJson = createTreeData(resultdata);
							
					callback && callback(treeDateJson);
							
				});
						
			},
			
			findUpStationRouteCode : function(lineId,diraction,stationRouteCode,callback) {
				
				$get('/stationroute/findUpStationRouteCode',{lineId:lineId,direction:diraction,stationRouteCode:stationRouteCode},function(result) {
					
					callback && callback(result);
					
				});
				
			},
			
			getStationRouteInfo : function(stationId,callback){
				
				$get('/stationroute/findStationRouteInfo',{id:stationId},function(r) {
					
					callback && callback(r);
					
				});
				
			},
			
			// 站点更新
			stationUpdate : function(station,callback) {
				
				$post('/station/stationUpdate',station,function(data) {
					
					callback && callback(data);
					
				});
				
			},
			
			clearRefresh : function() {
				
				// 清楚地图覆盖物
				mapB.clearOverlays();
				
				$('#eidt').attr("disabled",false);
			 	
			  	$('#eidt').removeClass('btn disabled');
			  	
			  	$('#eidt').addClass('btn');
				
				stationObj='';
				
				PublicFunctions.initStationInfo(stationId,mapB);
				
			},
			
			getstationObjData : function(){
				
				return stationObj;
			},
			
			getStationIdValue : function() {
				
				return stationId;
			},
			
			setStationNameValue : function(editStationName) {
				
				stationObj[0].stationName = editStationName;
				
				return stationObj;
			},
			
			getPolygonObj : function() {
				
				return polygon;
			},
			
			getMarkerObj : function() {
				
				return marker;
			},
			
			getCircleObj : function() {
				
				return circle;
				
			}
	}
	
	return PubFun ;
	
}();