|
@@ -13,11 +13,11 @@ class Route_UrlAction_WmsGenerate extends RouteBase {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getDirectory($id) {
|
|
|
|
|
- $folderConf = FoldersConfig::getAll('WMS_LAYERS_COLUMN');
|
|
|
|
|
|
|
+ private function getDirectory($table,$id) {
|
|
|
|
|
+ $folderConf = FoldersConfig::getAll($table.'_COLUMN');
|
|
|
$record=new stdClass;
|
|
$record=new stdClass;
|
|
|
$record->ID=$id;
|
|
$record->ID=$id;
|
|
|
- $uploader = new FileUploader('WMS_LAYERS_COLUMN', $record);
|
|
|
|
|
|
|
+ $uploader = new FileUploader($table.'_COLUMN', $record);
|
|
|
$errMsg="";
|
|
$errMsg="";
|
|
|
if (!$uploader->setConfig($folderConf, $errMsg)) throw new HttpException("Błąd danych konfiguracyjnych" . '<br>' . "\n" . $errMsg, 404);
|
|
if (!$uploader->setConfig($folderConf, $errMsg)) throw new HttpException("Błąd danych konfiguracyjnych" . '<br>' . "\n" . $errMsg, 404);
|
|
|
$uploader->findFolder();
|
|
$uploader->findFolder();
|
|
@@ -37,7 +37,7 @@ class Route_UrlAction_WmsGenerate extends RouteBase {
|
|
|
|
|
|
|
|
if ($layer[0]['FILE_STATUS']=="IN_PROGRESS") throw new Exception('Błąd - plik w trakcie przetwarzania!');
|
|
if ($layer[0]['FILE_STATUS']=="IN_PROGRESS") throw new Exception('Błąd - plik w trakcie przetwarzania!');
|
|
|
|
|
|
|
|
- $destFolderPath = $this->getDirectory($ID_WMS_LAYERS);
|
|
|
|
|
|
|
+ $destFolderPath = $this->getDirectory('WMS_LAYERS',$ID_WMS_LAYERS);
|
|
|
$files=array();
|
|
$files=array();
|
|
|
|
|
|
|
|
if ($layer[0]['LAYER_TYPE']=='GeoTIFF') {
|
|
if ($layer[0]['LAYER_TYPE']=='GeoTIFF') {
|
|
@@ -122,20 +122,54 @@ class Route_UrlAction_WmsGenerate extends RouteBase {
|
|
|
private function defaultAction_WIZJE_LOKALNE($ID_WIZJE_LOKALNE,$REFERER) {
|
|
private function defaultAction_WIZJE_LOKALNE($ID_WIZJE_LOKALNE,$REFERER) {
|
|
|
try {
|
|
try {
|
|
|
SE_Layout::alert('warning','Funkcja w trakcie implementacji');
|
|
SE_Layout::alert('warning','Funkcja w trakcie implementacji');
|
|
|
- if (V::get('ID_WMS_LAYERS',0,$_POST,'int')!=0) {
|
|
|
|
|
- //$ID=DB::getDB()->ADD_NEW_OBJ('WMS_LAYERS',(object) array('FILE_STATUS'=>'ERROR','FILE_STATUS_INFO'=>'Wystąpił błąd pliku qgs'));
|
|
|
|
|
- $WmsLayerTableZasobId=ProcesHelper::getZasobTableID('WMS_LAYERS');
|
|
|
|
|
|
|
+ $wizje=DB::getPDO()->fetchall("select WMS_LAYER_ID,LAYER_NAME from WIZJE_LOKALNE where ID='".$ID_WIZJE_LOKALNE."'");
|
|
|
|
|
+ if (!$wizje) throw new Exception("Błąd danych");
|
|
|
|
|
+
|
|
|
|
|
+ $displayForm=true;
|
|
|
|
|
+ $dirWizja=$this->getDirectory('WIZJE_LOKALNE',$ID_WIZJE_LOKALNE);
|
|
|
|
|
+ exec('find '.$dirWizja.' -type f -name "*.tif" 2>/dev/null',$files);
|
|
|
|
|
+ if (!$files) {
|
|
|
|
|
+ SE_Layout::alert('danger',"Wybrana wizja lokalna nie zawiera żadnych plików GeoTIFF!");
|
|
|
?>
|
|
?>
|
|
|
<div class="container" style="text-align:center">
|
|
<div class="container" style="text-align:center">
|
|
|
<a href="<?php echo $REFERER?>" class="btn btn-primary">Powrót</a>
|
|
<a href="<?php echo $REFERER?>" class="btn btn-primary">Powrót</a>
|
|
|
</div>
|
|
</div>
|
|
|
<?php
|
|
<?php
|
|
|
|
|
+ $displayForm=false;
|
|
|
} else {
|
|
} else {
|
|
|
- $wizje=DB::getPDO()->fetchall("select WMS_LAYER_ID,LAYER_NAME from WIZJE_LOKALNE where ID='".$ID_WIZJE_LOKALNE."'");
|
|
|
|
|
|
|
+ $ID_WMS_LAYERS=V::get('ID_WMS_LAYERS',0,$_POST,'int');
|
|
|
|
|
+ $file=V::get('file','',$_POST);
|
|
|
|
|
+ if ($ID_WMS_LAYERS!=0) {
|
|
|
|
|
+ if ($file=='') SE_Layout::alert('danger','Nie wybrano żadnego pliku!');
|
|
|
|
|
+ else {
|
|
|
|
|
+ $displayForm=false;
|
|
|
|
|
+ if ($ID_WMS_LAYERS==-1) $ID_WMS_LAYERS=DB::getDB()->ADD_NEW_OBJ('WMS_LAYERS',(object) array('LAYER_NAME'=>$wizje[0]['LAYER_NAME']));
|
|
|
|
|
+ echo $ID_WMS_LAYERS;
|
|
|
|
|
+ $WmsLayerDir=$this->getDirectory('WMS_LAYERS',$ID_WMS_LAYERS);
|
|
|
|
|
+ if (!file_exists($WmsLayerDir)) @mkdir($WmsLayerDir);
|
|
|
|
|
+ if (!is_dir($WmsLayerDir)) {
|
|
|
|
|
+ DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('FILE_STATUS_INFO'=>'Nie można utworzyć katalogu warstwy');
|
|
|
|
|
+ throw new Exception("Wystąpił nieoczekiwany błąd - nie można utworzyć katalogu ".$WmsLayerDir);
|
|
|
|
|
+ }
|
|
|
|
|
+ @chmod($WmsLayerDir, 0777);
|
|
|
|
|
+ exec("rm -f ".$WmsLayerDir."/*.tif 2>/dev/null");
|
|
|
|
|
+ symlink($file,$WmsLayerDir."/".basename($file));
|
|
|
|
|
+ $WmsLayerTableZasobId=ProcesHelper::getZasobTableID('WMS_LAYERS');
|
|
|
|
|
+ DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('FILE_STATUS_INFO'=>'Utoworzono link symboliczny z poziomu tabeli WIZJE_LOKALNE');
|
|
|
|
|
+?>
|
|
|
|
|
+<div class="container" style="text-align:center">
|
|
|
|
|
+ <a href="<?php echo $REFERER?>" class="btn btn-primary">Powrót</a>
|
|
|
|
|
+</div>
|
|
|
|
|
+<?php
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($displayForm) {
|
|
|
if ($wizje[0]['WMS_LAYER_ID']) {
|
|
if ($wizje[0]['WMS_LAYER_ID']) {
|
|
|
$layers=DB::getPDO()->fetchall("select LAYER_NAME,LAYER_TYPE from WMS_LAYERS where ID='".$wizje[0]['WMS_LAYER_ID']."'");
|
|
$layers=DB::getPDO()->fetchall("select LAYER_NAME,LAYER_TYPE from WMS_LAYERS where ID='".$wizje[0]['WMS_LAYER_ID']."'");
|
|
|
if ($layers[0]['LAYER_TYPE']!="GeoTIFF") throw new Exception("Niespójny typ wartstwy - należy zmienić typ warstwy ID ".$wizje[0]['WMS_LAYER_ID']." na GeoTIFF");
|
|
if ($layers[0]['LAYER_TYPE']!="GeoTIFF") throw new Exception("Niespójny typ wartstwy - należy zmienić typ warstwy ID ".$wizje[0]['WMS_LAYER_ID']." na GeoTIFF");
|
|
|
$LAYER_NAME=$layers[0]['LAYER_NAME'];
|
|
$LAYER_NAME=$layers[0]['LAYER_NAME'];
|
|
|
|
|
+ if (!$LAYER_NAME) $LAYER_NAME="BRAK NAZWY WARSTWY";
|
|
|
}
|
|
}
|
|
|
if (!$wizje) throw new Exception("Błędne ID z tabeli WIZJE_LOKALNE");
|
|
if (!$wizje) throw new Exception("Błędne ID z tabeli WIZJE_LOKALNE");
|
|
|
?>
|
|
?>
|
|
@@ -145,12 +179,15 @@ class Route_UrlAction_WmsGenerate extends RouteBase {
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label class="col-sm-1 control-label">Warstwa</label>
|
|
<label class="col-sm-1 control-label">Warstwa</label>
|
|
|
<div class="col-sm-11">
|
|
<div class="col-sm-11">
|
|
|
- <select id="warstwa" class="form-control" name="ID_WMS_LAYERS"<?php if ($wizje[0]['WMS_LAYER_ID']) echo " disabled"?>>
|
|
|
|
|
- <option value=<?php echo '"'.($wizje[0]['WMS_LAYER_ID']?$wizje[0]['WMS_LAYER_ID'].'">'.$LAYER_NAME:'-1">(Utwórz nową warstwę) '.$wizje[0]['LAYER_NAME'])?></option>
|
|
|
|
|
<?php
|
|
<?php
|
|
|
- if (!$wizje[0]['WMS_LAYER_ID']) {
|
|
|
|
|
|
|
+ if ($wizje[0]['WMS_LAYER_ID']) echo '<p class="form-control-static">ID:'.$wizje[0]['WMS_LAYER_ID']." ".$LAYER_NAME.'</p><p style="color:red;">Uwaga! Ten rekord wizji lokalnej został już powiazany z daną warstwą i nie ma możliwości zmiany powiązania.<br/>Ponowne dodanie pliku GeoTIFF spowoduje usunięcie dotychczasowego pliku GeoTIFF z danej warstwy.</p>'."\n".'<input type="hidden" name="ID_WMS_LAYERS" value="'.$wizje[0]['WMS_LAYER_ID'].'"/>'."\n";
|
|
|
|
|
+ else {
|
|
|
|
|
+?>
|
|
|
|
|
+ <select id="warstwa" class="form-control" name="ID_WMS_LAYERS">
|
|
|
|
|
+ <option value="-1">(Utwórz nową warstwę) <?php echo $wizje[0]['LAYER_NAME']?></option>
|
|
|
|
|
+<?php
|
|
|
$layers=DB::getPDO()->fetchall("select ID,LAYER_NAME from WMS_LAYERS where LAYER_TYPE='GeoTIFF' and A_STATUS='WAITING'");
|
|
$layers=DB::getPDO()->fetchall("select ID,LAYER_NAME from WMS_LAYERS where LAYER_TYPE='GeoTIFF' and A_STATUS='WAITING'");
|
|
|
- foreach ($layers as $layer) echo '<option value="'.$layer['ID'].'">(Oczekująca warstwa) '.$layer['ID'].': '.$layer['LAYER_NAME'].'</option>\n';
|
|
|
|
|
|
|
+ foreach ($layers as $layer) echo '<option value="'.$layer['ID'].'"'.($layer['ID']==$ID_WMS_LAYERS?" selected":"").'>(Oczekująca warstwa) '.$layer['ID'].': '.$layer['LAYER_NAME'].'</option>\n';
|
|
|
}
|
|
}
|
|
|
?>
|
|
?>
|
|
|
</select>
|
|
</select>
|
|
@@ -158,8 +195,18 @@ class Route_UrlAction_WmsGenerate extends RouteBase {
|
|
|
</div>
|
|
</div>
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label class="col-sm-1 control-label">Plik</label>
|
|
<label class="col-sm-1 control-label">Plik</label>
|
|
|
- <div class="col-sm-11">
|
|
|
|
|
- Tutaj będą pliki
|
|
|
|
|
|
|
+ <div class="col-sm-11" style="max-height:400px; overflow:auto;">
|
|
|
|
|
+ <table class="table table-bordered table-hover">
|
|
|
|
|
+ <thead>
|
|
|
|
|
+ <tr style="text-align:center;"><td width="1"></td><td>Ścieżka/nazwa</td><td width="1">Wielkość</td><td width="1">Data</td></tr>
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+<?php
|
|
|
|
|
+ foreach ($files as $file)
|
|
|
|
|
+ echo '<tr><td><input style="margin:0; position:relative;" type="radio" name="file" value="'.$file.'"/></td><td>'.substr($file,strlen($dirWizja)+1).'</td><td style="text-align:right;" nowrap>'.V::humanFileSize(filesize($file))."</td><td nowrap>".date("Y-m-d H:i:s",filectime($file))."</td></tr>\n";
|
|
|
|
|
+?>
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
@@ -168,7 +215,7 @@ class Route_UrlAction_WmsGenerate extends RouteBase {
|
|
|
<a href="<?php echo $REFERER?>" class="btn btn-default">Anuluj</a>
|
|
<a href="<?php echo $REFERER?>" class="btn btn-default">Anuluj</a>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <input type="hidden" name="WMS_REFERER" value="<?php echo $_SERVER['HTTP_REFERER']?>"/>
|
|
|
|
|
|
|
+ <input type="hidden" name="WMS_REFERER" value="<?php echo $REFERER?>"/>
|
|
|
</form>
|
|
</form>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -233,7 +280,7 @@ openOnFocus: false
|
|
|
### Przetworzenie projektów QGIS
|
|
### Przetworzenie projektów QGIS
|
|
|
$layers=DB::getPDO()->fetchall("select ID,FILE_NAME,LAYER_NAME,A_STATUS,ID_WMS_MAPS from WMS_LAYERS where LAYER_TYPE='QGIS' and FILE_STATUS='TO_GENERATE'");
|
|
$layers=DB::getPDO()->fetchall("select ID,FILE_NAME,LAYER_NAME,A_STATUS,ID_WMS_MAPS from WMS_LAYERS where LAYER_TYPE='QGIS' and FILE_STATUS='TO_GENERATE'");
|
|
|
foreach ($layers as $layer) {
|
|
foreach ($layers as $layer) {
|
|
|
- $destFolderPath = $this->getDirectory($layer['ID']);
|
|
|
|
|
|
|
+ $destFolderPath = $this->getDirectory('WMS_LAYERS',$layer['ID']);
|
|
|
if(!is_file($destFolderPath.'/'.$layer['FILE_NAME'])) {
|
|
if(!is_file($destFolderPath.'/'.$layer['FILE_NAME'])) {
|
|
|
DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'ERROR','FILE_STATUS_INFO'=>'Wystąpił błąd pliku qgs'));
|
|
DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'ERROR','FILE_STATUS_INFO'=>'Wystąpił błąd pliku qgs'));
|
|
|
throw new Exception("Błąd pliku: ".$layer['FILE_NAME']);
|
|
throw new Exception("Błąd pliku: ".$layer['FILE_NAME']);
|
|
@@ -342,7 +389,7 @@ END
|
|
|
foreach ($layers as $layer) {
|
|
foreach ($layers as $layer) {
|
|
|
if (!file_exists('/tmp/generate_wms-'.$layer['ID'].'.lock')) {
|
|
if (!file_exists('/tmp/generate_wms-'.$layer['ID'].'.lock')) {
|
|
|
unlink('/tmp/generate_wms-'.$layer['ID'].'.sh');
|
|
unlink('/tmp/generate_wms-'.$layer['ID'].'.sh');
|
|
|
- $destFolderPath = $this->getDirectory($layer['ID']);
|
|
|
|
|
|
|
+ $destFolderPath = $this->getDirectory('WMS_LAYERS',$layer['ID']);
|
|
|
if (file_exists($destFolderPath.'/.wms/.completed')) {
|
|
if (file_exists($destFolderPath.'/.wms/.completed')) {
|
|
|
if (file_exists($destFolderPath.'/.wms/.error')) {
|
|
if (file_exists($destFolderPath.'/.wms/.error')) {
|
|
|
DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'ERROR','FILE_STATUS_INFO'=>'Wystąpił błąd przetwarzania, przekaż problem administratorowi systemu'));
|
|
DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'ERROR','FILE_STATUS_INFO'=>'Wystąpił błąd przetwarzania, przekaż problem administratorowi systemu'));
|
|
@@ -382,7 +429,7 @@ END
|
|
|
$layers=DB::getPDO()->fetchall("select ID,ID_WMS_MAPS,LAYER_TYPE from WMS_LAYERS where A_STATUS='NORMAL' and FILE_STATUS='GENERATED' and MAP_STATUS='INACTIVE'");
|
|
$layers=DB::getPDO()->fetchall("select ID,ID_WMS_MAPS,LAYER_TYPE from WMS_LAYERS where A_STATUS='NORMAL' and FILE_STATUS='GENERATED' and MAP_STATUS='INACTIVE'");
|
|
|
foreach ($layers as $layer) {
|
|
foreach ($layers as $layer) {
|
|
|
if (!file_exists($wmsDirLocation.'/.maps/.single/'.$layer['ID'].$mapFileSuffix[$layer['LAYER_TYPE']])) {
|
|
if (!file_exists($wmsDirLocation.'/.maps/.single/'.$layer['ID'].$mapFileSuffix[$layer['LAYER_TYPE']])) {
|
|
|
- $destFolderPath = $this->getDirectory($layer['ID']);
|
|
|
|
|
|
|
+ $destFolderPath = $this->getDirectory('WMS_LAYERS',$layer['ID']);
|
|
|
symlink($destFolderPath.'/.wms/wms'.$mapFileSuffix[$layer['LAYER_TYPE']],$wmsDirLocation.'/.maps/.single/'.$layer['ID'].$mapFileSuffix[$layer['LAYER_TYPE']]);
|
|
symlink($destFolderPath.'/.wms/wms'.$mapFileSuffix[$layer['LAYER_TYPE']],$wmsDirLocation.'/.maps/.single/'.$layer['ID'].$mapFileSuffix[$layer['LAYER_TYPE']]);
|
|
|
}
|
|
}
|
|
|
DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'MAP_STATUS'=>'ACTIVE'));
|
|
DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'MAP_STATUS'=>'ACTIVE'));
|
|
@@ -514,10 +561,6 @@ END
|
|
|
foreach ($layers as $layer) {
|
|
foreach ($layers as $layer) {
|
|
|
if ($layer['LAYER_NAME']) $LAYER_NAME=V::convert($layer['LAYER_NAME'],'url');
|
|
if ($layer['LAYER_NAME']) $LAYER_NAME=V::convert($layer['LAYER_NAME'],'url');
|
|
|
else $LAYER_NAME=$layer['LAYER_TYPE']."_".$layer['ID'];
|
|
else $LAYER_NAME=$layer['LAYER_TYPE']."_".$layer['ID'];
|
|
|
- //$destFolderPath = $this->getDirectory($layer['ID']);
|
|
|
|
|
- //$file=$destFolderPath.'/.wms/'.$layer['FILE_NAME'];
|
|
|
|
|
- //if(is_file($file)) $files[]='"'.$file.'"';
|
|
|
|
|
- //else throw new Exception("ERROR - couldn't find file ".$file."\n");
|
|
|
|
|
$replace=array($LAYER_NAME,$urlLayerType[$layer['LAYER_TYPE']],$layer['ID'],$layer['EXTENT'],$layer['EPSG'],$wmsDirLocation.'/.maps/.template.html');
|
|
$replace=array($LAYER_NAME,$urlLayerType[$layer['LAYER_TYPE']],$layer['ID'],$layer['EXTENT'],$layer['EPSG'],$wmsDirLocation.'/.maps/.template.html');
|
|
|
$MAP_LAYERS .= str_replace($layerSearch,$replace,$layerSchema[$layer['LAYER_TYPE']]);
|
|
$MAP_LAYERS .= str_replace($layerSearch,$replace,$layerSchema[$layer['LAYER_TYPE']]);
|
|
|
$EPSGS['EPSG:'.$layer['EPSG']]=1;
|
|
$EPSGS['EPSG:'.$layer['EPSG']]=1;
|
|
@@ -568,7 +611,7 @@ fi
|
|
|
$layers=DB::getPDO()->fetchall("select ID,FILE_NAME from WMS_LAYERS where LAYER_TYPE='GeoTIFF' and FILE_STATUS='TO_GENERATE'");
|
|
$layers=DB::getPDO()->fetchall("select ID,FILE_NAME from WMS_LAYERS where LAYER_TYPE='GeoTIFF' and FILE_STATUS='TO_GENERATE'");
|
|
|
foreach ($layers as $layer) {
|
|
foreach ($layers as $layer) {
|
|
|
echo $layer['ID']."\n";
|
|
echo $layer['ID']."\n";
|
|
|
- $destFolderPath = $this->getDirectory($layer['ID']);
|
|
|
|
|
|
|
+ $destFolderPath = $this->getDirectory('WMS_LAYERS',$layer['ID']);
|
|
|
if(!is_file($destFolderPath.'/'.$layer['FILE_NAME'])) {
|
|
if(!is_file($destFolderPath.'/'.$layer['FILE_NAME'])) {
|
|
|
DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'ERROR','FILE_STATUS_INFO'=>'Wystąpił błąd pliku tif'));
|
|
DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'ERROR','FILE_STATUS_INFO'=>'Wystąpił błąd pliku tif'));
|
|
|
throw new Exception("Błąd pliku: ".$layer['FILE_NAME']);
|
|
throw new Exception("Błąd pliku: ".$layer['FILE_NAME']);
|