[mapguide-users] Problem with MgSelection's GetSelectedFeatures

Tom Lazo / Stygy tom.lazo at hotmail.com
Thu Jul 23 10:30:30 EDT 2009


Muchas Gracias Mauricio. Tu ayuda me sirvio para unas ideas y ya logre mi
objetivo.

Thanks Mauricio. Your support gave me a few ideas and i've already achieved
my goal.

Tom.



Mauricio Villablanca wrote:
> 
> Instead of 
> $featureReader = $selection->GetSelectedFeatures($layer, $className,
> $boolS); 
> use this
> 
> $layerClassName = $layer->GetFeatureClassName();
> //create a filter collection
> $selectedFeaturesCount = $selection->GetSelectedFeaturesCount($layer,
> $layerClassName);
> $selectionStringCollection = $selection->GenerateFilters($layer,
> $layerClassName, $selectedFeaturesCount); //$selection->GenerateFilter
> does not always generate the right filter collection
> $string_count = $selectionStringCollection->GetCount();
> $stringsArray = Array();
> for ($g=0; $g < $string_count; $g++) {
> 	$string = $selectionStringCollection->GetItem($g);
> 	array_push($stringsArray, $string);
> }
> //the filter that matches the selected features
> $strings = join(", ", $stringsArray);
> 
> //use the filter collection to query the layer
> $queryOptions = new MgFeatureQueryOptions();
> $queryOptions->SetFilter($strings);
> $layerFeatureId = $layer->GetFeatureSourceId();
> $layerFeatureResource = new MgResourceIdentifier($layerFeatureId);
> 
> $featureReader = $featureService->SelectFeatures($layerFeatureResource,
> $layerClassName, $queryOptions);
> 
> 
> 
> Tom Lazo / Stygy wrote:
>> 
>> Hi, 
>> 
>> Well, srry about my last post, quiet stupid...dun worry..i erased it.
>> Ok, i'm using the MgSelection as it follows	
>> 
>>         include ("Common.php");
>>         include('../../common/php/Utilities.php');
>>         include('Utilities.php');
>> 	
>> 	$featureService =
>> $siteConnection->CreateService(MgServiceType::FeatureService);
>> 
>>         $map = new MgMap();
>>         $map->Open($resourceService, $mapName);
>> 	
>> 	$selection = new MgSelection($map);
>> 	$selection->Open($resourceService,$mapName);
>> 		
>> 	$layers = $map->GetLayers();
>> 	
>> 	$layer = $layers->GetItem("LOTES"); // Ya tengo mi MgLayerBase
>> 	$className = $layer->GetFeatureClassName();
>> 	
>> 	$layersS = $selection->GetLayers();
>> 	
>> 	$ind = $layersS->IndexOf($layer);
>> 	echo $ind . " \n ";
>> 	
>> 	$boolS = true;
>> 	
>> 	$featureCount = $selection->GetSelectedFeaturesCount($layer,$className); 
>> 	echo $featureCount . " \n ";
>> 
>> 	$featureReader =
>> $selection->GetSelectedFeatures($layer,$className,$boolS); 
>> 
>> I have no problem with the GetSelectedFeaturesCount ( it gives me the
>> correct number), my problem is the  GetSelectedFeatures function... my
>> app crashes when i uncomment it. Could somebody tell me why ?
>> 
>> Thanks.
>> 
>> Tom 
>> 
>> 
> 
> 


-----
http://n2.nabble.com/file/u222842/warning.png   Stygy is not a living being!
-- 
View this message in context: http://n2.nabble.com/Problem-with-MgSelection%27s-GetSelectedFeatures-tp3305494p3309917.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list