[mapguide-users] setting filter

Ivan Milicevic Ivan.Milicevic at supranet.hr
Wed May 6 03:10:23 EDT 2009


Susan,

 

If your column ID is type of string put the filter value must be rounded
with qoute marks.

 

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of susan
Daniel
Sent: Wednesday, May 06, 2009 7:04 AM
To: MapGuide Users Mail List
Subject: [mapguide-users] setting filter

 

hi all.....

       Anyone plzz help me to set the filter.I am having  a feature
source with properties(pan_id,Name.,etc..).Now I wanna  select the
polygon  from the map  having pan_id=ID.
The ID will be entered from the task pane. Here is my code:

I copied it from dev guide..Then what is this this"SHPGEOM" in
setspatialfilter



<?php
    include '../common/common.php';

    $args = ($_SERVER['REQUEST_METHOD']=="GET")? $_GET: $_POST;
     
    $sessionId = $args['SESSION'];
    $mapName = $args['MAPNAME'];
    $ID= $_GET['PanId'];
     

    try
    {

      // Initialize the Web Extensions and connect to the Server using
      // the Web Extensions session identifier stored in PHP session
state.

      MgInitializeWebTier ($webconfigFilePath);

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

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

      // Get the geometry for the boundaries of District 

      $districtQuery = new MgFeatureQueryOptions();
      $districtQuery->SetFilter("pan_id=$ID");

      $layer = $map->GetLayers()->GetItem(0);
      $featureReader = $layer->SelectFeatures($districtQuery);
      $featureReader->ReadNext();
      $districtGeometryData = $featureReader->
      GetGeometry('Data');

      // Convert the AGF binary data to MgGeometry.

      $agfReaderWriter = new MgAgfReaderWriter();
      $districtGeometry = $agfReaderWriter->Read($districtGeometryData);

      // Create a filter to select the desired features. Combine
      // a basic filter and a spatial filter.

      $queryOptions = new MgFeatureQueryOptions();
      $queryOptions->SetFilter("pan_id=$ID"); 
      $queryOptions->SetSpatialFilter('SHPGEOM', $districtGeometry,
MgFeatureSpatialOperations::Inside);

      // Get the features from the feature source,
      // turn it into a selection, then save the selection as XML.

      $layer = $map->GetLayers()->GetItem(0);
      $featureReader = $layer->SelectFeatures($queryOptions);

      $layer = $map->GetLayers()->GetItem(0);       
      $selection = new MgSelection($map);
      $selection->AddFeatures($layer, $featureReader, 0);
      $selectionXml = $selection->ToXml();

       
    }
    catch (MgException $e)
    {
      echo $e->GetMessage();
      echo $e->GetDetails();
    }
    ?>

  </body>

  <script language="javascript">
 

    function OnPageLoad()
    {
      selectionXml = '<?php echo $selectionXml; ?>';
      parent.parent.SetSelectionXML(selectionXml);
    }

  </script>

</body>
</html>



-- 
thanks&regards
 susan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090506/d29be5a3/attachment.html


More information about the mapguide-users mailing list