"; if (!isset($mapName)) { die('mapname not set'); } if (isset($_SESSION['maps']) && isset($_SESSION['maps'][$mapName])) { $oMap = ms_newMapObj($_SESSION['maps'][$mapName]); } $bAllLayers = false; $nLayers = count($layers); if ($nLayers == 0) { $nLayers = $oMap->numlayers; $bAllLayers = true; } /*holds selection array*/ $properties = NULL; $properties->layers = array(); echo "/* nLayers: ".$nLayers." */"; for ($i=0; $i<$nLayers; $i++) { if (!$bAllLayers) { $oLayer = $oMap->GetLayerByName($layers[$i]); } else { $oLayer = $oMap->GetLayer($i); } $selectable = strtolower($oLayer->getMetaData('selectable')); if ( $selectable == 'true' ) { $oLayer->open(); $layerName = $oLayer->name != "" ? $oLayer->name : "Layer_".$i; echo "/* layername: ".$layerName." */"; array_push($properties->layers, $layerName); $properties->$layerName->propertynames = array(); $properties->$layerName->propertyvalues = array(); $properties->$layerName->propertytypes = array(); /*get first shape to get the attributes*/ //$oRes = $oLayer->getResult(0); //$oShape = $oLayer->getShape($oRes->tileindex,$oRes->shapeindex); $oShape = $oLayer->getFeature(0); if ($oShape) { while ( list($key,$val) = each($oShape->values) ) { array_push($properties->$layerName->propertynames, $key); //TODO : we should define away to give alias to field names array_push($properties->$layerName->propertyvalues, $key); //TODO we do not know the types of the attributes in MS. Just output 0 //we shouls possibly use OGR to get the attributes array_push($properties->$layerName->propertytypes, 0); } } $oLayer->close(); } /* if(isset($_SESSION['selection_array']->$layerName)){ if(isset($_SESSION['selection_array']->$layerName->values)){ $properties->$layerName->values = $_SESSION['selection_array']->$layerName->values; } } */ } /*save selection in the session*/ //$_SESSION['selection_array'] = $properties; echo var2json($properties); ?>