Browse Source

Custom Map Addition

master
Evgeny Gagua 3 years ago
parent
commit
dc58c1b69a
  1. 9
      lib/ajax_asm.php
  2. 9
      lib/assembler.php
  3. 66
      lib/controller/addMap.php
  4. 440
      lib/controller/getGeoZones.php
  5. 57
      lib/controller/getLocationItems.php
  6. 134
      lib/controller/getLocationNodeProps.php
  7. 3
      lib/controller/getLocationNodes.php
  8. 49
      lib/controller/getMapData.php
  9. 47
      lib/controller/listMaps.php
  10. 1
      lib/controller/map_picture_upload.html
  11. 62
      lib/controller/updateLocation.php
  12. 44
      lib/controller/updateMap.php
  13. 38
      lib/javascript/jsapi_dynamic/mojo_global_vars.js
  14. 838
      lib/javascript/jsapi_dynamic/mojo_map.js
  15. 69
      lib/javascript/jsapi_dynamic/mojo_settings.js
  16. 9
      lib/js_asm.php
  17. 17
      lib/php/db/language_class.php
  18. BIN
      style/assets/anchor_sys-1.psd
  19. BIN
      style/assets/cust_map_cord_sys-0.png
  20. BIN
      style/assets/cust_map_cord_sys-1.png
  21. BIN
      style/assets/map_mode_decart.png
  22. BIN
      style/assets/map_mode_wgs84.png

9
lib/ajax_asm.php

