/*

 * 전체 신호제어기를 메모리에 저장해서 등록함(Bean 으로 등록하면 됨)

 */



//신호현시 라인삭제

function emptySignalMarkerPop() {

	if(signalLineArrPoP != null) {

		for(var ii = 0; ii < signalLineArrPoP.length; ii++) {

			signalLineArrPoP[ii].setMap(null);

		}

	}

}



//신호현시 써클삭제

function emptySigCirclePop() {

	if(signalCircleArrPoP != null) {

		for(var ii = 0; ii < signalCircleArrPoP.length; ii++) {

			signalCircleArrPoP[ii].setMap(null);

		}

	}

}



function getPopSignalInfo()

{

	if(getPhaseTimeIdPoP != null) clearTimeout(getPhaseTimeIdPoP);

	if(signalArrPoP != null) signalArrPoP = [];

	if(aRingPhaseValArrPoP != null) aRingPhaseValArrPoP = [];

	if(bRingPhaseValArrPoP != null) bRingPhaseValArrPoP = [];

	if(aRingPhaseArrPoP != null) aRingPhaseArrPoP = [];

	if(bRingPhaseArrPoP != null) bRingPhaseArrPoP = [];

	

	

	var bounds = sigMap.getBounds();

    

	// 영역정보의 남서쪽 정보를 얻어옵니다 

    var swLatlng = bounds.getSouthWest();

    

    // 영역정보의 북동쪽 정보를 얻어옵니다 

    var neLatlng = bounds.getNorthEast();

    

    $("#min_x").val(swLatlng.getLng());

 	$("#min_y").val(swLatlng.getLat());

    $("#max_x").val(neLatlng.getLng());

    $("#max_y").val(neLatlng.getLat());

    

    var url = 'main/getSignalInfo.do';

	var option = {

			url		 : url,

			param	 : {

				minX : $("#min_x").val(),

				minY : $("#min_y").val(),

				maxX : $("#max_x").val(),

				maxY : $("#max_y").val()

			},

			callback : getSignalInfoCallbackPoP

	}

	// ajax로 요청

	callService(option);

	

	//getPhaseTimeIdPoP = setTimeout('getPopSignalInfo()',1000 * 1);

}



function getSignalInfoCallbackPoP(json)

{

	var bottomStr = '';

	var obj = json.data.list;

	this.level = map.getLevel();

	if(obj.length > 0 )

	{

		var regionCd = obj[0].REGION_CD;

		var regionNm = obj[0].REGION_NM;

		var intNo    = obj[0].INT_NO;

		var intNm    = obj[0].INT_NM;

		var xCoord   = obj[0].X_COORD;

		var yCoord   = obj[0].Y_COORD;

		

		var aRing0 = obj[0].A_RING_1_PHASE_CONF_CD;

		var aRing1 = obj[0].A_RING_2_PHASE_CONF_CD;

		var aRing2 = obj[0].A_RING_3_PHASE_CONF_CD;

		var aRing3 = obj[0].A_RING_4_PHASE_CONF_CD;

		var aRing4 = obj[0].A_RING_5_PHASE_CONF_CD;

		var aRing5 = obj[0].A_RING_6_PHASE_CONF_CD;

		var aRing6 = obj[0].A_RING_7_PHASE_CONF_CD;

		var aRing7 = obj[0].A_RING_8_PHASE_CONF_CD;

		

		var bRing0 = obj[0].B_RING_1_PHASE_CONF_CD;

		var bRing1 = obj[0].B_RING_2_PHASE_CONF_CD;

		var bRing2 = obj[0].B_RING_3_PHASE_CONF_CD;

		var bRing3 = obj[0].B_RING_4_PHASE_CONF_CD;

		var bRing4 = obj[0].B_RING_5_PHASE_CONF_CD;

		var bRing5 = obj[0].B_RING_6_PHASE_CONF_CD;

		var bRing6 = obj[0].B_RING_7_PHASE_CONF_CD;

		var bRing7 = obj[0].B_RING_8_PHASE_CONF_CD;

		

		var aRingPhaseVal = obj[0].A_RING_PHASE_VAL;          

		var bRingPhaseVal = obj[0].B_RING_PHASE_VAL;          

		

		var collctDtime = obj[0].COLLCT_DTIME;                   //수집일시

		var commOnOffFlag = obj[0].COMM_ON_OFF_FLAG;             //통신ON/OFF여부

		var contrlrOperModeCd = obj[0].CONTRLR_OPER_MODE_CD;     //제어기운영모드코드

		var aRingPhaseVal = obj[0].A_RING_PHASE_VAL;             //A링 현시값

		var bRingPhaseVal = obj[0].B_RING_PHASE_VAL;             //B링 현시값

		var siglightTurnoffFlag = obj[0].SIGLIGHT_TURNOFF_FLAG;  //신호등소등여부   

		var siglightBlinkFlag = obj[0].SIGLIGHT_BLINK_FLAG;      //신호등점멸여부

		var contrlrManualFlag = obj[0].CONTRLR_MANUAL_FLAG;      //제어기수동여부 

		var intSigCycleCnt = obj[0].INT_SIG_CYCLE_CNT;           //교차로 신호주기 카운트

		var intSigCycleLen = obj[0].INT_SIG_CYCLE_LEN;           //교차로 신호주기 값

		var groupNo = obj[0].GROUP_NO;

		

		var cdNo = regionCd+intNo;

		

		var signal = findSignal(cdNo);

		if(_mapSignal.containsKey(cdNo) == false) 

		{

			signal = new Signal(yCoord, xCoord);

			addSignal(cdNo,signal);

		}

		

		//페이즈 구분을 해주자...

		signalArr.push(signal);

		

		aRingPhaseValArr.push(aRingPhaseVal);

		bRingPhaseValArr.push(bRingPhaseVal);

		aRingPhaseArr.push(new ringPhaseData(aRing0,aRing1,aRing2,aRing3,aRing4,aRing5,aRing6,aRing7));

		bRingPhaseArr.push(new ringPhaseData(bRing0,bRing1,bRing2,bRing3,bRing4,bRing5,bRing6,bRing7));

		sigDataArr.push(new sigMetaData(regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,collctDtime,commOnOffFlag,contrlrOperModeCd,siglightTurnoffFlag,siglightBlinkFlag,contrlrManualFlag,groupNo));

		

		setRingPhasePoP();

	}

}



