コード例 #1
0
ファイル: markupeditor.php プロジェクト: kanbang/Colt
 function GetSelectionXML()
 {
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     $map = new MgMap();
     $map->Open($resourceService, $this->args['MAPNAME']);
     $markupLayer = $map->GetLayers()->GetItem('_' . $this->GetMarkupName());
     $selection = new MgSelection($map);
     $className = $markupLayer->GetFeatureClassName();
     $ids = $this->args['MARKUPFEATURE'];
     if (is_array($ids)) {
         foreach ($ids as $id) {
             $selection->AddFeatureIdInt32($markupLayer, $className, (int) $id);
         }
     } else {
         $selection->AddFeatureIdInt32($markupLayer, $className, (int) $ids);
     }
     return $selection->ToXML();
 }
コード例 #2
0
ファイル: testAwSelection.php プロジェクト: kanbang/Colt
 // We need to add some data to the sdf before using it.  The spatial context
 // reader must have an extent.
 $cmdColl = new MgFeatureCommandCollection();
 for ($i = 1; $i <= 20; $i++) {
     $insert = $intFeature->InsertCommand($i);
     $cmdColl->Add($insert);
 }
 echo "Updating features\n";
 $fsvc->UpdateFeatures($id, $cmdColl, false);
 $mapId = new MgResourceIdentifier("Library://TrevorWekel/NewSdf.MapDefinition");
 $map = new MgMap();
 $map->Create($rsvc, $mapId, "NewMap");
 echo "Building Selection from Add()\n";
 $sel = new MgSelection($map);
 $slayer = $map->GetLayers()->GetItem(0);
 $sel->AddFeatureIdInt32($slayer, "IntKey", 1);
 $sel->AddFeatureIdInt32($slayer, "IntKey", 10);
 $sel->AddFeatureIdInt32($slayer, "IntKey", 20);
 echo "XML FeatureSet is\n" . $sel->ToXml() . "\n";
 echo "\nString Filter: " . $sel->GenerateFilter($slayer, "StringKey") . "\n\n";
 echo "Building Selection from XML\n";
 $sel2 = new MgSelection($map, $sel->ToXml());
 // 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");
