コード例 #1
0
ファイル: bufferfunctions.php プロジェクト: kanbang/Colt
function CreateParcelMarkerFeatureSource($featureService, $wkt, $parcelMarkerDataResId)
{
    $parcelClass = new MgClassDefinition();
    $parcelClass->SetName('ParcelMarkerClass');
    $properties = $parcelClass->GetProperties();
    $idProperty = new MgDataPropertyDefinition('ID');
    $idProperty->SetDataType(MgPropertyType::Int32);
    $idProperty->SetReadOnly(true);
    $idProperty->SetNullable(false);
    $idProperty->SetAutoGeneration(true);
    $properties->Add($idProperty);
    $pointProperty = new MgGeometricPropertyDefinition('ParcelLocation');
    $pointProperty->SetGeometryTypes(MgGeometryType::Point);
    $pointProperty->SetHasElevation(false);
    $pointProperty->SetHasMeasure(false);
    $pointProperty->SetReadOnly(false);
    $pointProperty->SetSpatialContextAssociation('defaultSrs');
    $properties->Add($pointProperty);
    $idProperties = $parcelClass->GetIdentityProperties();
    $idProperties->Add($idProperty);
    $parcelClass->SetDefaultGeometryPropertyName('ParcelLocation');
    $parcelSchema = new MgFeatureSchema('ParcelLayerSchema', 'temporary schema to hold parcel markers');
    $parcelSchema->GetClasses()->Add($parcelClass);
    $sdfParams = new MgCreateSdfParams('defaultSrs', $wkt, $parcelSchema);
    $featureService->CreateFeatureSource($parcelMarkerDataResId, $sdfParams);
}
コード例 #2
0
ファイル: findaddressfunctions.php プロジェクト: kanbang/Colt
function CreateAddressMarkerFeatureSource($featureService, $addressMarkerDataResId)
{
    $ll84Wkt = 'GEOGCS["WGS84 Lat/Long\'s, Degrees, -180 ==> +180",DATUM["D_WGS_1984",SPHEROID["World_Geodetic_System_of_1984",6378137,298.257222932867]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]';
    $addressClass = new MgClassDefinition();
    $addressClass->SetName('AddressMarker');
    $properties = $addressClass->GetProperties();
    $idProperty = new MgDataPropertyDefinition('ID');
    $idProperty->SetDataType(MgPropertyType::Int32);
    $idProperty->SetReadOnly(true);
    $idProperty->SetNullable(false);
    $idProperty->SetAutoGeneration(true);
    $properties->Add($idProperty);
    $addressProperty = new MgDataPropertyDefinition('Address');
    $addressProperty->SetDataType(MgPropertyType::String);
    $addressProperty->SetLength(512);
    $properties->Add($addressProperty);
    $locationProperty = new MgGeometricPropertyDefinition('Location');
    $locationProperty->SetGeometryTypes(MgGeometryType::Point);
    $locationProperty->SetHasElevation(false);
    $locationProperty->SetHasMeasure(false);
    $locationProperty->SetReadOnly(false);
    $locationProperty->SetSpatialContextAssociation('LL84');
    $properties->Add($locationProperty);
    $idProperties = $addressClass->GetIdentityProperties();
    $idProperties->Add($idProperty);
    $addressClass->SetDefaultGeometryPropertyName('Location');
    $addressSchema = new MgFeatureSchema();
    $addressSchema->SetName('AddressMarkerSchema');
    $addressSchema->GetClasses()->Add($addressClass);
    $sdfParams = new MgCreateSdfParams('LL84', $ll84Wkt, $addressSchema);
    $featureService->CreateFeatureSource($addressMarkerDataResId, $sdfParams);
}
コード例 #3
0
ファイル: markupschemafactory.php プロジェクト: kanbang/Colt
 static function CreateGeometryProperty($geomType)
 {
     $geometryProperty = new MgGeometricPropertyDefinition('Geometry');
     $geometryProperty->SetGeometryTypes($geomType);
     $geometryProperty->SetHasElevation(false);
     $geometryProperty->SetHasMeasure(false);
     $geometryProperty->SetReadOnly(false);
     $geometryProperty->SetSpatialContextAssociation('Default');
     return $geometryProperty;
 }