function setRingPhasePoP()

{

	console.log(sigDataArr.length);

	var regionCd       = sigDataArr[0].regionCd;

	var regionNm       = sigDataArr[0].regionNm;

	var intNo          = sigDataArr[0].intNo;

	var intNm          = sigDataArr[0].intNm;

	var intSigCycleCnt = sigDataArr[0].intSigCycleCnt;

	var intSigCycleLen = sigDataArr[0].intSigCycleLen;

	var collctDtime    = sigDataArr[0].collctDtime;

	var commOnOffFlag   = sigDataArr[0].commOnOffFlag;

	var contrlrOperModeCd = sigDataArr[0].contrlrOperModeCd;

	var siglightTurnoffVal = sigDataArr[0].siglightTurnoffFlag;

	var siglightBlinkVal = sigDataArr[0].siglightBlinkFlag;

	var contrlrManualVal = sigDataArr[0].contrlrManualFlag;

	var groupNo = sigDataArr[0].groupNo;

	var aRingVal;

	var bRingVal;

	

	console.log(commOnOffFlag);

	

	if(commOnOffFlag == 1) signalArr[0].setPhase('commOff',null,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,collctDtime,commOnOffFlag,contrlrOperModeCd,groupNo);

	else if(siglightTurnoffVal == 1) signalArr[0].setPhase('siglightTurnoff',null,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,collctDtime,commOnOffFlag,contrlrOperModeCd,groupNo);

	else if(siglightBlinkVal == 1) signalArr[0].setPhase('siglightBlink',null,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,collctDtime,commOnOffFlag,contrlrOperModeCd,groupNo);

	else if(contrlrManualVal == 1) signalArr[0].setPhase('contrlrManual',null,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,collctDtime,commOnOffFlag,contrlrOperModeCd,groupNo);

	else

	{

		aRingVal = aRingPhaseValArr[0];

		bRingVal = bRingPhaseValArr[0];

		

		if(aRingVal == 0) aRingDeg = aRingPhaseArr[0].ring0;

		else if(aRingVal == 1) aRingDeg = aRingPhaseArr[0].ring1;

		else if(aRingVal == 2) aRingDeg = aRingPhaseArr[0].ring2;

		else if(aRingVal == 3) aRingDeg = aRingPhaseArr[0].ring3;

		else if(aRingVal == 4) aRingDeg = aRingPhaseArr[0].ring4;

		else if(aRingVal == 5) aRingDeg = aRingPhaseArr[0].ring5;

		else if(aRingVal == 6) aRingDeg = aRingPhaseArr[0].ring6;

		else if(aRingVal == 7) aRingDeg = aRingPhaseArr[0].ring7;

		else aRingDeg = '';

		

		if(bRingVal == 0) bRingDeg = bRingPhaseArr[0].ring0;

		else if(bRingVal == 1) bRingDeg = bRingPhaseArr[0].ring1;

		else if(bRingVal == 2) bRingDeg = bRingPhaseArr[0].ring2;

		else if(bRingVal == 3) bRingDeg = bRingPhaseArr[0].ring3;

		else if(bRingVal == 4) bRingDeg = bRingPhaseArr[0].ring4;

		else if(bRingVal == 5) bRingDeg = bRingPhaseArr[0].ring5;

		else if(bRingVal == 6) bRingDeg = bRingPhaseArr[0].ring6;

		else if(bRingVal == 7) bRingDeg = bRingPhaseArr[0].ring7;

		else bRingDeg = '';

		

		signalArr[0].setPhase(aRingDeg,bRingDeg,regionCd,regionNm,intNo,intNm,intSigCycleCnt,intSigCycleLen,collctDtime,commOnOffFlag,contrlrOperModeCd,groupNo);

	}

	

}