@ -35,8 +35,13 @@ if( isset($_GET['Lang'])){
$UCL=$_GET['Lang']/1;
if ($UCL) $_SESSION['userlang']=$UCL; else $_SESSION['userlang']=$UserLang;
}
if( isset($_SESSION['userlang']) )$Labels=new Language($_SESSION['userlang']);//, '_php');
else $Labels=new Language( $UserLang );//, '_php');
$LDB = new SQLite_DB( '/srv/www/web/lib/controller/data/language.db');
if( isset($_SESSION['userlang']) ){
$Labels=new Language( $_SESSION['userlang'],'', $LDB );
} else {
$Labels=new Language( $UserLang ,'', $LDB );
};
if( $UserLang == 3 || $UserLang == 255 ){
$RTL_SITE = true;

9
lib/assembler.php

@ -51,8 +51,13 @@ if( isset($_GET['Lang'])){
$UCL=$_GET['Lang']/1;
if ($UCL) $_SESSION['userlang']=$UCL; else $_SESSION['userlang']=$UserLang;
}
if( isset($_SESSION['userlang']) )$Labels=new Language( $_SESSION['userlang'] ); // '_php');
else $Labels=new Language( $UserLang );// '_php');
$LDB = new SQLite_DB( 'lib/controller/data/language.db');
if( isset($_SESSION['userlang']) ){
$Labels=new Language( $_SESSION['userlang'],'', $LDB );
} else {
$Labels=new Language( $UserLang ,'', $LDB );
};
if( $UserLang == 3 || $UserLang == 255 ){
$RTL_SITE = true;

66
lib/controller/addMap.php

@ -0,0 +1,66 @@
<?php
require_once('../ajax_asm.php');
function verbose( $ok=1,$info=""){
// failure to upload throws 400 error
if( $ok==0 ){
http_response_code(400);
};
die(json_encode(["ok"=>$ok, "info"=>$info]));
};
if( $CUser->Data['id'] > 1 ){
if( intval( $_POST['ctype'] ) == 1 ){
$EURL = $DATABASE->escape($_POST['map_url']);
$ENAME = $DATABASE->escape($_POST['map_name']);
$EDESC = $DATABASE->escape($_POST['map_desc']);
$EATTR = $DATABASE->escape($_POST['map_attr']);
$IZOOM = intval( $_POST['map_maxz'] );
$INZOOM = intval( $_POST['map_maxnz'] );
$QS = "INSERT INTO `location_maps`(`type`,`name`,`layer_url`,`desc`,`maxNativeZoom`,`maxZoom`,`attribution`) values(1,'{$ENAME}','{$EURL}','{$EDESC}',{$INZOOM},{$IZOOM},'{$EATTR}')";
$DATABASE->Query( $QS );
} else {
if( empty( $_FILES ) || $_FILES['map_image']['error'] ){
verbose( 0, "Failed to move uploaded file.[" . $_FILES['map_image']['error'] . "]" );
};
// upload destination
//$filePath = __DIR__ . DIRECTORY_SEPARATOR . "../../vault/working_dir/uploads";
$filePath = $SYSPath . 'lib/controller/data/assets/images';
if( !file_exists( $filePath ) ){
if (!mkdir($filePath, 0777, true)) {
verbose(0, "Failed to create $filePath" );
};
};
if( file_exists( $_FILES['map_image']['tmp_name'] ) ){
$MD5 = md5_file( $_FILES['map_image']['tmp_name'] );
$TArr = explode( '.', $_FILES['map_image']['name'] );
$EXT = $TArr[ count($TArr) - 1 ];
$FNAME = $MD5 . '.' . $EXT;
copy( $_FILES['map_image']['tmp_name'], $filePath . '/' . $FNAME );
@unlink( $_FILES['map_image']['tmp_name'] );
list( $width, $height, $type, $attr ) = getimagesize( $filePath . '/' . $FNAME );
$ENAME = $DATABASE->escape($_POST['map_name']);
$EDESC = $DATABASE->escape($_POST['map_desc']);
$EATTR = $DATABASE->escape($_POST['map_attr']);
$IZOOM = intval( $_POST['map_maxz'] );
$INZOOM = intval( $_POST['map_maxz'] );
$MA_WI = floatval( $_POST['map_width'] );
$MA_HE = floatval( $_POST['map_height'] );
$TB = intval( $_POST['map_tpb'] );
$LB = intval( $_POST['map_lpb'] );
$RB = intval( $_POST['map_rpb'] );
$BB = intval( $_POST['map_bpb'] );
$K_X = $MA_WI / ( $width - $LB - $RB );
$K_Y = $MA_HE / ( $height - $TB - $BB );
$IBLX = (-$LB)*$K_X;
$IBLY = (-$TB)*$K_Y;
$IBRX = ( $width + $RB ) * $K_X;
$IBRY = ( $height + $BB ) * $K_Y;
$QS = "INSERT INTO `location_maps`(`type`,`name`,`layer_url`,`desc`,`maxNativeZoom`,`maxZoom`,`attribution`,`bounds_lx`,`bounds_ly`,`bounds_rx`,`bounds_ry`) values(2,'{$ENAME}','{$FNAME}','{$EDESC}',{$INZOOM},{$IZOOM},'{$EATTR}',{$IBLX},{$IBLY},{$IBRX},{$IBRY})";
$DATABASE->Query( $QS );
verbose( 1, "ALL IS OK" );
};
};
} else {
verbose( 0, 'Access Denied!' );
};
?>

440
lib/controller/getGeoZones.php

@ -152,13 +152,20 @@ function ToLL($north, $east, $utmZone){
$SR = $DATABASE->Query( $QS, false );
if( count( $SR ) ){
$SS = $SR[0];
$ANCHOR = new gPoint();
$ANCHOR->setLongLat( floatval( $SS['anchor_lon'] ), floatval( $SS['anchor_lat'] ) );
$ANCHOR->convertLLtoTM();
$BASE_X = $ANCHOR->E();
$BASE_Y = $ANCHOR->N();
$BASE_Z = floatval( $SS['anchor_alt'] );
$BASE_ZONE = $ANCHOR->Z();
$GPS = $SS['local_binding'] == 0;
if( $GPS ){
$ANCHOR = new gPoint();
$ANCHOR->setLongLat( floatval( $SS['anchor_lon'] ), floatval( $SS['anchor_lat'] ) );
$ANCHOR->convertLLtoTM();
$BASE_X = $ANCHOR->E();
$BASE_Y = $ANCHOR->N();
$BASE_ZONE = $ANCHOR->Z();
} else {
$BASE_X = floatval( $SS['anchor_lon'] );
$BASE_Y = floatval( $SS['anchor_lat'] );
$BASE_ZONE = 'N';
};
$BASE_Z = floatval( $SS['anchor_alt'] );
$QS = "SELECT * FROM nodes WHERE ((type!=0)AND(type!=20))";
$Result = $DATABASE->Query( $QS, false );
date_default_timezone_set('UTC');
@ -173,39 +180,58 @@ function ToLL($north, $east, $utmZone){
$D = $DATABASE->Query( $QS, false );
if( count( $D ) ){
$CC = $D[0];
$A = new gPoint();
$A->setUTM( $CC['x'], $CC['y'] );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
//$A->setLongLat($CC['lon'],$CC['lat']);
//$A->convertLLtoTM();
$XC = $A->E();
$YC = $A->N();
$Z = $A->Z();
if( $GPS ){
$A = new gPoint();
$A->setUTM( $CC['x'], $CC['y'] );
$A->convertTMtoLL();
$LON = $A->Long();
$LAT = $A->Lat();
//$A->setLongLat($CC['lon'],$CC['lat']);
//$A->convertLLtoTM();
$XC = $A->E();
$YC = $A->N();
$Z = $A->Z();
} else {
$LON = $BASE_X + floatval( $CC['x'] );
$LAT = $BASE_Y + floatval( $CC['y'] );
$XC = $LON;
$YC = $LAT;
$Z = $BASE_Z;
};
$RAN = floatval( $CC['max_range'] );
if( 1 ){
$K = pi()/18.0;//10 deg
$Points = array();
$Points[] = array( 'lat'=>$LAT, 'lon'=>$LON );
$Points[] = array( 'lon'=>$LON, 'lat'=>$LAT );
$SANG = ( pi() / 180 ) * floatval( $CC['yaw'] );
for( $i = 0; $i < 11; $i++ ){
$CA = $i * $K;
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$B->convertTMtoLL();
$Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
if( $GPS ){
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$B->convertTMtoLL();
$Points[]=array( 'lon'=>$B->Long(), 'lat'=>$B->Lat() );
} else {
$PX = $XC + $RAN * cos( $SANG + $CA );
$PY = $YC + $RAN * sin( $SANG + $CA );
$Points[]=array( 'lon'=>$PX, 'lat'=>$PY );
};
};
if(1){
$ZMARK = array();
$B = new gPoint();
if( $GPS ){
$ZMARK = array();
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$ZPX = $XC + $RAN * cos( $SANG );
$ZPY = $YC + $RAN * sin( $SANG );
$ZMARK=array( 'lon'=>$ZPX, 'lat'=>$ZPY );
};
//$SANG = $SANG - ( pi() / 180 );
//$RAN = $RAN + 0.5;
//$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
@ -263,12 +289,18 @@ function ToLL($north, $east, $utmZone){
$Zone['bottomleft']=array($A->Lat(),$A->Long());
$ZMARK = array();
$B = new gPoint();
if( $GPS ){
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$ZPX = $XC + $RAN * cos( $SANG );
$ZPY = $YC + $RAN * sin( $SANG );
$ZMARK=array( 'lon'=>$ZPX, 'lat'=>$ZPY );
};
$Zone['zang'] = $ZMARK;
//*/
};
@ -287,14 +319,22 @@ function ToLL($north, $east, $utmZone){
$Zone['dev_name'] = $R['name'];
if( count( $D ) ){
$CC = $D[0];
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
$XC = $A->E();
$YC = $A->N();
$Z = $A->Z();
if( $GPS ){
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
$XC = $A->E();
$YC = $A->N();
$Z = $A->Z();
} else {
$LON = $BASE_X + floatval( $CC['x'] );
$LAT = $BASE_Y + floatval( $CC['y'] );
$XC = $LON;
$YC = $LAT;
$Z = $BASE_Z;
};
$RAN = floatval( $CC['max_range'] );
$K = pi()/ 36; // 5 deg//
@ -303,17 +343,29 @@ function ToLL($north, $east, $utmZone){
$SANG = ( pi() / 180 ) * floatval( $CC['z_rot'] ) + ( pi()/3000.0 * floatval( $CC['base_shift'] ) );
for( $i = 0; $i < 20; $i++ ){
$CA = $i * $K;
if( $GPS ){
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$B->convertTMtoLL();
$Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$PX = $XC + $RAN * cos( $SANG + $CA );
$PY = $YC + $RAN * sin( $SANG + $CA );
$Points[]=array( 'lon'=>$PX, 'lat'=>$PY );
};
};
$ZMARK = array();
if( $GPS ){
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$SANG = $SANG - ( pi()/3000.0 * floatval( $CC['base_shift'] ) );
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$ZPX = $XC + $RAN * cos( $SANG );
$ZPY = $YC + $RAN * sin( $SANG );
$ZMARK=array( 'lon'=>$ZPX, 'lat'=>$ZPY );
};
$ZMARK = array();
$B = new gPoint();
$SANG = $SANG - ( pi()/3000.0 * floatval( $CC['base_shift'] ) );
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
$Zone['zang'] = $ZMARK;
$Zone['type']='poly';
$Zone['points']=$Points;
@ -334,18 +386,26 @@ function ToLL($north, $east, $utmZone){
$Zone['dev_name'] = $R['name'];
if( count( $D ) ){
$CC = $D[0];
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
//$A = new gPoint();
//$A->setLongLat($CC['lon'],$CC['lat']);
//$A->convertLLtoTM();
$XC = $A->E();
$YC = $A->N();
$Z = $A->Z();
if( $GPS ){
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
//$A = new gPoint();
//$A->setLongLat($CC['lon'],$CC['lat']);
//$A->convertLLtoTM();
$XC = $A->E();
$YC = $A->N();
$Z = $A->Z();
} else {
$LON = $BASE_X + floatval( $CC['x'] );
$LAT = $BASE_Y + floatval( $CC['y'] );
$XC = $LON;
$YC = $LAT;
$Z = $BASE_Z;
};
$RAN = floatval( $CC['max_range'] );
if(1){
$K = pi()/ 36; // 10 deg//
@ -354,40 +414,52 @@ function ToLL($north, $east, $utmZone){
$SANG = ( pi() / 180 ) * floatval( $CC['z_rot'] ) + ( pi()/3000.0 * floatval( $CC['base_shift'] ) );
for( $i = 0; $i < 40; $i++ ){
$CA = $i * $K;
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$B->convertTMtoLL();
$Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
if( $GPS ){
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$B->convertTMtoLL();
$Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$PX = $XC + $RAN * cos( $SANG + $CA );
$PY = $YC + $RAN * sin( $SANG + $CA );
$Points[]=array( 'lon'=>$PX, 'lat'=>$PY );
};
};
if(1){
$ZMARK = array();
$B = new gPoint();
// PLS
$SANG = $SANG - ( pi()/3000.0 * floatval( $CC['base_shift'] ) );
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
//$SANG = $SANG - ( pi() / 180 );
//$RAN = $RAN + 0.5;
//$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
//$B->convertTMtoLL();
//$ZMARK[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
//$SANG = $SANG + ( pi() / 180 );
//$RAN = $RAN + 0.5;
//$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
//$B->convertTMtoLL();
//$ZMARK[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
//$SANG = $SANG + ( pi() / 180 );
//$RAN = $RAN - 0.5;
//$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
//$B->convertTMtoLL();
//$ZMARK[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
if( $GPS ){
$B = new gPoint();
// PLS
$SANG = $SANG - ( pi()/3000.0 * floatval( $CC['base_shift'] ) );
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
//$SANG = $SANG - ( pi() / 180 );
//$RAN = $RAN + 0.5;
//$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
//$B->convertTMtoLL();
//$ZMARK[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
//$SANG = $SANG + ( pi() / 180 );
//$RAN = $RAN + 0.5;
//$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
//$B->convertTMtoLL();
//$ZMARK[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
//$SANG = $SANG + ( pi() / 180 );
//$RAN = $RAN - 0.5;
//$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
//$B->convertTMtoLL();
//$ZMARK[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$ZPX = $XC + $RAN * cos( $SANG );
$ZPY = $YC + $RAN * sin( $SANG );
$ZMARK=array( 'lon'=>$ZPX, 'lat'=>$ZPY );
};
$Zone['zang'] = $ZMARK;
}
$Zone['type']='poly';
@ -427,12 +499,18 @@ function ToLL($north, $east, $utmZone){
$Zone['bottomleft']=array($A->Lat(),$A->Long());
//*/
$ZMARK = array();
$B = new gPoint();
if( $GPS ){
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$ZPX = $XC + $RAN * cos( $SANG );
$ZPY = $YC + $RAN * sin( $SANG );
$ZMARK=array( 'lon'=>$ZPX, 'lat'=>$ZPY );
}
$Zone['zang'] = $ZMARK;
};
$Zone['name'] = $R['name'];
@ -451,19 +529,26 @@ function ToLL($north, $east, $utmZone){
$Zone['dev_name'] = $R['name'];
if( count( $D ) ){
$CC = $D[0];
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
//$A = new gPoint();
//$A->setLongLat($CC['lon'],$CC['lat']);
//$A->convertLLtoTM();
$YC = $A->N();
$XC = $A->E();
$Z = $A->Z();
if( $GPS ){
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
//$A = new gPoint();
//$A->setLongLat($CC['lon'],$CC['lat']);
//$A->convertLLtoTM();
$YC = $A->N();
$XC = $A->E();
$Z = $A->Z();
} else {
$LON = $BASE_X + floatval( $CC['x'] );
$LAT = $BASE_Y + floatval( $CC['y'] );
$XC = $LON;
$YC = $LAT;
$Z = $BASE_Z;
};
$Zone['type']='circle';
$Zone['radius'] = floatval( $CC['max_range'] );
$Zone['color'] = '#8800FF';
@ -472,12 +557,17 @@ function ToLL($north, $east, $utmZone){
$SANG = ( pi() / 180 ) * floatval( $CC['z_rot'] );
$RAN = floatval( $CC['max_range'] );
$ZMARK = array();
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
if( $GPS ){
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$ZPX = $XC + $RAN * cos( $SANG );
$ZPY = $YC + $RAN * sin( $SANG );
$ZMARK=array( 'lon'=>$ZPX, 'lat'=>$ZPY );
};
$Zone['zang'] = $ZMARK;
$Zone['name'] = $R['name'];
$Data[] = $Zone;
@ -490,14 +580,22 @@ function ToLL($north, $east, $utmZone){
$D = $DATABASE->Query( $QS, false );
if( count( $D ) ){
$CC = $D[0];
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
$YC = $A->N();
$XC = $A->E();
$Z = $A->Z();
if( $GPS ){
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
$YC = $A->N();
$XC = $A->E();
$Z = $A->Z();
} else {
$LON = $BASE_X + floatval( $CC['x'] );
$LAT = $BASE_Y + floatval( $CC['y'] );
$XC = $LON;
$YC = $LAT;
$Z = $BASE_Z;
}
$CFOV = (2.0*atan($AC_imager_width[$CC['imager_type']]/(2.0*$cam_predef_focal_length[$CC['lens_f']])));
$Points = array();
$A = new gPoint();
@ -507,21 +605,33 @@ function ToLL($north, $east, $utmZone){
$RAN = floatval( $CC['max_range'] );
for( $i = 0; $i < 41; $i++ ){
$CA = $i * $K;
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$B->convertTMtoLL();
$Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
if( $GPS ){
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$B->convertTMtoLL();
$Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$PX = $XC + $RAN * cos( $SANG + $CA );
$PY = $YC + $RAN * sin( $SANG + $CA );
$Points[]=array( 'lon'=>$PX, 'lat'=>$PY );
};
};
$Zone['type']='poly';
$Zone['points']=$Points;
$Zone['color'] = '#000088';
$Zone['center'] = array( 'lat'=>$LAT, 'lon'=>$LON );
$ZMARK = array();
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG+( $CFOV / 2.0 ) ), $YC + $RAN * sin( $SANG +( $CFOV / 2.0 ) ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
if( $GPS ){
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG+( $CFOV / 2.0 ) ), $YC + $RAN * sin( $SANG +( $CFOV / 2.0 ) ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$ZPX = $XC + $RAN * cos( $SANG );
$ZPY = $YC + $RAN * sin( $SANG );
$ZMARK=array( 'lon'=>$ZPX, 'lat'=>$ZPY );
};
$Zone['zang'] = $ZMARK;
$Zone['name'] = $R['name'];
$Data[] = $Zone;
@ -534,14 +644,22 @@ function ToLL($north, $east, $utmZone){
$D = $DATABASE->Query( $QS, false );
if( count( $D ) ){
$CC = $D[0];
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
$YC = $A->N();
$XC = $A->E();
$Z = $A->Z();
if( $GPS ){
$A = new gPoint();
$A->setUTM( $BASE_X + floatval( $CC['x'] ), $BASE_Y + floatval( $CC['y'] ), $BASE_ZONE );
$A->convertTMtoLL();
$LAT = $A->Lat();
$LON = $A->Long();
$YC = $A->N();
$XC = $A->E();
$Z = $A->Z();
} else {
$LON = $BASE_X + floatval( $CC['x'] );
$LAT = $BASE_Y + floatval( $CC['y'] );
$XC = $LON;
$YC = $LAT;
$Z = $BASE_Z;
};
if( intval( $CC['pan_angles'] ) < 360 ){
$Points = array();
$A = new gPoint();
@ -551,21 +669,33 @@ function ToLL($north, $east, $utmZone){
$RAN = floatval( $CC['max_range'] );
for( $i = 0; $i < 41; $i++ ){
$CA = $i * $K;
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$B->convertTMtoLL();
$Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
if( $GPS ){
$B = new gPoint();
$B->setUTM( $XC + $RAN * cos( $SANG + $CA ), $YC + $RAN * sin( $SANG + $CA ), $Z );
$B->convertTMtoLL();
$Points[]=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$PX = $XC + $RAN * cos( $SANG + $CA );
$PY = $YC + $RAN * sin( $SANG + $CA );
$Points[]=array( 'lon'=>$PX, 'lat'=>$PY );
};
};
$Zone['type']='poly';
$Zone['points']=$Points;
$Zone['color'] = '#000088';
$Zone['center'] = array( 'lat'=>$LAT, 'lon'=>$LON );
$ZMARK = array();
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
if( $GPS ){
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$ZPX = $XC + $RAN * cos( $SANG );
$ZPY = $YC + $RAN * sin( $SANG );
$ZMARK=array( 'lon'=>$ZPX, 'lat'=>$ZPY );
};
$Zone['zang'] = $ZMARK;
} else {
$Zone['type']='circle';
@ -575,11 +705,17 @@ function ToLL($north, $east, $utmZone){
$SANG = ( pi() / 180 ) * floatval( $CC['z_rot'] );
$RAN = floatval( $CC['max_range'] );
$ZMARK = array();
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
if( $GPS ){
$B = new gPoint();
//$RAN = $RAN - 0.5;
$B->setUTM( $XC + $RAN * cos( $SANG ), $YC + $RAN * sin( $SANG ), $Z );
$B->convertTMtoLL();
$ZMARK=array('lat'=>$B->Lat(),'lon'=>$B->Long());
} else {
$ZPX = $XC + $RAN * cos( $SANG );
$ZPY = $YC + $RAN * sin( $SANG );
$ZMARK=array( 'lon'=>$ZPX, 'lat'=>$ZPY );
};
$Zone['zang'] = $ZMARK;
};
$Zone['name'] = $R['name'];

57
lib/controller/getLocationItems.php

@ -10,21 +10,29 @@
$SLAT = $R[0]['anchor_lat'];
$SLON = $R[0]['anchor_lon'];
$SALT = $R[0]['anchor_alt'];
$A = new gPoint();
$A->setLongLat( $SLON, $SLAT );
$A->convertLLtoTM();
$XC = $A->E();
$YC = $A->N();
$ZC = $A->Z();
$DIFF = intval( $R[0]['local_binding'] );
if( $DIFF == 0 ){
$A = new gPoint();
$A->setLongLat( $SLON, $SLAT );
$A->convertLLtoTM();
$XC = $A->E();
$YC = $A->N();
$ZC = $A->Z();
} else {
$XC = $SLON;
$YC = $SLAT;
$ZC = $SALT;
};
$QS = "SELECT * FROM nodes";
$Result = $DATABASE->Query( $QS, false );
$index = 0;
foreach( $Result as $CD ){
$cnode['id'] = intval($CD['id']);
$cnode['type'] = intval($CD['type']);
$index++;
$PUPA = false;
$CC = new gPoint();
if( $DIFF == 0 ) $CC = new gPoint();
switch( $CD['type'] ){
case ARGUS_ALS_SENSOR:
case ARGUS_LFS_SENSOR:
@ -34,10 +42,15 @@
case ARGUS_NET_PLS_200:
$QS="SELECT x, y FROM lrf_sensors WHERE id={$CD['aux_id']}";
$RV = $DATABASE->Query( $QS );
$CC->setUTM( $XC + floatval($RV[0]['x']), $YC+floatval($RV[0]['y']), $ZC );
$CC->convertTMtoLL();
$cnode['lat'] = $CC->Lat();
$cnode['lon'] = $CC->Long();
if( $DIFF == 0 ){
$CC->setUTM( $XC + floatval($RV[0]['x']), $YC+floatval($RV[0]['y']), $ZC );
$CC->convertTMtoLL();
$cnode['lat'] = $CC->Lat();
$cnode['lon'] = $CC->Long();
} else {
$cnode['lat'] = $XC + floatval($RV[0]['y']);
$cnode['lon'] = $YC +floatval($RV[0]['x']);
};
//if( floatval($RV[0]['x']) == 0 && floatval($RV[0]['y']) == 0 ){
// $cnode['lat'] = $SLAT;
// $cnode['lon'] = $SLON;
@ -55,19 +68,15 @@
case ARGUS_IP_PTZ_CAMERA:
$QS="SELECT x, y FROM cameras WHERE id={$CD['aux_id']}";
$RV = $DATABASE->Query( $QS );
$CC->setUTM( $XC + floatval($RV[0]['x']), $YC+floatval($RV[0]['y']), $ZC );
$CC->convertTMtoLL();
$cnode['lat'] = $CC->Lat();
$cnode['lon'] = $CC->Long();
//if( floatval($RV[0]['x']) == 0 && floatval($RV[0]['y']) == 0 ){
// $cnode['lat'] = $SLAT;
// $cnode['lon'] = $SLON;
//} else {
// $CC->setUTM( floatval($RV[0]['x']), floatval($RV[0]['y']), $ZC );
// $CC->convertTMtoLL();
// $cnode['lat']= $CC->Lat();
// $cnode['lon']= $CC->Long();
//};
if( $DIFF == 0 ){
$CC->setUTM( $XC + floatval($RV[0]['x']), $YC+floatval($RV[0]['y']), $ZC );
$CC->convertTMtoLL();
$cnode['lat'] = $CC->Lat();
$cnode['lon'] = $CC->Long();
} else {
$cnode['lat'] = $XC + floatval($RV[0]['y']);
$cnode['lon'] = $YC + floatval($RV[0]['x']);
};
$PUPA = true;
break;
};

134
lib/controller/getLocationNodeProps.php

@ -2,6 +2,130 @@
require_once('../ajax_asm.php');
require_once('../php/utm/gPoint.php');
$PROP_TPL=<<<_DATA_BOUNDARY
{
xtype: 'form',
labelWidth: 40, // label settings here cascade unless overridden
frame: false,
bodyStyle:'padding:5px 5px 0',
defaultType: 'textfield',
labelAlign: 'right',
items: [{
xtype: 'panel',
height: 100,
html: '<p align="center"><img src="/style/assets/%%%TYPE%%%_node.png"><br/>%%%NAME%%%<br/></p>'
},%%%LOCATION_PART%%%{
xtype:'fieldset',
title: 'Orientation',
collapsible: true,
autoHeight:true,
defaults: {
//width: 168
},
defaultType: 'textfield',
items :[{
fieldLabel: 'Roll',
id: 'sroll',
value: %%%ROLL%%%,
name: 'sroll',
allowBlank:false
},{
fieldLabel: 'Pitch',
id: 'spitch',
value: %%%PITCH%%%,
name: 'spitch',
allowBlank:false
},{
fieldLabel: 'Yaw',
id: 'syaw',
value: %%%YAW%%%,
name: 'syaw',
allowBlank:false
},{
xtype: 'button',
width: '100%',
text: 'Edit Orientation',
handler: orientationEditor
}]
},{
xtype:'fieldset',
title: 'Diff Position',
collapsible: true,
autoHeight:true,
defaults: {
//width: 168
},
defaultType: 'numberfield',
items :[{
fieldLabel: 'ΔX',
id: 'dx',
value: %%%DX%%%,
name: 'dx',
allowBlank:false
},{
fieldLabel: 'ΔY',
id: 'dy',
value: %%%DY%%%,
name: 'dy',
allowBlank:false
},{
fieldLabel: 'ΔZ',
id: 'dz',
value: %%%DZ%%%,
name: 'dz',
allowBlank:false
},{
xtype: 'button',
width: '100%',
text: 'Set Position',
handler: setNodeLocationByDelta
}]
},{
xtype: 'button',
text: 'Update',
width: '100%',
handler: updateLocationOrientation
}]
}
_DATA_BOUNDARY;
$LOCA_TPL=<<<_DATA_BOUNDARY
{
xtype:'fieldset',
//checkboxToggle:true,
collapsible: true,
title: 'Location',
autoHeight: true,
defaults: {
//width: 180
},
defaultType: 'textfield',
collapsed: false,
items :[{
fieldLabel: 'Lat',
name: 'slat',
value: %%%LAT%%%,
id: 'slat',
allowBlank:false
},{
fieldLabel: 'Lon',
id: 'slon',
value: %%%LON%%%,
name: 'slon',
allowBlank:false
},{
fieldLabel: 'Alt',
id: 'salt',
value: %%%ALT%%%,
name: 'salt',
allowBlank:false
},{
xtype: 'button',
text: 'Set To Anchor Position',
width: '100%',
handler: setNodeLocationToAnchor
}]
},
_DATA_BOUNDARY;
if( $CUser->Data['id'] > 1 ){
$Node = intval( $_POST['NODE'] );
$QS = "SELECT * FROM `nodes` WHERE id = {$Node}";
@ -12,6 +136,12 @@
$TName = 'props/loc_prop.js';
$QS = "SELECT * FROM `system_props`";
$R = $DATABASE->Query($QS);
$GPS = ( $R[0]['local_binding'] == 0 );
if( $GPS ){
$PROP_TPL = str_replace('%%%LOCATION_PART%%%', $LOCA_TPL, $PROP_TPL );
} else {
$PROP_TPL = str_replace('%%%LOCATION_PART%%%', '', $PROP_TPL );
};
$SLAT = $R[0]['anchor_lat'];
$SLON = $R[0]['anchor_lon'];
$SALT = $R[0]['anchor_alt'];
@ -23,10 +153,10 @@
$Zo = floatval( $SALT );
$ZC = $A->Z();
$Data = file_get_contents( $TName );
$Data = $PROP_TPL;//file_get_contents( $TName );
$Data = str_replace('%%%NODEID%%%', ''.$Node, $Data );
$Data = str_replace('%%%TYPE%%%', $Type, $Data );
$Data = str_replace('%%%NAME%%%', $Props['name'] , $Data );
$Data = str_replace('%%%NAME%%%', urldecode( $Props['name'] ), $Data );
switch( $Type ){
case 1:
case 2:

3
lib/controller/getLocationNodes.php

@ -9,8 +9,9 @@
foreach( $Result as $CD ){
$cid = intval($CD['id']);
$ct = intval($CD['type']);
$cname = urldecode( $CD['name'] );
if( in_array( $ct, array( 1, 2, 3, 5, 6, 10, 11, 12, 13 ) ) ){
$DL[] = "{ xtype: 'button', text: '{$CD['name']}', width: '100%', handler: function(){ locationSelectedNode={$cid}; loadNodeLocationProps({$cid}); } }";
$DL[] = "{ xtype: 'button', text: '{$cname}', width: '100%', handler: function(){ locationSelectedNode={$cid}; loadNodeLocationProps({$cid}); } }";
};
};
echo $Data . implode(',',$DL) ."] }";

49
lib/controller/getMapData.php

@ -0,0 +1,49 @@
<?php
require_once('../ajax_asm.php');
$UID = intval( $CUser->Data['id'] );
$ACCESS = intval( $CUser->Data['access'] );
$Data = array();
if( $UID > 1 ){
if( isset( $_POST['MID'] ) ){
$MID = intval($_POST['MID']);
$QS = "SELECT * FROM `location_maps` WHERE `id`={$MID}";
$DDD = $DATABASE->Query( $QS );
if( count( $DDD ) ){
$Data = $DDD[0];
} else {
// Default Map - OpenStreetMap
$Data['id']=0;
$Data['type']=1;
$Data['name']='__DEFAULT__';
$Data['layer_url']='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
$Data['attribution']='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
$Data['maxNativeZoom']=18;
$Data['maxZoom']=24;
};
} else {
$QS = "SELECT `map_id`, `local_binding` FROM `system_props` LIMIT 1";
$DDD = $DATABASE->Query( $QS );
$Data['selected_map'] = intval( $DDD[0]['map_id'] );
$Data['local_binding'] = ( intval( $DDD[0]['local_binding'] ) > 0 );
$QS = "SELECT * FROM `location_maps` WHERE `id`={$Data['selected_map']}";
//$Data['maps'] = array();
$R = $DATABASE->Query( $QS );
if( count( $R ) ){
$Data['maps']=$R[0];
} else {
// Default Map - OpenStreetMap
$MD['id']=0;
$MD['type']=1;
$MD['name']='OpenStreetMap';
$MD['layer_url']='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
$MD['attribution']='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
$MD['maxNativeZoom']=18;
$MD['maxZoom']=24;
$Data['maps'] = $MD;
};
};
} else {
};
echo json_encode( $Data );
?>

47
lib/controller/listMaps.php

@ -0,0 +1,47 @@
<?php
require_once('../ajax_asm.php');
/*
$CREATE_SENTENCE = <<<_DATA_BOUNDARY
CREATE TABLE "location_maps" (
"id" INTEGER NOT NULL UNIQUE,
"type" INTEGER NOT NULL DEFAULT 1,
"name" TEXT NOT NULL,
"desc" TEXT,
"layer_url" TEXT,
"maxNativeZoom" INTEGER,
"maxZoom" INTEGER,
"attribution" TEXT,
"bounds_lx" REAL,
"bounds_ly" REAL,
"bounds_rx" REAL,
"bounds_ry" REAL,
PRIMARY KEY("id" AUTOINCREMENT)
)
_DATA_BOUNDARY;
*/
if( $CUser->Data['id'] > 1 ){
$Data = array();
$Data['success'] = false;
//$DATABASE->Query( $CREATE_SENTENCE );
$QS = "SELECT * FROM `location_maps`";
$Result = $DATABASE->Query($QS,false);
if( count( $Result ) ){
$Data['maps'] = array();
foreach( $Result as $CD ){
$cnode['map_id'] = intval($CD['id']);
$cnode['map_type'] = intval($CD['type']);
$cnode['map_name'] = $CD['name'];
$cnode['map_url'] = $CD['layer_url'];
$cnode['map_attr'] = $CD['attribution'];
$cnode['map_zoom'] = intval($CD['maxZoom']);
$cnode['map_native_zoom'] = intval($CD['maxNativeZoom']);
$Data['maps'][] = $cnode;
};
$Data['success'] = true;
};
echo json_encode( $Data );
} else {
header('location: /');
};
?>

1
lib/controller/map_picture_upload.html

@ -0,0 +1 @@
koko

62
lib/controller/updateLocation.php

@ -4,6 +4,7 @@
if( $CUser->Data['id'] > 1 ){
$SITE = 0; $NID = 0;
$DIFF = 0;
//if( isset( $_POST['SITE'] ) ) $SITE = intval($_POST['SITE']);
$TYP = intval($_POST['TYPE']);
if( isset( $_POST['NODE'] ) ) $NID = intval($_POST['NODE']);
@ -17,20 +18,25 @@
$YAW = floatval( $_POST['YAW'] );
};
};
if( $TYP != 1 ){
if( $TYP != 1 && $TYP != 4 ){
$QS="SELECT `anchor_lat`, `anchor_lon`, `anchor_alt`, `local_binding` FROM `system_props` LIMIT 1";
$R = $DATABASE->Query( $QS );
$SLAT = $R[0]['anchor_lat'];
$SLON = $R[0]['anchor_lon'];
$SALT = $R[0]['anchor_alt'];
$DIFF =intval( $R[0]['local_binding'] );
$A = new gPoint();
$A->setLongLat( $SLON, $SLAT );
$A->convertLLtoTM();
$XC = $A->E();
$YC = $A->N();
$ZC = $A->Z();
$DIFF = intval( $R[0]['local_binding'] );
if( $DIFF == 0 ){
$A = new gPoint();
$A->setLongLat( $SLON, $SLAT );
$A->convertLLtoTM();
$XC = $A->E();
$YC = $A->N();
$ZC = $A->Z();
} else {
$XC = $SLON;
$YC = $SLAT;
$ZC = $SALT;
};
$QS = "SELECT * FROM nodes WHERE id ={$NID}";
$Result = $DATABASE->Query( $QS, false );
$CD = $Result[0];
@ -52,21 +58,18 @@
};
};
switch( $TYP ){
case 0://Short update
$CC = new gPoint();
$CC->setLongLat( $LON, $LAT );
$CC->convertLLtoTM();
$XX = $CC->E();
$YY = $CC->N();
$ZZ = $CC->Z();
case 0://Short update
if( $DIFF ){
$DX = $XX - $XC;
$DY = $YY - $YC;
$DZ = $ZZ - $ZC;
$DX = $LON - $XC;
$DY = $LAT - $YC;
$DZ = 0;//$ALT - $ZC;
} else {
$DX = $XX;
$DY = $YY;
$DZ = $ZZ;
$CC = new gPoint();
$CC->setLongLat( $LON, $LAT );
$CC->convertLLtoTM();
$DX = $CC->E() - $XC;
$DY = $CC->N() - $YC;
$DZ = 0;//$CC->Z() - $ZC;
};
$QS="UPDATE `{$TBL}` SET `x`={$DX}, `y`={$DY}, `z`={$DZ} WHERE `id`={$CD['aux_id']}";
break;
@ -94,6 +97,21 @@
case 3://update by cords -> no convert
$QS="UPDATE `{$TBL}` SET `x`={$LAT}, `y`={$LON}, `z`={$ALT} WHERE `id`={$CD['aux_id']}";
break;
case 4://Update Map TYPE
$MID = intval($_POST['MID']);
$QS = "SELECT * FROM `location_maps` WHERE `id`={$MID}";
$DDD = $DATABASE->Query( $QS );
if( count( $DDD ) ){
// Such map exists ->Check local Binding of coordinates
$MDATA = $DDD[0];
$LB = 0;
if( $MDATA['type'] == 2 ) $LB = 1;
$QS="UPDATE `system_props` SET `map_id`={$MID}, `local_binding`={$LB}";
} else {
// Falling to default map (OpenStreet)
$QS="UPDATE `system_props` SET `map_id`=0, `local_binding`=0";
};
break;
};
$DATABASE->Query( $QS );
echo "{ nid: {$NID}, QS:'{$QS}' }";

44
lib/controller/updateMap.php

@ -0,0 +1,44 @@
<?php
require_once('../ajax_asm.php');
function verbose( $ok=1,$info=""){
// failure to upload throws 400 error
if( $ok==0 ){
http_response_code(400);
};
die(json_encode(["ok"=>$ok, "info"=>$info]));
};
if( $CUser->Data['id'] > 1 ){
$MID = intval( $_POST['MID'] );
if( $MID ){
$QS = "SELECT * FROM `location_maps` WHERE `id`={$MID}";
$DDD = $DATABASE->Query( $QS );
if( count( $DDD ) ){
$MD = $DDD[0];
list( $width, $height, $type, $attr ) = getimagesize( $SYSPath . 'lib/controller/data/assets/images/' . $MD['layer_url'] );
$ENAME = $DATABASE->escape($_POST['map_name']);
$EDESC = $DATABASE->escape($_POST['map_desc']);
$EATTR = $DATABASE->escape($_POST['map_attr']);
$IZOOM = intval( $_POST['map_maxz'] );
$INZOOM = intval( $_POST['map_maxz'] );
$MA_WI = floatval( $_POST['map_width'] );
$MA_HE = floatval( $_POST['map_height'] );
$TB = intval( $_POST['map_tpb'] );
$LB = intval( $_POST['map_lpb'] );
$RB = intval( $_POST['map_rpb'] );
$BB = intval( $_POST['map_bpb'] );
$K_X = $MA_WI / ( $width - $LB - $RB );
$K_Y = $MA_HE / ( $height - $TB - $BB );
$IBLX = (-$LB)*$K_X;
$IBLY = (-$TB)*$K_Y;
$IBRX = ( $width + $RB ) * $K_X;
$IBRY = ( $height + $BB ) * $K_Y;
$QS = "UPDATE `location_maps` SET `name`='{$ENAME}',`desc`='{$EDESC}', `maxNativeZoom`={$INZOOM},`maxZoom`={$IZOOM}, `attribution`='{$EATTR}',`bounds_lx`={$IBLX},`bounds_ly`={$IBLY}, `bounds_rx`={$IBRX},`bounds_ry`={$IBRY}, `img_w`={$width}, `img_h`={$height}, `img_lb`={$LB}, `img_rb`={$RB}, `img_tb`={$TB},`img_bb`={$BB}, `img_map_w`={$MA_WI}, `img_map_h`={$MA_HE} WHERE `id`={$MID}";
$DATABASE->Query( $QS );
verbose( 1, "ALL IS OK" );
} else verbose( 0, "WRONG MAPID" );
} else verbose( 0, "WRONG MAPID" );
} else {
verbose( 0, 'Access Denied!' );
};
?>

38
lib/javascript/jsapi_dynamic/mojo_global_vars.js

@ -5,15 +5,15 @@ var SiteLat=<?=$AP_DATA['anchor_lat'];?>;
var SiteLon=<?=$AP_DATA['anchor_lon'];?>;
var SiteAlt=<?=$AP_DATA['anchor_alt'];?>;
var ap_type=<?=$AP_DATA['type'];?>;
var ap_title = '<?=$AP_DATA['name'];?>';
var winW = <?=intval($CUser->Data['width']);?>;
var winH = <?=intval($CUser->Data['height']);?>;
var my_access = <?=intval($CUser->Data['access']);?>;
var initView = <?=intval($CUser->Data['last_content_view']);?>;
var content_lvl0 = -1;
var content_lvl1 = -1;
var content_lvl2 = -1;
var content_lvl3 = -1;
var ap_title='<?=$AP_DATA['name'];?>';
var winW=<?=intval($CUser->Data['width']);?>;
var winH=<?=intval($CUser->Data['height']);?>;
var my_access=<?=intval($CUser->Data['access']);?>;
var initView=<?=intval($CUser->Data['last_content_view']);?>;
var content_lvl0= -1;
var content_lvl1= -1;
var content_lvl2= -1;
var content_lvl3= -1;
var SoundMode = 2;
var PanelW = winW;
var PanelH = winH-90;
@ -29,6 +29,26 @@ var nodeTHREEanimationId = 0;
var serverIsOnLine = false;
var SelectedSensor = 0;
var MAP_ID = <?=$AP_DATA['map_id'];?>;
var MAP_IS_LOCAL = <?=($AP_DATA['map_id']!=0)?$AP_DATA['local_binding']:0;?>;
var MAP_SET=<?php
$QS = "SELECT * FROM `location_maps` WHERE `id`={$AP_DATA['map_id']}";
$R = $DATABASE->Query( $QS );
if( count( $R ) ){
$MD=$R[0];
} else {
// Default Map - OpenStreetMap
$MD['id']=0;
$MD['type']=1;
$MD['name']='OpenStreetMap';
$MD['layer_url']='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
$MD['attribution']='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
$MD['maxNativeZoom']=18;
$MD['maxZoom']=24;
};
echo json_encode( $MD );
?>;
<?php
if( intval($CUser->Data['ss_timeout']) ){
?>

838
lib/javascript/jsapi_dynamic/mojo_map.js

@ -7,6 +7,31 @@ var map = null;
var map_ed = null;
var markers = [];
var mapListStore = new Ext.data.JsonStore({
root: 'maps',
totalProperty: 'totalCount',
idProperty: 'map_id',
remoteSort: false,
baseParams: {
UID: '<?=$CUser->Data['id'];?>',
SID: '<?=$Session;?>'//,
//SITE: <?=$SiteID;?>
},
fields: [{
name: 'map_id',
type: 'int'
},{
name: 'map_name',
type: 'string'
}],
proxy : new Ext.data.HttpProxy({
method: 'POST',
prettyUrls: false,
url: '/lib/controller/listMaps.php'
})
});
var selectedMarkerIcon = L.icon({
iconUrl: '/style/assets/cursor.png',
iconSize: [32, 32],
@ -252,8 +277,61 @@ function LoadMapEventsZ( Mode ){
});
};
function initMapMonitoring(){
var aK = true;
if( MAP_SET.attribution == '' ) aK = false;
var mapLayers = [];
if( map != null ){
map.off();
map.remove();
};
if( MAP_SET.type == 1 ){
map = L.map( 'event_map',{
//attributionControl: aK,
attributionControl: false,
preferCanvas: true,
zoomControl: true,
center: [SiteLat, SiteLon],
/*zoomControl: false,
zoom: 17,
minZoom: 17,
maxZoom: 17,*/
keyboard: false
});
//mapLayers[ MAP_SET.name ] = L.tileLayer( MAP_SET.layer_url, {
// attribution: MAP_SET.attribution,
// maxNativeZoom: MAP_SET.maxNativeZoom,
// maxZoom: MAP_SET.maxZoom
//});
L.tileLayer( MAP_SET.layer_url, {
attribution: MAP_SET.attribution,
attributionControl: false,
maxNativeZoom: MAP_SET.maxNativeZoom,
minZoom: 0,
maxZoom: MAP_SET.maxZoom
}).addTo( map );
} else {
map = L.map( 'event_map',{
crs: L.CRS.Simple,
attributionControl: false,
preferCanvas: true,
zoomControl: true,
center: [SiteLat, SiteLon],
/*zoomControl: false,*/
zoom: 0,
minZoom: 0,
maxZoom: 4,
keyboard: false
});
var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]];
var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map );
}
map.setView([SiteLat, SiteLon], 17 );
loadMapZones( 0 );
};
function initMapMonitoring_00(){
map = L.map('event_map',{
attributionControl: true,
//preferCanvas: true,
@ -352,14 +430,14 @@ function updateLocation( e ){
locationSelectedNode = e.target.options.mycustomid;
Ext.Ajax.request({
url: '/lib/controller/updateLocation.php',
params: {
NODE: locationSelectedNode,
SITE: <?=$SiteID;?>,
UID: <?=$UserID;?>,
TYPE: 0,
SID: '<?=$Session;?>',
LAT: e.target._latlng.lat,
LON: e.target._latlng.lng
params: {
NODE: locationSelectedNode,
SITE: <?=$SiteID;?>,
UID: <?=$UserID;?>,
TYPE: 0,
SID: '<?=$Session;?>',
LAT: e.target._latlng.lat,
LON: e.target._latlng.lng
},
success: function( response, opts ){
loadNodeLocationProps( locationSelectedNode );
@ -418,7 +496,7 @@ function setNodeLocationToAnchor(){
ALT: SiteAlt
},
success: function( response, opts ){
loadLocationEditor();
loadLocationEditor('sys_location_map');
},
failure: failureAJAXFunction
});
@ -441,7 +519,7 @@ function setNodeLocationByDelta(){
ALT: dz
},
success: function( response, opts ){
loadLocationEditor();
loadLocationEditor('sys_location_map');
},
failure: failureAJAXFunction
});
@ -558,7 +636,9 @@ function loadLocationNodes(){
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
for( i=0; i < data.length; i++){
var i = 0;
var tall = Array();
for( ; i < data.length; i++){
switch( data[i].type ){
case 1:{
markers[i] = L.marker([data[i].lat, data[i].lon], {draggable: true,icon: ALS_Icon, mycustomid:data[i].id } ).addTo( map_ed ).on('click', loadLoactionProps ).on('dblclick', markerDblClick ).on('dragend', updateLocation );
@ -595,8 +675,11 @@ function loadLocationNodes(){
break;
};
};
//bindPopup('A pretty CSS3 popup.<br> Easily customizable.');//.openPopup();
tall[i] = markers[i];
};
tall[i++] = ed_anchor;
var cVisible = L.featureGroup( tall );
map_ed.flyToBounds( cVisible.getBounds() );
},
failure: function( response, opts ) {
//var tPanel = Ext.getCmp('main_portal');
@ -783,7 +866,6 @@ function LoadNodesList(){
SID: '<?=$Session;?>'
},
success: function( response, opts ){
// If the response is JSON, you have to decode it
var data = Ext.decode(response.responseText);
var tPanel = Ext.getCmp('prop_content');
tPanel.remove(0);
@ -794,8 +876,29 @@ function LoadNodesList(){
});
};
function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
function reloadSiteMapData(){
Ext.Ajax.request({
url: '/lib/controller/getMapData.php',
params: {
SITE: <?=$SiteID;?>,
UID: <?=$UserID;?>,
SID: '<?=$Session;?>'
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
MAP_ID = parseInt( data.selected_map );
MAP_IS_LOCAL = (MAP_ID)?data.local_binding:false;
MAP_SET = data.maps;
Ext.getCmp('lab_123').update( '<?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?> '+((MAP_IS_LOCAL)?'Pos X':'<?=$Labels->GetLabel('_LON_SHORT_LBL_');?>')+':' );
Ext.getCmp('lab_124').update( ((MAP_IS_LOCAL)?'Pos Y':'<?=$Labels->GetLabel('_LAT_SHORT_LBL_');?>')+':' );
document.getElementById('lab_125').src = ((MAP_IS_LOCAL)?'/style/assets/map_mode_decart.png':'/style/assets/map_mode_wgs84.png');
loadLocationEditor('sys_location_map');
},
failure: failureAJAXFunction
});
};
var ed_anchor = null;
function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
if( tlInterval!= null ){
window.clearInterval( tlInterval );
tlInterval = null;
@ -805,26 +908,64 @@ function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
if( lat == undefined ){
lat = SiteLat;
lon = SiteLon;
};
//var cMSET = mapListStore.getAt( MAP_ID );
//alert( MAP_SET.id );
var aK = true;
if( MAP_SET.attribution == '' ) aK = false;
var mapLayers = [];
if( map_ed != undefined ){
map_ed.off();
map_ed.remove();
};
map_ed = L.map( el_id,{
attributionControl: true,
//preferCanvas: true,
zoomControl: true,
center: [SiteLat, SiteLon],
/*zoomControl: false,
zoom: 17,
minZoom: 17,
maxZoom: 17,*/
keyboard: false
}).setView([SiteLat, SiteLon], 17);
if( MAP_SET.type == 1 ){
map_ed = L.map( el_id,{
attributionControl: aK,
//preferCanvas: true,
zoomControl: true,
center: [SiteLat, SiteLon],
/*zoomControl: false,
zoom: 17,
minZoom: 17,
maxZoom: 17,*/
keyboard: false
});
//mapLayers[ MAP_SET.name ] = L.tileLayer( MAP_SET.layer_url, {
// attribution: MAP_SET.attribution,
// maxNativeZoom: MAP_SET.maxNativeZoom,
// maxZoom: MAP_SET.maxZoom
//});
L.tileLayer( MAP_SET.layer_url, {
attribution: MAP_SET.attribution,
maxNativeZoom: MAP_SET.maxNativeZoom,
minZoom: 0,
maxZoom: MAP_SET.maxZoom
}).addTo( map_ed );
} else {
map_ed = L.map( el_id,{
crs: L.CRS.Simple,
attributionControl: false,
preferCanvas: true,
zoomControl: true,
center: [SiteLat, SiteLon],
/*zoomControl: false,*/
zoom: 0,
minZoom: 0,
maxZoom: 4,
keyboard: false
});
var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]];
var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map_ed );
}
map_ed.setView([SiteLat, SiteLon], MAP_SET.maxZoom);
if( node_type ){
L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map_ed).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");//.openPopup();
ed_anchor = L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map_ed).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");//.openPopup();
} else {
L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map_ed).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");//.openPopup();
ed_anchor = L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map_ed).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");//.openPopup();
};
var mapLayers = [];
/*
mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxNativeZoom: 18,
@ -872,7 +1013,7 @@ function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo( map_ed );
*/
if( node_type ){
switch( node_type ){
case 1:{
@ -919,19 +1060,49 @@ function updateSiteAnchor(){
SiteAlt = Ext.getCmp('siteAlt').getValue();
Ext.Ajax.request({
url: '/lib/controller/updateLocation.php',
params: {
SITE: <?=$SiteID;?>,
UID: <?=$UserID;?>,
TYPE: 1,
SID: '<?=$Session;?>',
LAT: SiteLat,
LON: SiteLon,
ALT: SiteAlt
},
failure: failureAJAXFunction
params: {
SITE: <?=$SiteID;?>,
UID: <?=$UserID;?>,
TYPE: 1,
SID: '<?=$Session;?>',
LAT: SiteLat,
LON: SiteLon,
ALT: SiteAlt
},
success: function(){
loadLocationEditor('sys_location_map');
},
failure: failureAJAXFunction
});
};
function updateSiteMap(){
MAP_ID = Ext.getCmp('siteMap').getValue();
Ext.Ajax.request({
url: '/lib/controller/updateLocation.php',
params: {
SITE: <?=$SiteID;?>,
UID: <?=$UserID;?>,
TYPE: 4,
SID: '<?=$Session;?>',
MID: MAP_ID
},
success: function( response, opts ){
reloadSiteMapData();
},
failure: failureAJAXFunction
});
};
var mapDataLoadded = false;
// Call this to prepare all data once in Session
function prepareMapData(){
//if( ap_type == 1 ) return;//Metro No Map ...
if( !mapDataLoadded ){
mapListStore.load();
};
};
function updateLocationOrientation(){
var tLat = Ext.getCmp('slat').getValue();
var tLon = Ext.getCmp('slon').getValue();
@ -1015,7 +1186,7 @@ function markerDblClick( e ){
};
};
};
/*
function setNodeLocationToAnchor(){
Ext.Ajax.request({
url: '/lib/controller/updateLocation.php',
@ -1030,7 +1201,7 @@ function setNodeLocationToAnchor(){
ALT: SiteAlt
},
success: function( response, opts ){
loadLocationEditor();
loadLocationEditor('sys_location_map');
},
failure: failureAJAXFunction
});
@ -1058,3 +1229,582 @@ function setNodeLocationByDelta(){
failure: failureAJAXFunction
});
};
*/
var mapCreatorWindow = null;
function createNewMap(){
if( mapCreatorWindow == null ){
mapCreatorWindow = new Ext.Window({
width: 800,
height: 440,
title: 'Creeate Custom Map',
modal: true,
frame: true,
border: false,
resizable: false,
items: [{
xtype: 'tabpanel',
id: 'mcr_tbp',
activeTab: 0,
items:[{
xtype: 'form',
title: 'Internet Map',
id: 'map_map_frm',
labelWidth: 250,
labelAlign: 'right',
height: 350,
items:[{
xtype: 'textfield',
fieldLabel: 'Map Name',
name: 'map_name',
width: 540,
},{
xtype: 'hidden',
name: 'ctype',
value: 1
},{
xtype: 'textfield',
fieldLabel: 'Tiles URL Pattern',
name: 'map_url',
width: 540,
},{
xtype: 'textfield',
fieldLabel: 'Layer Attribution',
name: 'map_attr',
width: 540,
},{
xtype: 'textarea',
fieldLabel: 'Description',
name: 'map_desc',
width: 540,
},{
xtype: 'combo',
fieldLabel: 'Max Zoom',
name: 'map_maxz',
editable: false,
typeAhead: true,
triggerAction: 'all',
width: 100,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['zoom_l'],
data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
}),
value: '18',
valueField: 'zoom_l',
displayField: 'zoom_l'
},{
xtype: 'combo',
fieldLabel: 'Max Native Zoom',
name: 'map_maxnz',
editable: false,
typeAhead: true,
triggerAction: 'all',
width: 100,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['zoom_l'],
data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
}),
value: '16',
valueField: 'zoom_l',
displayField: 'zoom_l'
}]
},{
xtype: 'form',
title: 'Local Picture Map',
id: 'map_pic_frm',
fileUpload: true,
height: 350,
//autoHeight: true,
//bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 250,
labelAlign: 'right',
defaults: {
//anchor: '95%',
//allowBlank: false,
msgTarget: 'side'
},
items: [{
xtype: 'textfield',
fieldLabel: '<?=$Labels->GetLabel('_MAP_NAME_');?>',
id: 'map_name_2',
name: 'map_name',
width: 540
},{
xtype: 'hidden',
name: 'ctype',
value: 2
},{
xtype: 'fileuploadfield',
id: 'form-file',
emptyText: '<?=$Labels->GetLabel('_SELE_ANIMAGE_');?>',
fieldLabel: '<?=$Labels->GetLabel('_MAP_PICTURE_');?>',
width: 500,
name: 'map_image',
buttonText: '<?=$Labels->GetLabel('_BROWSE_');?>'
},{
xtype: 'textfield',
fieldLabel: '<?=$Labels->GetLabel('_LAYER_ATTRIB_');?>',
name: 'map_attr',
width: 540,
},{
xtype: 'textarea',
fieldLabel: '<?=$Labels->GetLabel('_DESCRIPTION_');?>',
name: 'map_desc',
width: 540,
},{
xtype: 'combo',
fieldLabel: '<?=$Labels->GetLabel('_MAX_ZOOM_');?>',
editable: false,
typeAhead: true,
name: 'map_maxz',
triggerAction: 'all',
width: 100,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['zoom_l'],
data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
}),
value: '16',
valueField: 'zoom_l',
displayField: 'zoom_l'
},{
xtype: 'combo',
fieldLabel: '<?=$Labels->GetLabel('_MAX_NATURAL_ZOOM_');?>',
editable: false,
typeAhead: true,
name: 'map_maxnz',
triggerAction: 'all',
width: 100,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['zoom_l'],
data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
}),
value: '16',
valueField: 'zoom_l',
displayField: 'zoom_l'
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_TOP_PIC_BOUND_');?>',
name: 'map_tpb',
value: 0,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_LEFT_PIC_BOUND_');?>',
name: 'map_lpb',
value: 0,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_RIGHT_PIC_BOUND_');?>',
name: 'map_rpb',
value: 0,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_BOT_PIC_BOUND_');?>',
name: 'map_bpb',
value: 0,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_MAP_WIDTH_');?>',
name: 'map_width',
decimalPrecision: 2,
value: 1000.00,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_MAP_HEIGHT_');?>',
name: 'map_heigth',
decimalPrecision: 2,
value: 1000.00,
width: 540,
}]
}]
}],
bbar:[ '->',{
text: '<?=$Labels->GetLabel('_CANCEL_');?>',
handler: function(){
//Ext.getCmp('map_map_frm').getForm().reset();
//Ext.getCmp('map_pic_frm').getForm().reset();
mapCreatorEditorWindow.destroy();
}
},{
text: '<?=$Labels->GetLabel('_CREATE_NEW_LBL_');?>',
handler: function(){
var tt = Ext.getCmp('mcr_tbp').getActiveTab();
if( tt.id == 'map_map_frm' ){
if( Ext.getCmp('map_map_frm').getForm().isValid()){
Ext.getCmp('map_map_frm').getForm().submit({
url: '/lib/controller/addMap.php',
waitMsg: 'Uploading Data...',
encoding: 'multipart/form-data',
success: function(fp, o){
//msg('Success', 'Processed file "'+o.result.file+'" on the server');
alert('Processed file on the server');
}
});
};
} else {
if( Ext.getCmp('map_pic_frm').getForm().isValid()){
Ext.getCmp('map_pic_frm').getForm().submit({
url: '/lib/controller/addMap.php',
waitMsg: 'Uploading Image...',
encoding: 'multipart/form-data',
success: function(fp, o){
//msg('Success', 'Processed file "'+o.result.file+'" on the server');
alert('Processed file on the server');
}
});
};
};
}
}],
listeners:{
beforedestroy: function(){
mapCreatorEditorWindow = null;
}
}
});
};
mapCreatorWindow.show();
};
var mapEditorWindow = null;
function editCurrentMap(){
Ext.Ajax.request({
url: '/lib/controller/getMapData.php',
params: {
SITE: <?=$SiteID;?>,
UID: <?=$UserID;?>,
MID: MAP_ID
},
success: function( response, opts ){
var newMapData = Ext.decode( response.responseText );
if( mapEditorWindow == null ){
switch( newMapData.type ){
case 1:{
mapEditorWindow = new Ext.Window({
width: 800,
height: 440,
title: 'Edit Current Map',
modal: true,
//closeAction: 'hide',
frame: true,
border: false,
resizable: false,
items: [{
xtype: 'form',
id: 'map_map_frm',
labelWidth: 250,
labelAlign: 'right',
height: 350,
items:[{
xtype: 'textfield',
fieldLabel: 'Map Name',
id: 'map_name_1',
name: 'map_name',
width: 540,
},{
xtype: 'hidden',
name: 'ctype',
value: 1
},{
xtype: 'textfield',
fieldLabel: 'Tiles URL Pattern',
name: 'map_url',
width: 540,
},{
xtype: 'textfield',
fieldLabel: 'Layer Attribution',
name: 'map_attr',
width: 540,
},{
xtype: 'textarea',
fieldLabel: 'Description',
name: 'map_desc',
width: 540,
},{
xtype: 'combo',
fieldLabel: 'Max Zoom',
name: 'map_maxz',
editable: false,
typeAhead: true,
triggerAction: 'all',
width: 100,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['zoom_l'],
data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
}),
value: '18',
valueField: 'zoom_l',
displayField: 'zoom_l'
},{
xtype: 'combo',
fieldLabel: 'Max Native Zoom',
name: 'map_maxnz',
editable: false,
typeAhead: true,
triggerAction: 'all',
width: 100,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['zoom_l'],
data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
}),
value: '16',
valueField: 'zoom_l',
displayField: 'zoom_l'
}]
}],
bbar:[ '->',{
text: '<?=$Labels->GetLabel('_CANCEL_');?>',
handler: function(){
mapEditorWindow.destroy();
}
},{
text: '<?=$Labels->GetLabel('_APPLY_CHANGES_');?>',
handler: function(){
var tt = Ext.getCmp('mcr_tbp').getActiveTab();
if( tt.id == 'map_map_frm' ){
if( Ext.getCmp('map_map_frm').getForm().isValid()){
Ext.getCmp('map_map_frm').getForm().submit({
url: '/lib/controller/addMap.php',
waitMsg: 'Uploading Image...',
encoding: 'multipart/form-data',
success: function(fp, o){
//msg('Success', 'Processed file "'+o.result.file+'" on the server');
alert('Processed file on the server');
}
});
};
} else {
if( Ext.getCmp('map_pic_frm').getForm().isValid()){
Ext.getCmp('map_pic_frm').getForm().submit({
url: '/lib/controller/addMap.php',
waitMsg: 'Uploading Image...',
encoding: 'multipart/form-data',
success: function(fp, o){
//msg('Success', 'Processed file "'+o.result.file+'" on the server');
alert('Processed file on the server');
}
});
};
};
}
}],
listeners: {
beforedestroy: function(){
mapEditorWindow = null;
}
}
});
break;
};
default:{
mapEditorWindow = new Ext.Window({
width: 800,
height: 540,
title: 'Edit Current Map',
modal: true,
//closeAction: 'hide',
frame: true,
border: false,
resizable: false,
items: [{
xtype: 'form',
id: 'map_edt_frm',
height: 480,
//autoHeight: true,
//bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 250,
labelAlign: 'right',
defaults: {
//anchor: '95%',
//allowBlank: false,
msgTarget: 'side'
},
items:[{
xtype: 'spacer',
height: 6
},{
xtype: 'textfield',
fieldLabel: '<?=$Labels->GetLabel('_MAP_NAME_');?>',
name: 'map_name',
value: newMapData.name,
width: 540
},{
xtype: 'hidden',
name: 'MID',
value: newMapData.id
},{
xtype: 'panel',
frame: false,
border: false,
html: '<center><img height="50px" SRC="/lib/controller/data/assets/images/'+MAP_SET.layer_url+'"></center>'
},{
xtype: 'textfield',
fieldLabel: '<?=$Labels->GetLabel('_LAYER_ATTRIB_');?>',
name: 'map_attr',
value: newMapData.attribution,
width: 540,
},{
xtype: 'textarea',
fieldLabel: '<?=$Labels->GetLabel('_DESCRIPTION_');?>',
name: 'map_desc',
value: newMapData.desc,
width: 540,
},{
xtype: 'combo',
fieldLabel: '<?=$Labels->GetLabel('_MAX_ZOOM_');?>',
editable: false,
typeAhead: true,
name: 'map_maxz',
value: newMapData.maxZoom,
triggerAction: 'all',
width: 100,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['zoom_l'],
data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
}),
value: '16',
valueField: 'zoom_l',
displayField: 'zoom_l'
},{
xtype: 'combo',
fieldLabel: '<?=$Labels->GetLabel('_MAX_NATURAL_ZOOM_');?>',
editable: false,
typeAhead: true,
name: 'map_maxnz',
value: newMapData.maxNativeZoom,
triggerAction: 'all',
width: 100,
lazyRender:true,
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['zoom_l'],
data: [['16'], ['17'],['18'],['19'],['20'],['21'],['22'],['23'],['24'],['25'],['26'],['27'],['28']]
}),
value: '16',
valueField: 'zoom_l',
displayField: 'zoom_l'
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_TOP_PIC_BOUND_');?>',
name: 'map_tpb',
value: newMapData.img_tb,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_LEFT_PIC_BOUND_');?>',
name: 'map_lpb',
value: newMapData.img_lb,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_RIGHT_PIC_BOUND_');?>',
name: 'map_rpb',
value: newMapData.img_rb,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_BOT_PIC_BOUND_');?>',
name: 'map_bpb',
value: newMapData.img_bb,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_MAP_WIDTH_');?>',
name: 'map_width',
decimalPrecision: 2,
value: newMapData.img_map_w,
width: 540,
},{
xtype: 'numberfield',
fieldLabel: '<?=$Labels->GetLabel('_MAP_HEIGHT_');?>',
name: 'map_height',
decimalPrecision: 2,
value: newMapData.img_map_h,
width: 540,
},{
xtype: 'panel',
frame: false,
border: false,
layout: 'table',
layoutConfig: {
columns: 5
},
items:[{
xtype: 'spacer',
width: 250,
html: '<p style="text-align:right; margin-right: 5px;"><?=$Labels->GetLabel('_MAP_CENTER_MODE_');?>:</p>'
},{
xtype: 'radio',
name: 'bounds_mode',
value: 0,
checked: ( newMapData.bounds_mode == 0 ),
fieldLabel: '',
},{
width: 80,
html: '<img src="/style/assets/cust_map_cord_sys-0.png">'
},{
xtype: 'radio',
name: 'bounds_mode',
checked: ( newMapData.bounds_mode == 1 ),
value: 1,
fieldLabel: '',
},{
html: '<img src="/style/assets/cust_map_cord_sys-1.png">'
}]
}]
}],
bbar:[ '->',{
text: '<?=$Labels->GetLabel('_CANCEL_');?>',
handler: function(){
mapEditorWindow.destroy();
}
},{
text: '<?=$Labels->GetLabel('_APPLY_CHANGES_');?>',
handler: function(){
if( Ext.getCmp('map_edt_frm').getForm().isValid()){
Ext.getCmp('map_edt_frm').getForm().submit({
url: '/lib/controller/updateMap.php',
waitMsg: 'Uploading Image...',
encoding: 'multipart/form-data',
success: function(fp, o){
//msg('Success', 'Processed file "'+o.result.file+'" on the server');
alert('Processed file on the server');
}
});
};
}
}],
listeners: {
beforedestroy: function(){
mapEditorWindow = null;
}
}
});
break;
};
};
};
mapEditorWindow.show();
},
failure: failureAJAXFunction
});
};

69
lib/javascript/jsapi_dynamic/mojo_settings.js

@ -2060,6 +2060,10 @@ function showSettingsApplication(){
stopStatusUpdater();
content_lvl1 = 1;
content_lvl2 = 3;
//Load Location
prepareMapData();
var tPanel = Ext.getCmp('main_content');
tPanel.removeAll( true );
tPanel.add({
@ -2277,7 +2281,7 @@ function showSettingsApplication(){
html: '&nbsp;',
listeners:{
afterrender: function( t, state ){
loadLocationEditor( 'sys_location_map' );
loadLocationEditor('sys_location_map');
}
}
//}
@ -2290,27 +2294,29 @@ function showSettingsApplication(){
},
layoutConfig: {
// The total column count must be specified here
columns: 7,
columns: 8,
textAlign: 'center'
},
items:[{
border: false,
html: '<?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?> <?=$Labels->GetLabel('_LAT_SHORT_LBL_');?>:'
id: 'lab_123',
html: '<?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?> '+((MAP_IS_LOCAL)?'Pos X':'<?=$Labels->GetLabel('_LON_SHORT_LBL_');?>')+':'
},{
xtype: 'numberfield',
id: 'siteLat',
decimalPrecision: 8,
width: 100,
value: SiteLat
decimalPrecision: 8,
id: 'siteLon',
value: SiteLon
},{
border: false,
html: '<?=$Labels->GetLabel('_LON_SHORT_LBL_');?>:'
id: 'lab_124',
html: ((MAP_IS_LOCAL)?'Pos Y':'<?=$Labels->GetLabel('_LAT_SHORT_LBL_');?>')+':'
},{
xtype: 'numberfield',
width: 100,
id: 'siteLat',
decimalPrecision: 8,
id: 'siteLon',
value: SiteLon
width: 100,
value: SiteLat
},{
border: false,
html: '<?=$Labels->GetLabel('_ALT_SHORT_LBL_');?>:'
@ -2324,6 +2330,12 @@ function showSettingsApplication(){
xtype: 'button',
text: '<?=$Labels->GetLabel('_UPDATE_LBL_');?>',
handler: updateSiteAnchor
},{
xtype: 'panel',
frame: false,
border: false,
rowspan: 2,
html: ((MAP_IS_LOCAL)?'<img id="lab_125" height="64px" src="/style/assets/map_mode_decart.png">':'<img id="lab_125" height="64px" src="/style/assets/map_mode_wgs84.png">')
},{
border: false,
html: '<?=$Labels->GetLabel('_MAP_TYP_LBL_');?>:'
@ -2344,22 +2356,47 @@ function showSettingsApplication(){
disabled: false,
typeAhead: true,
triggerAction: 'all',
id: 'siteMap',
lazyRender:true,
colspan: 5,
colspan: 3,
mode: 'local',
store: new Ext.data.ArrayStore({
store: mapListStore /*new Ext.data.ArrayStore({
id: 0,
fields: ['map_id', 'map_text' ],
data: [[1, 'OpenStreetMap'], [2, 'OpenTopoMap'], [3, 'EsriSat'], [4, 'EsriStreet'], [5, 'EsriTopo']]
}),
})*/,
value: MAP_ID,
valueField: 'map_id',
displayField: 'map_text'
displayField: 'map_name',
listeners:{
select: function(){
updateSiteMap();
LoadNodesList();
}
}
},{
xtype: 'button',
disabled: false,
text: '<?=$Labels->GetLabel('_EDIT_');?>',
handler: function(){
editCurrentMap();
}
},{
xtype: 'button',
disabled: false,
text: '<?=$Labels->GetLabel('_DELETE_');?>',
handler: function(){
deleteCurrentMap();
}
},{
xtype: 'button',
id: 'add-c_map-btn',
disabled: true,
text: '<?=$Labels->GetLabel('_CREATE_NEW_LBL_');?>'
disabled: false,
text: '<?=$Labels->GetLabel('_CREATE_NEW_LBL_');?>',
handler: function(){
createNewMap();
}
}]
}]
},{

9
lib/js_asm.php

@ -61,8 +61,13 @@ if( isset($_GET['Lang'])){
$UCL=$_GET['Lang']/1;
if ($UCL) $_SESSION['userlang']=$UCL; else $_SESSION['userlang']=$UserLang;
}
if( isset($_SESSION['userlang']) )$Labels=new Language($_SESSION['userlang']);//, '_js');
else $Labels=new Language( $UserLang );//, '_js');
$LDB = new SQLite_DB( '/srv/www/web/lib/controller/data/language.db');
if( isset($_SESSION['userlang']) ){
$Labels=new Language( $_SESSION['userlang'],'', $LDB );
} else {
$Labels=new Language( $UserLang ,'', $LDB );
};
if( $UserLang == 3 || $UserLang == 255 ){
$RTL_SITE = true;

17
lib/php/db/language_class.php

@ -1,25 +1,32 @@
<?php
class Language{
var $Labels;
function Language($LangID=1, $_module = ''){
function Language($LangID=1, $_module = '', $DBM = null ){
global $DATABASE;
$this->Labels=array();
$QS="SELECT key, label FROM labels" . $_module . " WHERE language_id='{$LangID}'";
$result= $DATABASE->Query($QS);
if( $DBM == null ){
$result= $DATABASE->Query($QS);
} else {
$result= $DBM->Query($QS);
}
foreach ( $result as $array) $this->Labels[$array['key']]=$array['label'];
}
function GetLabel($LabelKey){
//global $Labels;
if (isset($this->Labels[$LabelKey])){
return $this->Labels[$LabelKey];
} else return $LabelKey;
}
function AddLabel($LabelKey, $LabelText, $LanguageID)
function AddLabel($LabelKey, $LabelText, $LanguageID, $DBM = null )
{
global $DATABASE;
$QS="INSERT INTO labels SET key='$LabelKey', label='$LabelText', language_id=$LanguageID";
$result= $DATABASE->Query($QS, false);
if( $DBM == null ){
$DATABASE->Query($QS, false);
} else {
$DBM->Query($QS, false);
};
}
};

BIN
style/assets/anchor_sys-1.psd

Binary file not shown.

BIN
style/assets/cust_map_cord_sys-0.png

Binary file not shown.

After

Width: 64  |  Height: 64  |  Size: 3.0 KiB

BIN
style/assets/cust_map_cord_sys-1.png

Binary file not shown.

After

Width: 64  |  Height: 64  |  Size: 3.0 KiB

BIN
style/assets/map_mode_decart.png

Binary file not shown.

After

Width: 128  |  Height: 128  |  Size: 13 KiB

BIN
style/assets/map_mode_wgs84.png

Binary file not shown.

After

Width: 128  |  Height: 128  |  Size: 17 KiB

Loading…
Cancel
Save