Exemple #1
0
 function GetSelectionXML()
 {
     $json = new Services_JSON();
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     $featureService = $this->site->CreateService(MgServiceType::FeatureService);
     $map = new MgMap();
     $map->Open($resourceService, $this->args['MAPNAME']);
     $layer = $map->GetLayers()->GetItem($this->args['LAYERNAME']);
     $resId = new MgResourceIdentifier($layer->GetFeatureSourceId());
     $featureClass = $layer->GetFeatureClassName();
     $schemaAndClass = explode(":", $featureClass);
     $classDef = $featureService->GetClassDefinition($resId, $schemaAndClass[0], $schemaAndClass[1]);
     $properties = new MgPropertyCollection();
     $idList = $json->decode($this->args['IDLIST']);
     foreach ($idList as $key => $value) {
         switch ($classDef->GetProperties()->GetItem($key)->GetDataType()) {
             case MgPropertyType::Boolean:
                 $properties->Add(new MgBooleanProperty($key, $value));
                 break;
             case MgPropertyType::Byte:
                 $properties->Add(new MgByteProperty($key, $value));
                 break;
             case MgPropertyType::Single:
                 $properties->Add(new MgSingleProperty($key, $value));
                 break;
             case MgPropertyType::Double:
                 $properties->Add(new MgDoubleProperty($key, $value));
                 break;
             case MgPropertyType::Int16:
                 $properties->Add(new MgInt16Property($key, $value));
                 break;
             case MgPropertyType::Int32:
                 $properties->Add(new MgInt32Property($key, $value));
                 break;
             case MgPropertyType::Int64:
                 $properties->Add(new MgInt64Property($key, $value));
                 break;
             case MgPropertyType::String:
                 $properties->Add(new MgStringProperty($key, $value));
                 break;
             case MgPropertyType::DateTime:
                 $properties->Add(new MgDateTimeProperty($key, $value));
                 break;
             case MgPropertyType::Null:
             case MgPropertyType::Blob:
             case MgPropertyType::Clob:
             case MgPropertyType::Feature:
             case MgPropertyType::Geometry:
             case MgPropertyType::Raster:
                 break;
         }
     }
     $selection = new MgSelection($map);
     $selection->AddFeatureIds($layer, $featureClass, $properties);
     return $selection->ToXml();
 }
Exemple #2
0
    // Test basic methods
    $layerColl = $sel2->GetLayers();
    $newLayer = $layerColl->GetItem(0);
    echo "First layer selected is " . $newLayer->GetName() . "\n";
    echo "BadKey Filter: " . $sel2->GenerateFilter($slayer, "BadKey") . "\n";
    $filter = $sel2->GenerateFilter($slayer, "IntKey");
    echo "\nString Filter: " . $filter . "\n\n";
    $query = new MgFeatureQueryOptions();
    $query->AddFeatureProperty("KEY");
    $query->AddFeatureProperty("NAME");
    $query->SetFilter($filter);
    echo "Selected features\n";
    $reader = $fsvc->SelectFeatures($id, "IntKey", $query);
    while ($reader->ReadNext() == true) {
        echo $reader->GetString("NAME") . "\n";
    }
    echo "MgSelection from Reader\n";
    $reader = $fsvc->SelectFeatures($id, "IntKey", $query);
    $selection = new MgSelection($map);
    $layer1 = $map->GetLayers()->GetItem(0);
    $selection->AddFeatures($layer1, $reader, 0);
    echo $selection->ToXml();
    $envelope = $selection->GetExtents($fsvc);
    $ll = $envelope->GetLowerLeftCoordinate();
    $ur = $envelope->GetUpperRightCoordinate();
    echo "(" . $ll->GetX() . "," . $ll->GetY() . ") - (" . $ur->GetX() . "," . $ur->GetY() . ")\n";
} catch (MgException $exc) {
    echo $exc->GetExceptionMessage() . "\n";
    echo $exc->GetDetails() . "\n";
}
echo "Done.\n";
Exemple #3
0
    // 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("RNAME LIKE 'SCHMITT%'");
    $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('Parcels');
    $featureReader = $layer->SelectFeatures($queryOptions);
    $layer = $map->GetLayers()->GetItem('Parcels');
    $selection = new MgSelection($map);
    $selection->AddFeatures($layer, $featureReader, 0);
    $selectionXml = $selection->ToXml();
    echo 'Selecting parcels owned by Schmitt in District 1';
} catch (MgException $e) {
    echo $e->GetExceptionMessage();
    echo $e->GetDetails();
}
?>

  </body>

  <script language="javascript">

    <!-- Emit this function and assocate it with the onLoad event for the -->
    <!-- page so that it gets executed when this page loads in the        -->
    <!-- browser. The function calls the SetSelectionXML method on the    -->
    <!-- Viewer Frame, which updates the current selection on the viewer  -->