function findSignalPoP(Id) {

	return _mapSignalPoP.get(Id);

};



function addSignalPoP(Id, Obj) {

	_mapSignalPoP.put(Id, Obj);

	return _mapSignalPoP.size();

};





//#define RadToDeg(x) (57.29577951 * x)

//#define DegToRad(x) (0.017453293 * x)

Number.prototype.toRadians = function() { 

	return this * 0.017453293; 

	//return this * Math.PI / 180; 

};

Number.prototype.toDegrees = function() { 

	return this * 57.29577951; 

	//return this * 180 / Math.PI; 

};





function SignalDrawPoP(ringA, ringB, lat, lng, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, collctDtime, commOnOffFlag, contrlrOperModeCd, groupNo) {

	this.initialize(ringA, ringB, lat, lng, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, collctDtime, commOnOffFlag, contrlrOperModeCd, groupNo);

};



SignalDrawPoP.prototype = {

	ringA : null,

    ringB : null,

    Lat : 0,

	Lng : 0,

	regionCd : null,

	regionNm : null,

	intNo : null,

	intNm : null,

	intSigCycleCnt : 0,

	intSigCycleLen : 0,

	collctDtime : null,

	commOnOffFlag : null,

	contrlrOperModeCd : null,

	groupNo : 0,



	posA : null,

	posB : null,

	

	typeA : 0,

	typeB : 0,

	mapCircle : null,

	mapRingA : null,

	mapRingB : null,

	

	listCoordA : null,

	listCoordB : null,

	

    initialize : function(ringA, ringB, lat, lng, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, collctDtime, commOnOffFlag, contrlrOperModeCd, groupNo) {

    	

    	this.ringA = ringA;

    	this.ringB = ringB;

    	this.Lat = lat;

    	this.Lng = lng;

    	this.regionCd = regionCd;

    	this.regionNm = regionNm;

    	this.intNo = intNo;

    	this.intNm = intNm;

    	this.intSigCycleCnt = intSigCycleCnt;

    	this.intSigCycleLen = intSigCycleLen;

    	this.collctDtime = collctDtime;

    	this.commOnOffFlag = commOnOffFlag;

    	this.contrlrOperModeCd = contrlrOperModeCd;

    	this.groupNo = groupNo;

    	

    	this.posA = new SCoord(lat, lng);

    	this.posB = new SCoord(lat, lng);

    	

		this.mapRingA = null;

    	this.mapRingB = null;

    	

    	this.listCoordA = new Array();

		this.listCoordB = new Array();

		

		this.typeA = this.checkRingType(this.ringA);

		this.typeB = this.checkRingType(this.ringB);

		

		if (this.typeA == 0 && this.typeB == 0) {

			return;	

		}



		var degAI = 0; var degAO = 0; var degBI = 0; var degBO = 0; 

		

		// 진입, 진출 Degree 각도를 얻는다.

		if (this.typeA == 1 || this.typeA == 2 || this.typeA == 3) {

			degAI = Number(this.ringA.substring(1,4));

			degAO = Number(this.ringA.substring(4,7));

			

			if(this.typeA == 1 || this.typeA == 2)

			{

				if (degAI >= 360) degAI = degAI - 360;

				if (degAO >= 360) degAO = degAO - 360;

			}

			else if(this.typeA == 3)

			{

				if(regionCd == 'L01')

				{

					degAO = degAI + 180;

					if (degAI >= 360) degAI = degAI - 360;

					if (degAO >= 360) degAO = degAO - 360;

				}

				else

				{

					if(degAO != 0)

					{

						return this.drawPedestrians();

					}

					else

					{

						degAI += 90;

						degAO = degAI + 180;

						if(degAI > 360) degAI = degAI - 360;

						if(degAO > 360) degAO = degAO - 360;

					}

				}

				/*if(degAO != 0)

				{

					return this.drawPedestrians();

				}

				else

				{

					degAI += 90;

					degAO = degAI + 180;

					if(degAI > 360) degAI = degAI - 360;

					if(degAO > 360) degAO = degAO - 360;

				}*/

			}

			

		}

		

		if (this.typeB == 1 || this.typeB == 2 || this.typeB == 3) {

			degBI = Number(this.ringB.substring(1,4));

			degBO = Number(this.ringB.substring(4,7));

			

			if(this.typeB == 1 || this.typeB == 2)

			{

				if (degBI >= 360) degBI = degBI - 360;

				if (degBO >= 360) degBO = degBO - 360;

			}

			else if(this.typeB == 3)

			{

				if(regionCd == 'L01')

				{

					degBO = degBI + 180;

					if (degBI >= 360) degBI = degBI - 360;

					if (degBO >= 360) degBO = degBO - 360;

				}

				else

				{

					if(degBO != 0)

					{

						return this.drawPedestrians();

					}

					else

					{

						degBI += 90;

						degBO = degBI + 180;

						if(degBI > 360) degBI = degBI - 360;

						if(degBO > 360) degBO = degBO - 360;

					}

				}

				/*if(degBO != 0)

				{

					return this.drawPedestrians();

				}

				else

				{

					degBI += 90;

					degBO = degBI + 180;

					if(degBI > 360) degBI = degBI - 360;

					if(degBO > 360) degBO = degBO - 360;

				}*/

			}

			

		}

		

		if (((this.typeA == 1 || this.typeA == 2 || this.typeA == 3) && this.typeB == 0) || ((this.typeB == 1 || this.typeB == 2 || this.typeB == 3) && this.typeA == 0)) {

			if (this.typeA == 3) {

				degAI = 0;

				degAO = 180;

			}

			if (this.typeB == 3) {

				degBI = 0;

				degBO = 180;

			}

			

			return this.createMap(degAI, degAO, degBI, degBO);

		}



		var a;

		var gapAngle;

		

		// ARing

		if (this.typeA == 1 || this.typeA == 2) {

			if(this.typeA == 1)

			{

				//직진

				gapAngle = 270;

			}

			else 

			{

				//좌회전

				gapAngle = 90;

			}

			

			a = degAI + gapAngle;

			if (a >= 360) a = a - 360;

			

			this.moveCenterPos(this.posA, a, false);

		}

		else if (this.typeA == 3) 

		{

			var diff = degAI;

			if (diff > 180) {

				diff = diff - 180;

				gapAngle = 90;

			}else{

				gapAngle = 270;

			}

			

			a = diff + gapAngle;

			if (a >= 360) a = a - 360;

			

			//보행자

			this.moveCenterPos(this.posA, a, true);

		}

		else if (this.typeA == 4 || this.typeA == 5 || this.typeA == 6 || this.typeA == 7) {

			return this.createErrMap(this.typeA);

		}

		

		// BRing

		if (this.typeB == 1 || this.typeB == 2) {

			if(this.typeB == 1)

			{

				//직진

				gapAngle = 270;

			}

			else 

			{

				//좌회전

				gapAngle = 90;

			}

			

			a = degBI + gapAngle;

			if (a >= 360) a = a - 360;

			

			this.moveCenterPos(this.posB, a, false);

		}

		else if (this.typeB == 3) {

			var diff = degBI;

			if (diff > 180) {

				diff = diff - 180;

				gapAngle = 90;

			}else{

				gapAngle = 270;

			}

			

			a = diff + gapAngle;

			if (a >= 360) a = a - 360;

			

			//보행자

			this.moveCenterPos(this.posB, a, true);

		}

		

		return this.createMap(degAI, degAO, degBI, degBO);

    },



	moveCenterPos : function(pos, deg, pedestrians) {

		

		var rad = deg.toRadians();

		var deltaLat = 0.005 * Math.cos(rad);

		var deltaLng = 0.005 * Math.sin(rad);

		

		deltaLat = (deltaLat * 360) / 40000;

		deltaLng = (deltaLng * 360) / 40000;

		pos.Lat = pos.Lat + deltaLat;

		pos.Lng = pos.Lng + deltaLng;

		

	},

    

	checkRingType : function(ring) {

		if (ring == null) 

    		return 0;	//유효하지 않은 유형

    	

    	var type = ring.substring(0,1);

		if (type == "S") return 1;	//직진

		if (type == "L") return 2;  //좌회전

		if (type == "P") return 3;	//보행자

		

		if (ring == "commOff") return 4;         //통신이상

		if (ring == "siglightTurnoff") return 5; //신호등소등여부

		if (ring == "siglightBlink") return 6;   //신호등점멸여부

		if (ring == "contrlrManual") return 7;   //제어기수동여부

		

		return 0;	//알수없음

    },



    draw : function(map) {

		if (this.mapRingA != null) this.mapRingA.setMap(map);

		if (this.mapRingB != null) this.mapRingB.setMap(map);

    },



    createMap : function(degAI, degAO, degBI, degBO) {

    	

    	var lineLengthA;            //A라인길이

    	var strokeWeightA;          //A라인두께

		var endArrawA = true;       //A라인화살표유무

		var strokeStyleA = 'solid'; //A라인 라인종류 

		var colorA = '#0000FF';     //A라인 색상

		

		var lineLengthB;            //B라인길이

		var strokeWeightB;          //B라인두께

		var endArrawB = true;       //B라인화살표유무

		var strokeStyleB = 'solid'; //B라인 라인종류

		var colorB = '#0000FF';     //B라인 색상

		

		if (this.typeA != 0) {

			if(this.typeA == 3) //보행자

			{

				lineLengthA = 0.008;

				strokeWeightA = 8;

				endArrawA = false;

				strokeStyleA = 'shortdot';

				colorA = '#000000';

			}

			else

			{

				lineLengthA = 0.009;

				strokeWeightA = 9;

				endArrawA = true;

				strokeStyleA = 'solid';

				colorA = '#0000FF';

			}

			

			this.listCoordA.push(new SCoord(lineLengthA * Math.cos(degAI.toRadians()), lineLengthA * Math.sin(degAI.toRadians())));

			this.listCoordA.push(new SCoord(this.posA.Lat, this.posA.Lng));

			this.listCoordA.push(new SCoord(lineLengthA * Math.cos(degAO.toRadians()), lineLengthA * Math.sin(degAO.toRadians())));

		}

		

		if (this.typeB != 0) {

			if(this.typeB == 3) //보행자

			{

				lineLengthB = 0.008;

				strokeWeightB = 8;

				endArrawB = false;

				strokeStyleB = 'shortdot';

				colorB = '#000000';

			}

			else

			{

				lineLengthB = 0.009;

				strokeWeightB = 9;

				endArrawB = true;

				strokeStyleB = 'solid';

				colorB = '#0000FF';

			}

			

			this.listCoordB.push(new SCoord(lineLengthB * Math.cos(degBI.toRadians()), (lineLengthB) * Math.sin(degBI.toRadians())));

			this.listCoordB.push(new SCoord(this.posB.Lat, this.posB.Lng));

			this.listCoordB.push(new SCoord(lineLengthB * Math.cos(degBO.toRadians()), (lineLengthB) * Math.sin(degBO.toRadians())));

		}

		

		for(var ii = 0; ii < 3; ii++) {

			if (ii == 1) continue;	//중심좌표는 보정이 필요없음.

			

	    	if (this.typeA != 0) {

		    	this.listCoordA[ii].Lat = (this.listCoordA[ii].Lat * 360) / 40000;	//delta lat

		    	this.listCoordA[ii].Lng = (this.listCoordA[ii].Lng * 360) / 40000;	//delta lng

		    	this.listCoordA[ii].Lat = this.posA.Lat + this.listCoordA[ii].Lat;

		    	this.listCoordA[ii].Lng = this.posA.Lng + this.listCoordA[ii].Lng;

	    	}

	    	if (this.typeB != 0) {

		    	this.listCoordB[ii].Lat = (this.listCoordB[ii].Lat * 360) / 40000;	//delta lat

		    	this.listCoordB[ii].Lng = (this.listCoordB[ii].Lng * 360) / 40000;	//delta lng

		    	this.listCoordB[ii].Lat = this.posB.Lat + this.listCoordB[ii].Lat;

		    	this.listCoordB[ii].Lng = this.posB.Lng + this.listCoordB[ii].Lng;

	    	}

		}

		

		if (this.typeA != 0) {

			this.mapRingA = new daum.maps.Polyline({

		          path: [

		              new daum.maps.LatLng(this.listCoordA[0].Lat, this.listCoordA[0].Lng),

		              new daum.maps.LatLng(this.listCoordA[1].Lat, this.listCoordA[1].Lng),

		              new daum.maps.LatLng(this.listCoordA[2].Lat, this.listCoordA[2].Lng)

		          ],

		          strokeWeight: strokeWeightA,

		          strokeColor: colorA,

		          strokeOpacity: 1,

		          strokeStyle: strokeStyleA,

		          endArrow: endArrawA,

		          zIndex: 10

		    });

			

			this.mapRingA.setMap(map);

    	}

    	

    	if (this.typeB != 0) {

			this.mapRingB = new daum.maps.Polyline({

	          path: [

	              new daum.maps.LatLng(this.listCoordB[0].Lat, this.listCoordB[0].Lng),

	              new daum.maps.LatLng(this.listCoordB[1].Lat, this.listCoordB[1].Lng),

	              new daum.maps.LatLng(this.listCoordB[2].Lat, this.listCoordB[2].Lng)

	          ],

	          strokeWeight: strokeWeightB,

	          strokeColor: colorB,

	          strokeOpacity: 1,

	          strokeStyle: strokeStyleB,

	          endArrow: endArrawB,

	          zIndex: 10

			});

			

			this.mapRingB.setMap(map);

		}

    },

    

    createErrMap : function(type){

    	var lat = this.Lat;

    	var lng = this.Lng;

    	var eventVal = null;

    	

    	if(type == 6) {

    		eventVal = this.siglightBlinkImg();

    	}

    	else 

    	{

    		var fillColor = '#FF0000';

        	if(type == 5) fillColor = '#FF007F'; 

        	if(type == 7) fillColor = '#00D8FF';

        	

        	this.mapRingA = new daum.maps.Circle({

    		    center : new daum.maps.LatLng(lat, lng),

    		    radius: 20,

    		    strokeWeight: 10,

    		    strokeColor: '#000000',

    		    strokeOpacity: 1,

    		    strokeStyle: 'solid',

    		    fillColor: fillColor,

    		    fillOpacity: 0.5,

    		    zIndex: 20

    		});

        	

        	this.mapRingA.setMap(map);

        	eventVal = this.mapRingA; 

    	}

    },

    

    drawPedestrians : function(){

    	var lat = this.Lat;

    	var lng = this.Lng;

    	

    	var position = new daum.maps.LatLng(lat, lng);

    	var src = _pedeImgSrc;

    	var size = new daum.maps.Size(175,175),

    	           options = {

    					offset : new daum.maps.Point(85,85)

    				};

    	

    	var markerImage = new daum.maps.MarkerImage(src, size, options);

    	this.mapRingA = new daum.maps.Marker({

    		position : position,

    		image : markerImage

    	});

    	

    	this.mapRingA.setMap(map);

    },

    

    siglightBlinkImg : function()

    {

    	var lat = this.Lat;

    	var lng = this.Lng;

    	var icon = new daum.maps.MarkerImage(

    			'images/walking100.png',

			    new daum.maps.Size(175,175),

			    {

			        offset: new daum.maps.Point(85,85),

			        alt: "점멸"

			    }

			);

		

		this.mapCircle = new daum.maps.Marker({

					    position: new daum.maps.LatLng(lat, lng),

					    image: icon,

					    zIndex: 10

					});

		

		this.mapCircle.setMap(map);

		

		return this.mapCircle;

    }

    

}