コード例 #4
0
ファイル: query.php プロジェクト: kanbang/Colt
 private function CreateFilterSchema()
 {
     $filterSchema = new MgFeatureSchema();
     $filterSchema->SetName('FilterSchema');
     $filterClass = new MgClassDefinition();
     $filterClass->SetName('Filter');
     $properties = $filterClass->GetProperties();
     $idProperty = new MgDataPropertyDefinition('ID');
     $idProperty->SetDataType(MgPropertyType::Int32);
     $idProperty->SetReadOnly(true);
     $idProperty->SetNullable(false);
     $idProperty->SetAutoGeneration(true);
     $properties->Add($idProperty);
     $geometryProperty = new MgGeometricPropertyDefinition('Geometry');
     $geometryProperty->SetGeometryTypes(MgFeatureGeometricType::Surface);
     $geometryProperty->SetHasElevation(false);
     $geometryProperty->SetHasMeasure(false);
     $geometryProperty->SetReadOnly(false);
     $geometryProperty->SetSpatialContextAssociation('MAPCS');
     $properties->Add($geometryProperty);
     $filterClass->GetIdentityProperties()->Add($idProperty);
     $filterClass->SetDefaultGeometryPropertyName('Geometry');
     $filterSchema->GetClasses()->Add($filterClass);
     return $filterSchema;
 }
