コード例 #1
0
ファイル: query.php プロジェクト: kanbang/Colt
 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();
 }
コード例 #2
0
ファイル: search.php プロジェクト: kanbang/Colt
                            $idProps->Add(new MgInt64Property($id, $features->GetInt64($id)));
                            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();