/*

 * 신호제어기 정보

 */

function SignalPoP(yCoord, xCoord)

{

	this.initialize(yCoord, xCoord);

}



SignalPoP.prototype = {

	Lat  : 0,

	Lng  : 0,



	drawSignalPop     : null,	/* 현재 표출될 SignalDraw class */

	listDrawSignalPoP : null, 	/* 표출현시 목록을 저장할 list array: 최초 한번만 좌표를 계산하도록 하기 위함, 성능에 따라 map 사용 가능 */



	initialize : function(Lat, Lng) {

		this.Lat   = yCoord;

		this.Lng   = xCoord;

		this.drawSignalPop = null;	/* 현재 표출될 SignalDraw class */

		

		/* 

		 * Phase 정보를 저장할 목록: 최초 한번만 좌표를 계산하도록 하기 위함, 성능에 따라 map 사용 가능 

		 * Phase 를 개별적으로 저장했으나 RingA+RingB를 합쳐서 관리하도록 수정함.

		 */

		

		this.listDrawSignalPoP = [];

		

		var mapCircle = new daum.maps.Circle({

		    center : new daum.maps.LatLng(this.Lat, this.Lng),

		    radius: 20,

		    strokeWeight: 10,

		    strokeColor: '#FF0000',

		    strokeOpacity: 1,

		    strokeStyle: 'solid',

		    fillColor: '#fff',

		    fillOpacity: 1

		});

		

		this.mapCircle.setMap(map);

	},



	/*

	 * 신호제어기 정보를 돌려줌

	 */

	getInfo : function() {

    	return this.Id + ', ' + this.Lat + '. ' + this.Lng + ", " + this.listDrawSignal.length + ", " + this.drawSignal;

	},

	/*

	 * 현재 Phase 정보를 설장함. 설정한 것에 따라 this.APhase, this.BPhase 정보가 설정됨

	 */

	setPhase : function(ARing, BRing, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, collctDtime, commOnOffFlag, contrlrOperModeCd, groupNo) {

		console.log(ARing);

		//신호라인 삭제

		if(this.drawSignalPop != null) this.empty(map);

		

		this.drawSignalPop = new SignalDraw(ARing, BRing, this.Lat, this.Lng, regionCd, regionNm, intNo, intNm, intSigCycleCnt, intSigCycleLen, collctDtime, commOnOffFlag, contrlrOperModeCd, groupNo);

	},

	

	empty : function(map) {

		if(this.drawSignalPop.mapRingA != null) this.drawSignalPop.mapRingA.setMap(null);

		if(this.drawSignalPop.mapRingB != null) this.drawSignalPop.mapRingB.setMap(null);

		if(this.drawSignalPop.mapCircle != null) this.drawSignalPop.mapCircle.setMap(null);

	}



};



