class TRoutes { constructor(map) { this.routes = []; //Список маршрутов } //Получаем список объектов //Фильтруем объекты для заполнения в таблицу filtering() { showProgressBar(document.getElementById('div_tbl_e')); var data = { name: "", type: "" }; $.ajax({ url: '/monitoring/pscripts/routes.php', data: JSON.stringify(data), contentType: 'application/json; charset=utf-8', type: "POST", dataType: "json", success: function(thiz){return function(data,status){ if(status=='success') { thiz.routes = []; //Удаляю старые объекты g_vectorSourceRoute.clear(); //Удаляю все отображения for(i=0;i'+trt('Route_name')+''+trt('Points')+''+trt('Length')+''; var theTable = document.getElementById('thetable_e'); for(i=0;i'; tr.appendChild(td); td = document.createElement('td'); td.style.cssText="text-align: center;"; td.innerHTML=''; tr.appendChild(td); td = document.createElement('td'); td.style.cursor='pointer'; td.innerHTML=this.routes[i].name; td.onclick=function(route){ return function(){ route.goToStart(); } }(this.routes[i]); tr.appendChild(td); td = document.createElement('td'); td.style.cssText='cursor:pointer;text-align:right;'; td.innerHTML=this.routes[i].count; td.onclick=function(route){ return function(){ route.goToStart(); } }(this.routes[i]); tr.appendChild(td); td = document.createElement('td'); td.style.cssText='cursor:pointer;white-space:nowrap;text-align:right;'; td.innerHTML=this.routes[i].length+' '+trt('km'); td.onclick=function(route){ return function(){ route.goToStart(); } }(this.routes[i]); tr.appendChild(td); /*td = document.createElement('td'); td.innerHTML=this.routes[i].value; tr.appendChild(td);*/ /*td = document.createElement('td'); td.innerHTML=this.routes[i].date; tr.appendChild(td);*/ theTable.tBodies[0].appendChild(tr); //Формирую раскрывающийся список tr = document.createElement('tr'); tr.id=this.routes[i].id; tr.style.cssText="background-color:var(--back-color-3);display:none"; td = document.createElement('td'); td.colSpan=6; var html='
'; html+=''+trt('Bus_station')+': '+trt('Edit')+' '+this.routes[i].station+'
'; html+=''+trt('Carrier')+': '+trt('Edit')+' '+this.routes[i].carriers+'
'; html+=''+trt('Schedule')+': '+trt('Edit')+'
'; for(let j=0;j
'; } html+='Контрольные точки: '+trt('Create')+' '+trt('Edit')+'
'; for(var j=0;j
'+this.routes[i].checkpoints[j].direction+': '+this.routes[i].checkpoints[j].time+' '+this.routes[i].checkpoints[j].name+'
'+trt('Edit')+' '+trt('Delete')+'
'; } html+='
'+trt('Swap')+' A B'+trt('Edit')+''+trt('Delete')+'
'; td.innerHTML=html; tr.appendChild(td); theTable.tBodies[0].appendChild(tr); //При щелчке на ячейку перемещаем карту на точку /*var cell=document.getElementById("cell_e_"+this.routes[i].id); cell.onclick=function(object){ return function(){ object.getGeoJSON(); } }(this.routes[i]);*/ var cell=document.getElementById("route_ch_"+this.routes[i].id); cell.onclick=function(route){ return function(){ var chb=document.getElementById("route_ch_"+route.id); route.setVisibility(chb.checked); } }(this.routes[i]); //Кнопка разсрыть список var btn=document.getElementById('routes_down_btn_'+this.routes[i].id); btn.onclick=function(tr,thiz,id){ return function(){ var btn=document.getElementById('routes_down_btn_'+id); if(btn.src.indexOf("right.png")!=-1) { btn.src = '/resources/images/down.png'; tr.style.display = 'table-row'; }else if(btn.src.indexOf("down.png")!=-1) { btn.src = '/resources/images/right.png'; tr.style.display = 'none'; } }; }(tr,this,this.routes[i].id); //Кнопка поменять местами начальную и конечную точку btn=document.getElementById('route_rev_'+this.routes[i].id) btn.onclick=function(thiz,id){ return function(){ thiz.swapPoints({id:id}); }; }(this,this.routes[i].id); //Кнопка редактировать btn=document.getElementById('route_edit_'+this.routes[i].id) btn.onclick=function(thiz,id){ return function(){ thiz.editRoute({id:id}); }; }(this,this.routes[i].id); //Кнопка удалить btn=document.getElementById('route_del_'+this.routes[i].id) btn.onclick=function(thiz,id){ return function(){ thiz.deleteRoute({id:id}); }; }(this,this.routes[i].id); //Кнопка редактировать "Автовокзал", "Перевозчик" var eBtn=function(thiz,id){ return function(){ var settings=''; myFunction('RoutesCompanies',settings); }; }(this,this.routes[i].id); btn=document.getElementById('route_edit2_'+this.routes[i].id) btn.onclick=eBtn; btn=document.getElementById('route_edit3_'+this.routes[i].id) btn.onclick=eBtn; //Кнопка редактировать расписание рейса btn=document.getElementById('route_edit4_'+this.routes[i].id) btn.onclick=function(thiz,id){ return function(){ var settings=''; myFunction('TripsSchedules',settings); }; }(this,this.routes[i].id); //Кнопка создать контрольную точку btn=document.getElementById('route_edit5_'+this.routes[i].id) btn.onclick=function(thiz,id){ return function(){ thiz.createCheckPoint(id); }; }(this,this.routes[i].id); //Кнопка редактировать контрольные точки (табличка) btn=document.getElementById('route_edit6_'+this.routes[i].id) btn.onclick=function(thiz,id){ return function(){ var settings=''; myFunction('RoutesCheckpoints',settings); }; }(this,this.routes[i].id); //Кнопки редактировать контрольные точки for(var j=0;j'); eRec.win.onClose=function(thiz){ return function(){ thiz.filtering();};}(this); } createCheckPoint(id) { //В настройках передаю центр карты let center=ol.proj.transform(g_map.getView().getCenter(), 'EPSG:3857','EPSG:4326'); let eRec = new EdtRec(""); eRec.eRecNa("RoutesCheckpoints",-1,''); eRec.win.onClose=function(thiz){ return function(){ thiz.filtering();};}(this); } //Удалить маршрут deleteRoute(settings) { if (typeof settings === 'string' || settings instanceof String) { try { settings = JSON.parse(settings); } catch (e) { alert(e.message); return; } } if (confirm(trt("Do_you_really_want_to_delete_the_record")+'?')) { var req=createRequestObject(); req.onreadystatechange = function(thiz) { return function(){ if(req.readyState === 4){ var data=null; try { data = JSON.parse(req.responseText); } catch (e) { alert(e.message); return; } if(data!=null) { if(data.errorMessage !== undefined && data.errorMessage!='') { alert(data.errorMessage); thiz.win.hideProgressBar(); }else { } } //Фильтрую список заново thiz.filtering(); } }; }(this); req.open("POST", '/monitoring/pscripts/routes.php?fn=3', true); req.setRequestHeader("Content-type", "text/plain"); req.send(JSON.stringify(settings)); this.filtering(); } return true; } //Удалить маршрут deleteControlPoint(settings) { if (typeof settings === 'string' || settings instanceof String) { try { settings = JSON.parse(settings); } catch (e) { alert(e.message); return; } } if (confirm(trt("Do_you_really_want_to_delete_the_record")+'?')) { alert(settings.id); /*var req=createRequestObject(); req.onreadystatechange = function(thiz) { return function(){ if(req.readyState === 4){ var data=null; try { data = JSON.parse(req.responseText); } catch (e) { alert(e.message); return; } if(data!=null) { if(data.errorMessage !== undefined && data.errorMessage!='') { alert(data.errorMessage); thiz.win.hideProgressBar(); }else { } } //Фильтрую список заново thiz.filtering(); } }; }(this); req.open("POST", '/monitoring/pscripts/routes.php?fn=3', true); req.setRequestHeader("Content-type", "text/plain"); req.send(JSON.stringify(settings)); this.filtering();*/ } return true; } editRoute(settings) { if (typeof settings === 'string' || settings instanceof String) { try { settings = JSON.parse(settings); } catch (e) { alert(e.message); return; } } let route=this.getRouteByID(settings.id); let eRec = new EdtRec(""); eRec.eRecNa("Routes",settings.id); eRec.win.onClose=function(thiz,route){ return function(){ route.showPoints(false); //thiz.filtering(); };}(this,route); if(route!=null) { route.showPoints(true); route.setVisibility(true); } } editCheckPoint(settings) { if (typeof settings === 'string' || settings instanceof String) { try { settings = JSON.parse(settings); } catch (e) { alert(e.message); return; } } let checkPoint=this.getCheckPointByID(settings.id); let eRec = new EdtRec(""); eRec.eRecNa("RoutesCheckpoints",settings.id); eRec.win.onClose=function(thiz,checkPoint){ return function(){ checkPoint.showPoints(false); };}(this,checkPoint); //alert("checkPoint = "+checkPoint+" id = "+settings.id); if(checkPoint!=null) { checkPoint.showPoints(true); checkPoint.setVisibility(true); } } //Вернуть объект TRoute по идентификатору getRouteByID(id) { for(var i=0;i0) { var point = coord[0]; if(point!=null) { g_map.getView().setCenter(point); if(g_map.getView().getZoom()<9) g_map.getView().setZoom(9); } } }else { if(!isNaN(parseFloat(this.lon))) { var point = ol.proj.transform([this.lon,this.lat], 'EPSG:4326','EPSG:3857'); if(point!=null) { g_map.getView().setCenter(point); if(g_map.getView().getZoom()<9) g_map.getView().setZoom(9); } } } } //Отобразить точки для редактирования showPoints(val) { this.shP=val; if(this.shP) enableEditPoints(this.feature); else disableEditPoints(this.feature); return true; } //Запросить гео данные для построения маршрута на карте getGeoJSON() { if(this.feature!=null) return; var data = { id: this.id }; $.ajax({ url: '/monitoring/pscripts/routes.php?fn=1', data: JSON.stringify(data), contentType: 'application/json; charset=utf-8', type: "POST", dataType: "json", success: function(thiz){return function(data,status){ if(status=='success') { var dataC; var featuresC; var vectorSourceC; dataC = data;//JSON.parse('{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type": "LineString","coordinates": [[34.32128906249999,54.67383096593114],[45.3955078125,54.44449176335762],[52.7783203125,52.61639023304539],[62.13867187499999,49.095452162534826],[76.1572265625,43.45291889355465]]}}]}'); vectorSourceC = new ol.source.Vector({ features: (new ol.format.GeoJSON()).readFeatures(dataC,{featureProjection: 'EPSG:3857'}) }); featuresC = vectorSourceC.getFeatures(); var point=null; //Коордионаты первой точки в маршруте for(i=0;i