コード例 #1
0
 /**
  * GetLegendGraphics
  * @param string $repository Lizmap Repository
  * @param string $project Name of the project : mandatory
  * @return Image of the legend for 1 to n layers, returned by the Map Server
  */
 function GetLegendGraphics()
 {
     //Get parameters  DELETED HERE SINCE ALREADY DONE IN index method
     //if(!$this->getServiceParameters())
     //return $this->serviceException();
     $wmsRequest = new lizmapWMSRequest($this->project, $this->params);
     $result = $wmsRequest->process();
     $rep = $this->getResponse('binary');
     $rep->mimeType = $result->mime;
     $rep->content = $result->data;
     $rep->doDownload = false;
     $rep->outputFileName = 'qgis_server_legend';
     return $rep;
 }
コード例 #2
0
 /**
  * GetMap
  * @param string $repository Lizmap Repository
  * @param string $project Name of the project : mandatory
  * @return Image rendered by the Map Server.
  */
 function GetMap()
 {
     // Get parameters
     if (!$this->getServiceParameters()) {
         return $this->serviceException();
     }
     jClasses::inc('lizmap~lizmapWMSRequest');
     $wmsRequest = new lizmapWMSRequest($this->project, $this->params);
     $result = $wmsRequest->process();
     $rep = $this->getResponse('binary');
     $rep->mimeType = $result->mime;
     $rep->content = $result->data;
     $rep->doDownload = false;
     $rep->outputFileName = 'qgis_server_wms_map_' . $this->repository->getKey() . '_' . $this->project->getKey();
     $rep->setHttpStatus($result->code, '');
     if (!preg_match('/^image/', $result->mime)) {
         return $rep;
     }
     // HTTP browser cache expiration time
     $layername = $this->params["layers"];
     $lproj = lizmap::getProject($this->repository->getKey() . '~' . $this->project->getKey());
     $configLayers = $lproj->getLayers();
     if (property_exists($configLayers, $layername)) {
         $configLayer = $configLayers->{$layername};
         if (property_exists($configLayer, 'clientCacheExpiration')) {
             $clientCacheExpiration = (int) $configLayer->clientCacheExpiration;
             $rep->setExpires("+" . $clientCacheExpiration . " seconds");
         }
     }
     return $rep;
 }
コード例 #3
0
 function gettile()
 {
     //jLog::log('GetTile '.http_build_query($this->params));
     // Get the layer
     $LayerName = $this->param('Layer');
     if (!$LayerName) {
         // Error message
         jMessage::add('The parameter Layer is mandatory !', 'MissingParameter');
         return $this->serviceException();
     }
     $Format = $this->param('Format');
     if (!$Format) {
         // Error message
         jMessage::add('The parameter Format is mandatory !', 'MissingParameter');
         return $this->serviceException();
     }
     $TileMatrixSetId = $this->param('TileMatrixSet');
     if (!$TileMatrixSetId) {
         // Error message
         jMessage::add('The parameter TileMatrixSet is mandatory !', 'MissingParameter');
         return $this->serviceException();
     }
     $TileMatrixId = $this->param('TileMatrix');
     if ($TileMatrixId === null) {
         // Error message
         jMessage::add('The parameter TileMatrix is mandatory !', 'MissingParameter');
         return $this->serviceException();
     }
     $TileRow = $this->param('TileRow');
     if ($TileRow === null) {
         // Error message
         jMessage::add('The parameter TileRow is mandatory !', 'MissingParameter');
         return $this->serviceException();
     }
     $TileCol = $this->param('TileCol');
     if ($TileCol === null) {
         // Error message
         jMessage::add('The parameter TileCol is mandatory !', 'MissingParameter');
         return $this->serviceException();
     }
     $cacheId = $this->repository->getKey() . '_' . $this->project->getKey() . '_WMTS';
     $tileMatrixSetList = jCache::get($cacheId . '_tilematrixsetlist');
     if (!$tileMatrixSetList) {
         $this->getcapabilities();
         $tileMatrixSetList = jCache::get($cacheId . '_tilematrixsetlist');
     }
     $tileMatrixSet = null;
     foreach ($tileMatrixSetList as $tms) {
         if ($tms->ref == $TileMatrixSetId) {
             $tileMatrixSet = $tms;
             break;
         }
     }
     if ($tileMatrixSet === null) {
         // Error message
         jMessage::add('TileMatrixSet seems to be wrong', 'MissingParameter');
         return $this->serviceException();
     }
     $tileWidth = 256.0;
     $tileHeight = 256.0;
     $tileMatrix = $tileMatrixSet->tileMatrixList[(int) $TileMatrixId];
     $res = $tileMatrix->resolution;
     $minx = $tileMatrix->left + (int) $TileCol * ($tileWidth * $res);
     $miny = $tileMatrix->top - (int) $TileRow * ($tileHeight * $res);
     $maxx = $tileMatrix->left + ((int) $TileCol + 1) * ($tileWidth * $res);
     $maxy = $tileMatrix->top - ((int) $TileRow + 1) * ($tileHeight * $res);
     $params['service'] = 'WMS';
     $params['version'] = '1.3.0';
     $params['request'] = 'GetMap';
     $params['layers'] = $LayerName;
     $params['styles'] = '';
     $params['format'] = $Format;
     $params['crs'] = $TileMatrixSetId;
     $params['bbox'] = (string) round($minx, 6) . ',' . (string) round($miny, 6) . ',' . (string) round($maxx, 6) . ',' . (string) round($maxy, 6);
     $params['width'] = $tileWidth;
     $params['height'] = $tileHeight;
     $params['dpi'] = '96';
     if (preg_match('#png#', $Format)) {
         $params['transparent'] = 'true';
     }
     $wmsRequest = new lizmapWMSRequest($this->project, $params);
     $wmsRequest->setForceRequest($this->forceRequest);
     return $wmsRequest->process();
 }