function drawPhaseLine(regionCd,ringPhase, lat, lng)

{

	var ringType;

	if(typeof ringPhase != 'undefined' || ringPhase != null) ringType = checkPhaseRingType(ringPhase);

	else return;

	

	// 진입, 진출 Degree 각도를 얻는다.

	var degIn = Number(ringPhase.substring(1,4));

	var degOut = Number(ringPhase.substring(4,7));

	if(ringType == 1 || ringType == 2)

	{

		if (degIn  > 360) degIn = degIn - 360;

		if (degOut > 360) degOut = degOut - 360;

	}

	else if(ringType == 3)

	{

		if(regionCd == 'L01')

		{

			degOut = degIn + 180;

			if (degIn  > 360) degIn = degIn - 360;

			if (degOut > 360) degOut = degOut - 360;

		}

		else

		{

			if(degOut != 0)

			{

				return drawPhasePedestrians();

			}

			else

			{

				degIn += 90;

				degOut = degIn + 180;

				if(degIn  > 360) degIn  = degIn - 360;

				if(degOut > 360) degOut = degOut - 360;

			}

		}

	}

	

	var turnLeftAngle = 135;

	var a;

	var gapAngle;

	var diff = degIn;

	

	if(ringType == 1) gapAngle = 270;

	else if(ringType == 2) gapAngle = 90;

	else if(ringType == 3) 

	{

		if (diff > 180) 

		{

			diff = diff - 180;

			gapAngle = 90;

		}

		else

		{

			gapAngle = 270;

		}

	}

	

	a = diff + gapAngle;

	if (a >= 360) a = a - 360;

	

	movePhaseCenterPos(lat, lng, a);

	createPhaseMap(ringType, degIn, degOut);

}



