[mapguide-users] The feature set is empty

ehsan ehsan85 at yahoo.com
Wed Aug 3 02:42:49 EDT 2011


Hi,

i have problem regarding feature set, i need get property value from the
selectionXML on the taskpane. this is my code (i use PHP):

if ($xmlSelection != '')
		{
			$resourceService =
$siteConnection->CreateService(MgServiceType::ResourceService);
			$featureService =
$siteConnection->CreateService(MgServiceType::FeatureService);
			$queryOptions = new MgFeatureQueryOptions();

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

			$selection = new MgSelection($map, $xmlSelection);
			$layers = $selection->GetLayers();

			
			if ($layers)
			{
				#count layer
				for ($i = 0; $i < $layers->GetCount(); $i++)
				{

					$layer = $layers->GetItem($i);
					$selectlayer=$layer->GetName();

					//if selected layer same with layer in collection
					if ($layer && $layer->GetName() == $selectlayer)
					{
						// Create a filter containing the IDs of the selected features on this
layer

						$layerClassName = $layer->GetFeatureClassName();
						$selectionString = $selection->GenerateFilter($layer,
$layerClassName);

						// Get the feature resource for the selected layer

						$layerFeatureId = $layer->GetFeatureSourceId();
						$layerFeatureResource = new MgResourceIdentifier($layerFeatureId);
						$queryOptions->SetFilter($selectionString);//set the query filter.

						$featureReader =
$featureService->SelectFeatures($layerFeatureResource, $layerClassName,
$queryOptions);
						// Get all the property name and value of the selected layer.
						$featureReader->ReadNext();
						$totalProperty=$featureReader->GetPropertyCount();//get the property
count

						
							$bilVal = 0;
							for ($i=0;$i<$totalProperty;$i++)
							{
								$propName[$i]=$featureReader->GetPropertyName($i);//get the name of
the property
								$propType=$featureReader->GetPropertyType($propName[$i]);//get the
type of the property

								//Property name
								$name = $propName[$i];

								
								#Get value for No Lot & Mukim
								if(($name=="NO_LOT") ||($name=="KOD_MUKIM"))
								{
									switch($propType)
									{
										case MgPropertyType::Boolean:
											$prType[$bilVal]="MgBooleanProperty";
											$val[$bilVal] = $featureReader->GetBoolean($propName[$i])?
"true": "false";
											break;//MgBooleanProperty
										case MgPropertyType::Single:
											$prType[$bilVal]="MgSingleProperty";
											$val[$bilVal] = $featureReader->GetSingle($propName[$i]);
											break;//MgSingleProperty
										case MgPropertyType::Double:
											$prType[$bilVal]="MgDoubleProperty";
											$val[$bilVal] = $featureReader->GetDouble($propName[$i]);
											break;//MgDoubleProperty
										case MgPropertyType::Int16:
											$prType[$bilVal]="MgInt16Property";
											$val[$bilVal] = $featureReader->GetInt16($propName[$i]);
											break;//MgInt16Property
										case MgPropertyType::Int32:
											$prType[$bilVal]="MgInt32Property";
											$val[$bilVal] = $featureReader->GetInt32($propName[$i]);
											break;//MgInt32Property
										case MgPropertyType::Int64:
											$prType[$bilVal]="MgInt64Property";
											$val[$bilVal] = $featureReader->GetInt64($propName[$i]);
											break;//MgInt64Property
										case MgPropertyType::String:
											$prType[$bilVal]="MgStringProperty";
											$val[$bilVal] = $featureReader->GetString($propName[$i]);
											break;//MgStringProperty
										case MgPropertyType::DateTime:
											$prType[$bilVal]="MgDateTimeProperty";
											$val[$bilVal] =
$featureReader->GetDateTime($propName[$i])->ToString();
											break;//MgDateTimeProperty
									}
									$bilVal++;
								}
							}

							echo "*Selection Information*<hr></hr>";
							echo "<table><tr>".
							"<td>".$layer->GetLegendLabel()."</td>"
							."<tr><td>No Lot :".$val[0]."</td></tr>"
							."<tr><td>Kod Mukim :".$val[1]."</td></tr>"
							."</table>";						
												
					}
				}

			}
		}

The code work fine, but sometime it give error *The feature set is empty.*,
but properties pane show all the value for the selection.
Is there problem with my code or there is something missing..

Thanks,
ehsan.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/The-feature-set-is-empty-tp6647729p6647729.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list