コード例 #3
0
 private function TranslateToSelectionXml($siteConn, $mapName, $featFilter, $bAppend)
 {
     $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
     $map = new MgMap($siteConn);
     $map->Open($mapName);
     $sel = new MgSelection($map);
     $layers = $map->GetLayers();
     //If appending, load the current selection first
     if ($bAppend) {
         $sel->Open($resSvc, $mapName);
     }
     $doc = new DOMDocument();
     $doc->loadXML($featFilter);
     /*
             Document structure
             
             /SelectionUpdate
        /Layer
            /Name
            /Feature [0...n]
                /ID
                    /Name
                    /Value
            /SelectionFilter [0...n]
     */
     $root = $doc->documentElement;
     if ($root->tagName != "SelectionUpdate") {
         $this->BadRequest($this->app->localizer->getText("E_INVALID_DOCUMENT"), MgMimeType::Xml);
     }
     $layerNodes = $root->childNodes;
     for ($i = 0; $i < $layerNodes->length; $i++) {
         $layerNode = $layerNodes->item($i);
         if ($layerNode->tagName == "Layer") {
             //$this->app->log->debug("Found //SelectionUpdate/Layer");
             $featureNodes = $layerNode->childNodes;
             for ($j = 0; $j < $featureNodes->length; $j++) {
                 $featureNode = $featureNodes->item($j);
                 if ($featureNode->tagName == "Name") {
                     //$this->app->log->debug("Found //SelectionUpdate/Layer/Name");
                     $layerName = $featureNode->nodeValue;
                     $lidx = $layers->IndexOf($layerName);
                     if ($lidx < 0) {
                         $this->BadRequest($this->app->localizer->getText("E_LAYER_NOT_FOUND_IN_MAP", $layerName), MgMimeType::Xml);
                     }
                     $layer = $layers->GetItem($lidx);
                     $clsDef = $layer->GetClassDefinition();
                     $clsIdProps = $clsDef->GetIdentityProperties();
                 } else {
                     if ($featureNode->tagName == "SelectionFilter") {
                         $query = new MgFeatureQueryOptions();
                         $query->SetFilter($featureNode->nodeValue);
                         $fr = $layer->SelectFeatures($query);
                         $sel->AddFeatures($layer, $fr, 0);
                     } else {
                         if ($featureNode->tagName == "Feature") {
                             //$this->app->log->debug("Found //SelectionUpdate/Layer/Feature");
                             $idNodes = $featureNode->childNodes;
                             if ($idNodes->length == 1) {
                                 $idNode = $idNodes->item(0);
                                 if ($idNode->tagName == "ID") {
                                     //$this->app->log->debug("Found //SelectionUpdate/Layer/Feature/ID");
                                     $nameNode = null;
                                     $valueNode = null;
                                     for ($nv = 0; $nv < $idNode->childNodes->length; $nv++) {
                                         $children = $idNode->childNodes;
                                         $child = $children->item($nv);
                                         if ($child->tagName == "Name") {
                                             //$this->app->log->debug("Found //SelectionUpdate/Layer/Feature/ID/Name");
                                             $nameNode = $child;
                                         } else {
                                             if ($child->tagName == "Value") {
                                                 //$this->app->log->debug("Found //SelectionUpdate/Layer/Feature/ID/Value");
                                                 $valueNode = $child;
                                             }
                                         }
                                     }
                                     //Name/Value nodes must be specified
                                     if ($nameNode == null || $valueNode == null) {
                                         $this->BadRequest($this->app->localizer->getText("E_INVALID_DOCUMENT"), MgMimeType::Xml);
                                     }
                                     //Property must exist
                                     $pidx = $clsIdProps->IndexOf($nameNode->nodeValue);
                                     if ($pidx < 0) {
                                         $this->BadRequest($this->app->localizer->getText("E_PROPERTY_NOT_FOUND_IN_CLASS", $nameNode->nodeValue, $clsDef->GetName()), MgMimeType::Xml);
                                     }
                                     $propDef = $clsIdProps->GetItem($pidx);
                                     $value = $valueNode->nodeValue;
                                     $propType = $propDef->GetDataType();
                                     //$this->app->log->debug("Value is: $value");
                                     //$this->app->log->debug("Property type: $propType");
                                     switch ($propType) {
                                         case MgPropertyType::Int16:
                                             //$this->app->log->debug("=== ADD INT16: $value ===");
                                             $sel->AddFeatureIdInt16($layer, $layer->GetFeatureClassName(), intval($value));
                                             break;
                                         case MgPropertyType::Int32:
                                             //$this->app->log->debug("=== ADD INT32: $value ===");
                                             $sel->AddFeatureIdInt32($layer, $layer->GetFeatureClassName(), intval($value));
                                             break;
                                         case MgPropertyType::Int64:
                                             //$this->app->log->debug("=== ADD INT64: $value ===");
                                             $sel->AddFeatureIdInt64($layer, $layer->GetFeatureClassName(), intval($value));
                                             break;
                                         case MgPropertyType::String:
                                             //$this->app->log->debug("=== ADD STRING: $value ===");
                                             $sel->AddFeatureIdString($layer, $layer->GetFeatureClassName(), $value);
                                             break;
                                         case MgPropertyType::Single:
                                         case MgPropertyType::Double:
                                             //$this->app->log->debug("=== ADD DOUBLE: $value ===");
                                             $sel->AddFeatureIdInt64($layer, $layer->GetFeatureClassName(), floatval($value));
                                             break;
                                             //case MgPropertyType::DateTime:
                                             //    break;
                                     }
                                 }
                             } else {
                                 if ($idNodes->length > 1) {
                                     throw new Exception($this->app->localizer->getText("E_MULTIPLE_IDENTITY_PROPS_NOT_SUPPORTED"));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $sel->ToXml();
 }
コード例 #4
0
ファイル: markupeditor.php プロジェクト: kanbang/Colt
 function GetSelectionXML()
 {
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     $map = new MgMap();
     $map->Open($resourceService, $this->args['MAPNAME']);
     $markupLayer = $map->GetLayers()->GetItem('_' . $this->GetMarkupName());
     $selection = new MgSelection($map);
     $selection->AddFeatureIdInt32($markupLayer, $markupLayer->GetFeatureClassName(), (int) $this->args['MARKUPFEATURE']);
     return $selection->ToXML();
 }
コード例 #5
0
ファイル: Search.php プロジェクト: alonso/fusion
         case MgPropertyType::String:
             $val = $features->GetString($propName);
             break;
     }
     // Generate XML to selection this feature
     //
     $sel = new MgSelection($map);
     if ($multiIds) {
         throw new SearchError(GetLocalizedString("SEARCHNOMULTIPROP", $locale), $searchError);
     } else {
         if ($i == 0) {
             $idPropType = $features->GetPropertyType($idPropName);
         }
         switch ($idPropType) {
             case MgPropertyType::Int32:
                 $sel->AddFeatureIdInt32($layer, $featureClassName, $features->GetInt32($idPropName));
                 break;
             case MgPropertyType::String:
                 $sel->AddFeatureIdString($layer, $featureClassName, $features->GetString($idPropName));
                 break;
             default:
                 throw new SearchError(FormatMessage("SEARCHTYYPENOTSUP", $locale, array($idPropType)), $searchError);
         }
     }
     $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;
 }