function checkPhaseRingType(ring)

{

	var type = ring.substring(0,1);

	if (type == "S") return 1;	//직진

	if (type == "L") return 2;  //좌회전

	if (type == "P") return 3;	//보행자	

}



function movePhaseCenterPos(lat, lng, deg)

{

	var pLat = parseFloat(lat);

	var rad = deg.toRadians();

	var deltaLat = 0.001 * Math.cos(rad);

	var deltaLng = 0.001 * Math.sin(rad);

	

	deltaLat = (deltaLat * 360) / 40000;

	deltaLng = (deltaLng * 360) / 40000;

	centerLat = parseFloat(pLat) + parseFloat(deltaLat);

	centerLng = parseFloat(lng) + parseFloat(deltaLng);

	

	//console.log('centerLat : '+centerLat);

	//console.log('centerLng : '+centerLng);

}



function drawPhasePedestrians()

{

	var pLat = parseFloat(_YCoord);

	var pLng = parseFloat(_XCoord);

	var position = new daum.maps.LatLng(pLat - 0.00002, pLng + 0.00003);

	var src = 'images/walking60.png';

	var size = new daum.maps.Size(40,40),

	           options = {

					offset : new daum.maps.Point(29,29),

					shape : 'poly'

				};

	

	var markerImage = new daum.maps.MarkerImage(src, size, options);

	var mapRing = new daum.maps.Marker({

		position : position,

		image : markerImage

	});

	

	mapRing.setMap(pMap);

}



