Пример #1
0
<?php

/**
    QGIS-WEB-CLIENT - PHP HELPERS

    Return a cached json legend for easier customization
    It uses GetStyles for the given layer to retrieve styles informations
    and GetLegendGraphics for each symbol image

    @copyright: 2013 by Alessandro Pasotti ItOpen (http://www.itopen.it)
        <*****@*****.**>
    @license: GNU AGPL, see COPYING for details.
*/
require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/helpers.php';
// Params
$mapname = @$_REQUEST['map'];
// Name of the layer to get legend for
$layername = @$_REQUEST['layer'];
$map = get_map_path($mapname);
// Get project
$project = get_project($map);
$legend = get_legend($mapname, $layername, $project);
$json_result = json_encode($legend);
header('Content-type: application/json');
header('Content-length: ' . strlen($json_result));
echo $json_result;
Пример #2
0
function get_map_html($img_url) {
	global $previous_sizes, $sizes;

	require_once('PEAR.php');
	pear::loadExtension('json');

	$json = exec('curl "'. $img_url .'&chof=json"');
	$map = json_decode($json)->chartshape;

	$map_html = "<map name=\"disk_usage_map\">\n";
	foreach ($map as $area) {
		if (count($previous_sizes) > 0) {
			list($path, $size) = array_kshift($previous_sizes);
		} else {
			list($path, $size) = array_kshift($sizes);
		}
		$href_dir = $path;
		if (strrpos($path, '/.../') == strlen($path)-5) {
			$href_dir = substr($path, 0, strlen($path)-5);
		} else if (strrpos($path, '/*') == strlen($path)-2) {
			$href_dir = substr($path, 0, strlen($path)-2);
		} else if (strrpos($path, '/') == strlen($path)-1) {
			$href_dir = substr($path, 0, strlen($path)-1);
		}
		if (strrpos($path, '/**') != strlen($path)-3 && $href_dir != 'Legend') {
			$map_html .= "  <area name=\"$area->name\" shape=\"$area->type\" coords=\"". implode(',', $area->coords) ."\" href=\"du.php?d=". urlencode($href_dir) ."\"  title=\"". htmlentities(get_legend($path, $size, TRUE), ENT_COMPAT, 'UTF-8') ."\">\n";
		}
	}
	$map_html .= "</map>\n";

	return $map_html;
}