[mapguide-users] Mix of selectfeature and selectaggregate query

Jo Cook j.cook at oxfordarch.co.uk
Fri Dec 18 07:24:22 EST 2009


Hi Dave,

Thanks for that- I've tried to implement it as a single selectaggregate
query, but I'm still missing something. I suspect (though I don't really
understand what I'm doing) that it's falling over at the dataReader section.
If you (or someone could have a look at my code I'd really appreciate it.
The relevant code is as follows:

MgInitializeWebTier ($webconfigFilePath);

               $userInfo = new MgUserInformation($sessionId);
               $siteConnection = new MgSiteConnection();
               $siteConnection->Open($userInfo);

               $map = new MgMap($siteConnection);
               $map->Open($mapName);

               $filter = "POSTCODE LIKE '$SMAlocation%'";
               //echo $filter;

               $queryOptions = new MgFeatureAggregateOptions();
               $queryOptions->SelectDistinct(true);
               $queryOptions->AddFeatureProperty("Postcodegroup");
               $queryOptions->SetFilter($filter);


               $layers = $map->GetLayers();
               $selLayer = $layers->GetItem($SMAlayer);


               $featureresourceID = new MgResourceIdentifier($selLayer->
GetFeatureSourceID());
               $featureclassname = $selLayer->GetFeatureClassName();
               $featureService = new MgFeatureService;
               $dataReader =
$featureService->SelectAggregate($featureresourceID, $featureclassname,
$queryOptions);
               print_r($dataReader);
               $dataReader.close();

               echo "<p>Postcodes matching your criteria:</p>";

               while ($dataReader->ReadNext()) {

               $postcode = $dataReader->GetString('Postcode');
               echo $postcode."<br />";
               }
               echo"</p>";

               }

Thanks

Jo

Dave Wilson wrote:
> 
> There is a filter on SelectAggregates just like SelectFeatures. You should
> be able to add a PostalCode LIKE clause using this if I am not mistaken.
> 
> Dave
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Mix-of-selectfeature-and-selectaggregate-query-tp4176453p4186257.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list