[mapguide-users] selection generated by MgRenderingService::QueryFeatures() does not work properly?

mjirku martinjirku at gmail.com
Sat Aug 23 05:44:50 PDT 2014

I am using MgRenderingService::QueryFeatures(). But when:
- I use "A-code" to get layers from $map, I am able to run "C-code" part and
'echo $featureFilter . "<br/>";' outputs filters with features Id. Something
like this:

- If I use "A-code" but comment out the "C-code" and uncomment "D-code". the
server returns mgunclassifiedexception

- If I use "B-code" instead of "A-code", the server returns

Why I am not able to get FeatureReaders straight from MgSelection object?
What can be wrong? Why it throws those exceptions?

require_once __DIR__ . '/IGsSearcher.php';
require_once __DIR__ . '/GsServiceProvider.php';
require_once __DIR__ . '/MgHelper.php';

class GsSearcherMapStrategy implements IGsSearcher{
	public static $MAP = 'map';
	public static $GEOMETRY = 'geometry';

	private $map;
	private $geometry;
	private $session;

	public function __construct($params){
		$this->map = $params[self::$MAP];
		$this->geometry = $params[self::$GEOMETRY];
		$this->session = $this->map->GetSessionId();

	public function search(){
		$mgFeatureInformation = $this->getMgFeatureInformation();
		$resourceService =  GsServiceProvider::get($this->session,
		$mapName = $this->map->GetName();
		$mgSelection = $mgFeatureInformation->GetSelection();

		$layers = $this->map->GetLayers();
		//$layers = $mgSelection->GetLayers();

		$countLayers = $layers->GetCount();
		for ($i=0; $i < $countLayers; $i++) { 
			$layer = $layers->GetItem($i);
			$featureFilter = $mgSelection->GenerateFilter($layer,
			echo $featureFilter . "<br/>";
			//$featureReader = $mgSelection->GetSelectedFeatures($layer,
	private function getMgFeatureInformation(){
		$renderingSrv = GsServiceProvider::get($this->session,
		$mgStringCollection = new MgStringCollection();
		$layers = $this->map->GetLayers();
		$countLayers = $layers->GetCount();
		for ($i=0; $i < $countLayers; $i++) { 
		$selectionVariant = MgFeatureSpatialOperations::Intersects;
		$maxFeatures = -1;

		return $renderingSrv->QueryFeatures($this->map, $mgStringCollection,
$this->geometry, $selectionVariant, $maxFeatures);

View this message in context: http://osgeo-org.1560.x6.nabble.com/selection-generated-by-MgRenderingService-QueryFeatures-does-not-work-properly-tp5157992.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

More information about the mapguide-users mailing list