コード例 #5
0
 public function CreateFeatureSource($resId, $inputFormat)
 {
     //Check for unsupported representations
     $fmt = $this->ValidateRepresentation($inputFormat, array("xml", "json"));
     $sessionId = "";
     if ($resId->GetRepositoryType() == MgRepositoryType::Session) {
         $sessionId = $resId->GetRepositoryName();
     }
     $mimeType = $this->GetMimeTypeForFormat($fmt);
     $this->EnsureAuthenticationForSite($sessionId, false, $mimeType);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     $site = $siteConn->GetSite();
     $this->VerifyWhitelist($resId->ToString(), $mimeType, "CREATEFEATURESOURCE", $fmt, $site, $this->userName);
     $this->EnsureAuthenticationForSite($sessionId);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     $featSvc = $siteConn->CreateService(MgServiceType::FeatureService);
     if ($fmt == "json") {
         $body = $this->app->request->getBody();
         $json = json_decode($body);
         if ($json == NULL) {
             throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
         }
     } else {
         $body = $this->app->request->getBody();
         $jsonStr = MgUtils::Xml2Json($body);
         $json = json_decode($jsonStr);
     }
     if (!isset($json->FeatureSourceParams)) {
         throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
     }
     $fsParams = $json->FeatureSourceParams;
     if (!isset($fsParams->File)) {
         throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
     }
     if (!isset($fsParams->SpatialContext)) {
         throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
     }
     if (!isset($fsParams->FeatureSchema)) {
         throw new Exception($this->app->localizer->getText("E_MALFORMED_JSON_BODY"));
     }
     $mkParams = new MgFileFeatureSourceParams();
     if (isset($fsParams->File->Provider)) {
         $mkParams->SetProviderName($fsParams->File->Provider);
     }
     if (isset($fsParams->File->FileName)) {
         $mkParams->SetFileName($fsParams->File->FileName);
     }
     if (isset($fsParams->SpatialContext->Name)) {
         $mkParams->SetSpatialContextName($fsParams->SpatialContext->Name);
     }
     if (isset($fsParams->SpatialContext->Description)) {
         $mkParams->SetSpatialContextDescription($fsParams->SpatialContext->Description);
     }
     if (isset($fsParams->SpatialContext->CoordinateSystem)) {
         $mkParams->SetCoordinateSystemWkt($fsParams->SpatialContext->CoordinateSystem);
     }
     if (isset($fsParams->SpatialContext->XYTolerance)) {
         $mkParams->SetXYTolerance($fsParams->SpatialContext->XYTolerance);
     }
     if (isset($fsParams->SpatialContext->ZTolerance)) {
         $mkParams->SetZTolerance($fsParams->SpatialContext->ZTolerance);
     }
     $mkSchema = $fsParams->FeatureSchema;
     $schema = new MgFeatureSchema();
     if (isset($mkSchema->Name)) {
         $schema->SetName($mkSchema->Name);
     }
     if (isset($mkSchema->Description)) {
         $schema->SetDescription($mkSchema->Description);
     }
     $classes = $schema->GetClasses();
     foreach ($mkSchema->ClassDefinition as $mkClass) {
         $cls = new MgClassDefinition();
         if (isset($mkClass->Name)) {
             $cls->SetName($mkClass->Name);
         }
         if (isset($mkClass->Description)) {
             $cls->SetDescription($mkClass->Description);
         }
         if (isset($mkClass->DefaultGeometryPropertyName)) {
             $cls->SetDefaultGeometryPropertyName($mkClass->DefaultGeometryPropertyName);
         }
         $clsProps = $cls->GetProperties();
         $idProps = $cls->GetIdentityProperties();
         foreach ($mkClass->PropertyDefinition as $propDef) {
             if (isset($propDef->PropertyType)) {
                 $mkProp = null;
                 switch ($propDef->PropertyType) {
                     case MgFeaturePropertyType::DataProperty:
                         $mkProp = new MgDataPropertyDefinition($propDef->Name);
                         if (isset($propDef->DataType)) {
                             $mkProp->SetDataType($propDef->DataType);
                         }
                         if (isset($propDef->Nullable)) {
                             $mkProp->SetNullable($propDef->Nullable);
                         }
                         if (isset($propDef->IsAutoGenerated)) {
                             $mkProp->SetAutoGeneration($propDef->IsAutoGenerated);
                         }
                         if (isset($propDef->DefaultValue)) {
                             $mkProp->SetDefaultValue($propDef->DefaultValue);
                         }
                         if (isset($propDef->Length)) {
                             $mkProp->SetLength($propDef->Length);
                         }
                         if (isset($propDef->Precision)) {
                             $mkProp->SetPrecision($propDef->Precision);
                         }
                         if (isset($propDef->Scale)) {
                             $mkProp->SetScale($propDef->Scale);
                         }
                         break;
                     case MgFeaturePropertyType::GeometricProperty:
                         $mkProp = new MgGeometricPropertyDefinition($propDef->Name);
                         if (isset($propDef->GeometryTypes)) {
                             $mkProp->SetGeometryTypes($propDef->GeometryTypes);
                         }
                         if (isset($propDef->HasElevation)) {
                             $mkProp->SetHasElevation($propDef->HasElevation);
                         }
                         if (isset($propDef->HasMeasure)) {
                             $mkProp->SetHasMeasure($propDef->HasMeasure);
                         }
                         if (isset($propDef->SpatialContextAssociation)) {
                             $mkProp->SetSpatialContextAssociation($propDef->SpatialContextAssociation);
                         }
                         break;
                     default:
                         throw new Exception($this->app->localizer->getText("E_UNSUPPORTED_PROPERTY_TYPE"));
                 }
                 if ($mkProp != null) {
                     if (isset($propDef->Description)) {
                         $mkProp->SetDescription($propDef->Description);
                     }
                     if (isset($propDef->ReadOnly)) {
                         $mkProp->SetReadOnly($propDef->ReadOnly);
                     }
                     $clsProps->Add($mkProp);
                     if (isset($propDef->IsIdentity) && $propDef->IsIdentity == true) {
                         $idProps->Add($mkProp);
                     }
                 }
             }
         }
         if (isset($mkClass->DefaultGeometryPropertyName)) {
             $cls->SetDefaultGeometryPropertyName($mkClass->DefaultGeometryPropertyName);
         }
         $classes->Add($cls);
     }
     $mkParams->SetFeatureSchema($schema);
     try {
         $featSvc->CreateFeatureSource($resId, $mkParams);
     } catch (MgException $ex) {
         $this->OnException($ex, $mimeType);
     }
 }