function createPhaseMap(ringType, degIn, degOut)

{

	var color = '#0000FF';//blue

	var distance = 0.005;

	var strokeWeight = 3;

	var endArraw = true;

	var strokeStyle = 'solid';

	

	if (ringType != 0) {

		if (ringType == 3) {

			endArraw = false;

			distance = 0.0055;

			strokeWeight = 4;

			strokeStyle = 'shortdot';

			color = '#000000';//black

		}

		

		listCoord.push(new SCoord(distance * Math.cos(degIn.toRadians()), distance * Math.sin(degIn.toRadians())));

		listCoord.push(new SCoord(centerLat, centerLng));

		listCoord.push(new SCoord(distance * Math.cos(degOut.toRadians()), distance * Math.sin(degOut.toRadians())));

		

		for(var ii = 0; ii < 3; ii++) {

			if (ii == 1) continue;	//중심좌표는 보정이 필요없음.

			

	    	listCoord[ii].Lat = (listCoord[ii].Lat * 360) / 40000;	//delta lat

	    	listCoord[ii].Lng = (listCoord[ii].Lng * 360) / 40000;	//delta lng

	    	listCoord[ii].Lat = centerLat + listCoord[ii].Lat;

	    	listCoord[ii].Lng = centerLng + listCoord[ii].Lng;

		}

		

		var mapRing = new daum.maps.Polyline({

	          path: [

	              new daum.maps.LatLng(listCoord[0].Lat, listCoord[0].Lng),

	              new daum.maps.LatLng(listCoord[1].Lat, listCoord[1].Lng),

	              new daum.maps.LatLng(listCoord[2].Lat, listCoord[2].Lng)

	          ],

	          strokeWeight: strokeWeight,

	          strokeColor: color,

	          strokeOpacity: 1,

	          strokeStyle: strokeStyle,

	          endArrow: endArraw,

	          zIndex: 10

	    });

		

		mapRing.setMap(pMap);

		

		/*for(var ii = 0; ii < pMapArr.length; ii++)

		{

			//console.log(pMapArr[ii]);

			//mapRing.setMap(pMap);

			console.log(pMapArr[ii]);

			if(ringGubun == 'aRing0') mapRing.setMap(pMapArr[0]);

			if(ringGubun == 'aRing1') mapRing.setMap(pMapArr[1]);

			if(ringGubun == 'aRing2') mapRing.setMap(pMapArr[2]);

			if(ringGubun == 'aRing3') mapRing.setMap(pMapArr[3]);

			if(ringGubun == 'aRing4') mapRing.setMap(pMapArr[4]);

			if(ringGubun == 'aRing5') mapRing.setMap(pMapArr[5]);

			if(ringGubun == 'bRing0') mapRing.setMap(pMapArr[6]);

			if(ringGubun == 'bRing1') mapRing.setMap(pMapArr[7]);

			if(ringGubun == 'bRing2') mapRing.setMap(pMapArr[8]);

			if(ringGubun == 'bRing3') mapRing.setMap(pMapArr[9]);

			if(ringGubun == 'bRing4') mapRing.setMap(pMapArr[10]);

			if(ringGubun == 'bRing5') mapRing.setMap(pMapArr[11]);

		}*/

		

	}

	

}

