layers = array(); if (isset($_SESSION['selection_array'])) { $bAllLayers = 1; $aLayers = array(); if (isset($_REQUEST['layers']) && $_REQUEST['layers'] !='') { $aLayers = split(",", $_REQUEST['layers']); $bAllLayers = 0; } $aStartCount = array(); if (isset($_REQUEST['startcount']) && $_REQUEST['startcount'] !='') { $aStartCount = split(",", $_REQUEST['startcount']); } /* if number of layers and number of startcount should be the same */ if ( count($aStartCount) > 0 && (count($aLayers) != count($aStartCount))) { echo "error : number of layers and number of startcount should be the same"; exit; } $properties = $_SESSION['selection_array']; $aSelectedLayers = $properties->layers; if (count($aSelectedLayers) > 0) { $result->extents = NULL; $result->extents->minx = $properties->extents->minx; $result->extents->miny = $properties->extents->miny; $result->extents->maxx = $properties->extents->maxx; $result->extents->maxy = $properties->extents->maxy; for ($i=0; $i$layerName) && $properties->$layerName->numelements > 0) { array_push($result->layers, $layerName); $result->$layerName->propertynames = $properties->$layerName->propertynames; $result->$layerName->propertyvalues = $properties->$layerName->propertyvalues; $result->$layerName->propertytypes = $properties->$layerName->propertytypes; $result->$layerName->metadatanames = $properties->$layerName->metadatanames; /*if start and count are given, validate them. If valid return the valid elements. if not return all elements. */ $start = -1; $count = -1; if (count($aStartCount) > 0) { for ($j=0; $j= $properties->$layerName->numelements || $count > $properties->$layerName->numelements || ($start + $count) > $properties->$layerName->numelements) { $start = -1; $count = -1; } } /* if invalid return all elements*/ if ($start < 0 || $count < 0) { $start =0; $count = $properties->$layerName->numelements; } //print_r($properties->$layerName); $result->$layerName->numelements = $count; $result->$layerName->values = array(); $result->$layerName->metadata = array(); $iIndice = 0; for ($j=$start; $j<($start+$count); $j++) { $result->$layerName->values[$iIndice] = $properties->$layerName->values[$j]; $result->$layerName->metadata[$iIndice] = $properties->$layerName->metadata[$j]; $iIndice++; } } } } } header('Content-type: text/x-json'); header('X-JSON: true'); echo var2json($result); ?>