Source for file MapFishPrintProxy.php
Documentation is available at MapFishPrintProxy.php
* Proxy of MapFishPrint type
* @copyright 2010, Centre de Geomatique du Quebec
* @license http://www.geoprisma.org/license BSD License
* @link http://www.geoprisma.org
* Proxy of MapFishPrint type
private $m_objArraySpec =
null;
private $m_objArraySpecLayers =
null;
* Get the action this proxy does.
* Forward the call end return the result
// get the print capabilities to have the 'createURL'
// get the params of the 'spec' with original 'source' values of the
curl_setopt($objCurl, CURLOPT_URL, $objCapabilities['createURL']);
curl_setopt($objCurl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
if ($objResult ==
null ||
!isset
($objResult->getURL))
$objResult =
$objResult->getURL;
if ( $_SERVER['REQUEST_METHOD'] ==
'POST' )
$_SESSION[$strID] =
array(
$_SESSION[$strID]['resources'],
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header('Content-Disposition: attachment; filename="map.pdf"');
// --------------------------
// --------------------------
* Not used by this proxy.
* Returns the spec layers array
return $this->m_objArraySpecLayers;
// --------------------------
// --------------------------
* Set the spec layers array property
* @param array $pobjArraySpecLayers The 'spec' layers array
private function setSpecLayers($pobjArraySpecLayers)
$this->m_objArraySpecLayers =
$pobjArraySpecLayers;
// --------------------------
// --------------------------
* Get the spec array converted from the $_REQUEST['spec'] parameter if
* request is GET or from 'php://input' if POST.
if (!$this->m_objArraySpec)
if ( $_SERVER['REQUEST_METHOD'] ==
'POST' )
$this->m_objArraySpec =
json_decode($strPostRequest, true);
if (!isset
($_REQUEST['spec']))
throw
new Exception("spec param is missing");
$this->m_objArraySpec =
json_decode($_REQUEST['spec'], true);
return $this->m_objArraySpec;
* Get the resources from the 'spec' object. At the same time, get all
* the requested 'layers' as well and the resources according 'services'
* that are going to be used to render the images to print.
* @param org_geoprisma_config_Config &$pobjConfig The config object.
* @return array of org_geoprisma_resource_Resource objects
$objArrayResources =
Array();
$objArraySpecLayers =
Array();
foreach ($objSpec['layers'] as $objLayer)
if (!isset
($objLayer['baseURL']) &&
$objLayer['type'] ==
"Vector")
if (!$pobjConfig->isProxyURL($objLayer['baseURL']))
if (!isset
($osmresource))
throw
new Exception("osmresource param is missing");
throw
new Exception("osmservice param is missing");
'osmresource' =>
$osmresource,
'osmservice' =>
$osmservice
// keep track of the renderer service to use for each resource
foreach ($objArraySubResources as $objSubResource)
$objSubResource->m_objRendererService
=
$pobjConfig->getService($osmservice);
// for each 'layers' of this layer, keep track of each mentioned
// resource for later validation
if (isset
($objLayer['layers']))
foreach ($objLayer['layers'] as $strLayer)
'resources' =>
$objArraySubResources
else if (isset
($objLayer['layer']))
'layer' =>
$objLayer['layer'],
'resources' =>
$objArraySubResources
throw
new Exception("The layer had no 'layer' or 'layers' properties defining which layer to print.");
$objArrayResources, $objArraySubResources
$this->setSpecLayers($objArraySpecLayers);
return $objArrayResources;
* Validate the resources from the request using the parent method of the
foreach ($objArrayResources as $objResource)
$objResource->m_objRendererService,
* Validate the layers from the request using the parent method of the
foreach ($objArraySpecLayers as $objSpecLayer)
// resources that are grouped together always share the same
// service so it is safe to get the first one since they are all
=
$objSpecLayer['resources'][0]->m_objRendererService;
$objSpecLayer['resources'],
Array($objSpecLayer['layer'])
* Get the 'spec' object with all 'baseURL' changed to point to the according
* service source url instead of the geoprisma proxy url.
for ($iIter=
0, $iLen=
count($objSpec['layers']); $iIter<
$iLen; $iIter++
)
$objLayer =
$objSpec['layers'][$iIter];
if (!isset
($objLayer['baseURL']) &&
$objLayer['type'] ==
"Vector")
if (!$objConfig->isProxyURL($objLayer['baseURL']))
$objSpec['layers'][$iIter]['baseURL']
=
$objConfig->getService($osmservice)->getSource();
Documentation generated on Thu, 19 Jan 2012 00:08:40 +0400 by phpDocumentor 1.4.1