[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:
(FID=5023802)
(FID=11315)

- 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
mginvalidmapdefinitionexception

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

<?php
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,
MgServiceType::ResourceService);
		$mapName = $this->map->GetName();
		$mgSelection = $mgFeatureInformation->GetSelection();

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

		$countLayers = $layers->GetCount();
		for ($i=0; $i < $countLayers; $i++) { 
			$layer = $layers->GetItem($i);
			//C-code
			$featureFilter = $mgSelection->GenerateFilter($layer,
$layer->GetFeatureClassName());
			echo $featureFilter . "<br/>";
			//D-code
			//$featureReader = $mgSelection->GetSelectedFeatures($layer,
$layer->GetFeatureClassName(),false);
		}
	}
	
	private function getMgFeatureInformation(){
		$renderingSrv = GsServiceProvider::get($this->session,
MgServiceType::RenderingService);
		$mgStringCollection = new MgStringCollection();
		$layers = $this->map->GetLayers();
		$countLayers = $layers->GetCount();
		for ($i=0; $i < $countLayers; $i++) { 
			$mgStringCollection->Add($layers->GetItem($i)->GetName());
		}
		$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