Exemple #4
0
                $layerClassName = $layer->GetFeatureClassName();
                $options = new MgFeatureQueryOptions();
                $options->SetFilter($resultSel->GenerateFilter($layer, $layerClassName));
                $resourceId = new MgResourceIdentifier($layer->GetFeatureSourceId());
                $featureReader = $featureSrvc->SelectFeatures($resourceId, $layerClassName, $options);
                $properties = BuildSelectionArray($featureReader, $layerName, $properties, false, NULL, false, $layer, true);
                $featureReader->Close();
                array_push($result->layers, $layerName);
                array_push($properties->layers, $layerName);
                $count = $resultSel->GetSelectedFeaturesCount($layer, $layerClassName);
                $result->$layerName->featureCount = $count;
              }

              /*save selection in the session*/
              $_SESSION['selection_array'] = $properties;
              echo str_replace("</FeatureSet>", "</FeatureSet></FeatureInformation>", str_replace("<FeatureSet", "<FeatureInformation><FeatureSet", $resultSel->ToXml()));
            } else { echo "<Message>layers false or 0</Message>"; }
          } else { echo "<Message>no resultsel</Message>"; }
        } else { echo "<Message>no fi</Message>"; }
      } else { echo "<Message>no multi geom</Message>"; }
    } else { echo "<Message>no layers</Message>"; }

    //return XML
    header("Content-type: text/xml");
  } catch(MgException $e) {
    echo "\nException: " . $e->GetDetails();
    return;
  } catch(Exception $ne) {
    return;
  }
Exemple #5
0
                            break;
                        case MgPropertyType::Double:
                            $idProps->Add(new MgDoubleProperty($id, $features->GetDouble($id)));
                            break;
                        case MgPropertyType::Single:
                            $idProps->Add(new MgSingleProperty($id, $features->GetSingle($id)));
                            break;
                        case MgPropertyType::DateTime:
                            $idProps->Add(new MgDateTimeProperty($id, $features->GetDateTime($id)));
                            break;
                        default:
                            throw new SearchError(FormatMessage("SEARCHTYYPENOTSUP", $locale, array($idPropType)), $searchError);
                    }
                }
                $sel->AddFeatureIds($layer, $featureClassName, $idProps);
                $selText = EscapeForHtml($sel->ToXml(), true);
                echo sprintf("<td class=\"%s\" id=\"%d:%d\" onmousemove=\"SelectRow(%d)\" onclick=\"CellClicked('%s')\">&nbsp;%s</td>\n", !($row % 2) ? "Search" : "Search2", $row, $i, $row, $selText, $val);
            }
            echo "</tr>";
            if (++$row == $matchLimit) {
                break;
            }
        } while ($features->ReadNext());
    } else {
        throw new SearchError(GetLocalizedString("SEARCHNOMATCHES", $locale), GetLocalizedString("SEARCHREPORT", $locale));
    }
} catch (MgException $ae) {
    if ($features) {
        // Close the feature reader
        $features->Close();
    }
 public function GetSelectionXml($sessionId, $mapName)
 {
     $this->EnsureAuthenticationForSite($sessionId);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
     $map = new MgMap($siteConn);
     $map->Open($mapName);
     $selection = new MgSelection($map);
     $selection->Open($resSvc, $mapName);
     $this->app->response->header("Content-Type", MgMimeType::Xml);
     $this->app->response->write($selection->ToXml());
 }