|
|
@@ -171,8 +171,28 @@ class Route_UrlAction_WmsGenerate extends RouteBase {
|
|
|
throw new Exception("Błąd pliku: ".$layer['FILE_NAME']);
|
|
|
}
|
|
|
|
|
|
- $dataSources=$xml->xpath('/qgis/projectlayers/maplayer/datasource');
|
|
|
- foreach ($dataSources as $id => $file) $dataSources[$id][0]=$destFolderPath.'/.wms/'.basename($file);
|
|
|
+ $extents=array();
|
|
|
+ $mapLayers=$xml->xpath('/qgis/projectlayers/maplayer');
|
|
|
+ foreach ($mapLayers as $mapLayer) {
|
|
|
+ $mapLayer->datasource=$destFolderPath.'/.wms/'.basename($mapLayer->datasource);
|
|
|
+ $bash='
|
|
|
+tmp=`mktemp -d`
|
|
|
+ogr2ogr -s_srs EPSG:'.$mapLayer->srs->spatialrefsys->srid.' -t_srs EPSG:4236 "$tmp/tmp.shp" "'.$mapLayer->datasource.'" >/dev/null 2>&1
|
|
|
+extent=`ogrinfo -al -so "$tmp/tmp.shp" | grep Extent | sed "s/[(),\-]//g;s/ / /g;s/Extent: //g"`
|
|
|
+echo "${extent} "
|
|
|
+rm -rf $tmp
|
|
|
+';
|
|
|
+ $extent=explode(" ",shell_exec($bash));
|
|
|
+ $extents['xmin'][]=$extent[0];
|
|
|
+ $extents['ymin'][]=$extent[1];
|
|
|
+ $extents['xmax'][]=$extent[2];
|
|
|
+ $extents['ymax'][]=$extent[3];
|
|
|
+ }
|
|
|
+ $xmin=min($extents['xmin']);
|
|
|
+ $ymin=min($extents['ymin']);
|
|
|
+ $xmax=max($extents['xmax']);
|
|
|
+ $ymax=max($extents['ymax']);
|
|
|
+ $geom="POLYGON(({$xmin} {$ymax},{$xmax} {$ymax},{$xmax} {$ymin},{$xmin} {$ymin},{$xmin} {$ymax}))";
|
|
|
|
|
|
if ($layer['LAYER_NAME']) $LAYER_NAME=V::convert($layer['LAYER_NAME'],'url');
|
|
|
else $LAYER_NAME="QGIS_".$layer['ID'];
|
|
|
@@ -192,9 +212,7 @@ class Route_UrlAction_WmsGenerate extends RouteBase {
|
|
|
|
|
|
$xml->asXml($destFolderPath.'/.wms/wms.qgs');
|
|
|
unlink($destFolderPath.'/.wms/'.$layer['FILE_NAME']);
|
|
|
- //TODO calculate wgs84
|
|
|
- //DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'GENERATED','FILE_STATUS_INFO'=>'Plik przetworzony poprawnie','the_geom'=>"GeomFromText('{$geom}')",'EPSG'=>"{$epsg}",'EXTENT'=>"{$extent}"));
|
|
|
- DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'GENERATED','FILE_STATUS_INFO'=>'Plik przetworzony poprawnie','EPSG'=>"{$epsg}",'EXTENT'=>"{$extent}"));
|
|
|
+ DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'GENERATED','FILE_STATUS_INFO'=>'Plik przetworzony poprawnie','the_geom'=>"GeomFromText('{$geom}')",'EPSG'=>"{$epsg}",'EXTENT'=>"{$extent}"));
|
|
|
if ($layer['A_STATUS']=='NORMAL') $mapsToGenerate[$layer['ID_WMS_MAPS']]=1;
|
|
|
}
|
|
|
|
|
|
@@ -449,19 +467,19 @@ END
|
|
|
|
|
|
### Wygenerowanie plików tif warstw
|
|
|
$bashSchema='
|
|
|
-#rm -rf __PATH__/.wms
|
|
|
-#mkdir __PATH__/.wms
|
|
|
+rm -rf __PATH__/.wms
|
|
|
+mkdir __PATH__/.wms
|
|
|
lock="/tmp/generate_wms-__ID__.lock"
|
|
|
touch ${lock}
|
|
|
-gdaltindex -t_srs epsg:4326 /tmp/generate_wms-__ID__-shp_wgs84.shp __PATH__/__FILE__ >/dev/null 2>&1
|
|
|
+gdaltindex -t_srs epsg:4326 /tmp/generate_wms-__ID__-shp_wgs84.shp "__PATH__/__FILE__" >/dev/null 2>&1
|
|
|
ogr2ogr -f CSV /tmp/generate_wms-__ID__-shp_wgs84.csv /tmp/generate_wms-__ID__-shp_wgs84.shp -lco GEOMETRY=AS_WKT
|
|
|
wgs84=`cat /tmp/generate_wms-__ID__-shp_wgs84.csv |tr -d "\n" | cut -d "\"" -f 2`
|
|
|
-gdaltindex /tmp/generate_wms-__ID__-shp_orig.shp __PATH__/__FILE__ >/dev/null 2>&1
|
|
|
+gdaltindex /tmp/generate_wms-__ID__-shp_orig.shp "__PATH__/__FILE__" >/dev/null 2>&1
|
|
|
extent=`ogrinfo -al -so /tmp/generate_wms-__ID__-shp_orig.shp | grep Extent | sed "s/[(),\-]//g;s/ / /g;s/Extent: //g"`
|
|
|
rm -f /tmp/generate_wms-__ID__-shp_*
|
|
|
echo "${wgs84}|${extent}|" > __PATH__/.wms/.data
|
|
|
ok=0
|
|
|
-#/opt/local/bin/gdal_translate -of GTiff -co "TILED=YES" -co "COMPRESS=DEFLATE" -co "ZLEVEL=9" -co "BIGTIFF=YES" __PATH__/__FILE__ __PATH__/.wms/__FILE__ && /opt/local/bin/gdaladdo -r average __PATH__/.wms/__FILE__ 2 4 8 16 32 64 128 && ok=1
|
|
|
+/opt/local/bin/gdal_translate -of GTiff -co "TILED=YES" -co "COMPRESS=DEFLATE" -co "ZLEVEL=9" -co "BIGTIFF=YES" "__PATH__/__FILE__" "__PATH__/.wms/__FILE__" && /opt/local/bin/gdaladdo -r average "__PATH__/.wms/__FILE__" 2 4 8 16 32 64 128 && ok=1
|
|
|
rm -f ${lock}
|
|
|
touch __PATH__/.wms/.completed
|
|
|
if [ "$ok" -eq 1 ]; then
|
|
|
@@ -481,6 +499,7 @@ fi
|
|
|
throw new Exception("Błąd pliku: ".$layer['FILE_NAME']);
|
|
|
}
|
|
|
$xml=@simplexml_load_string(shell_exec('gdalsrsinfo -o xml '.$destFolderPath.'/'.$layer['FILE_NAME']));
|
|
|
+//var_dump($xml);
|
|
|
$epsg=$xml->{'gml:srsID'}->{'gml:name'};
|
|
|
if (!$epsg) {
|
|
|
DB::getDB()->UPDATE_OBJ('WMS_LAYERS',(object) array('ID'=>$layer['ID'],'FILE_STATUS'=>'ERROR','FILE_STATUS_INFO'=>'Wystąpił błąd pliku tif - brak informacji o układzie współrzędnych'));
|