フィーチャ ソースを作成する

次の手順では、フィーチャ ソースを作成します。

『開発者用ガイド』のサンプルの digitizing_features フォルダにある draw_line.php を参照してください。

// Create a temporary feature source to draw the lines on
 
// Create a feature class definition for the new feature 
// source
$classDefinition = new MgClassDefinition();
$classDefinition->SetName("Lines");
$classDefinition->SetDescription("Lines to display.");
$geometryPropertyName="SHPGEOM";
$classDefinition->
    SetDefaultGeometryPropertyName( $geometryPropertyName); 
   
// Create an identify property
$identityProperty = new MgDataPropertyDefinition("KEY");
$identityProperty->SetDataType(MgPropertyType::Int32);
$identityProperty->SetAutoGeneration(true);
$identityProperty->SetReadOnly(true);   
// Add the identity property to the class definition
$classDefinition->GetIdentityProperties()->
    Add($identityProperty);
$classDefinition->GetProperties()->Add($identityProperty);
   
// Create a name property
$nameProperty = new MgDataPropertyDefinition("NAME");
$nameProperty->SetDataType(MgPropertyType::String); 
// Add the name property to the class definition
$classDefinition->GetProperties()->Add($nameProperty);
  
// Create a geometry property
$geometryProperty = new 
    MgGeometricPropertyDefinition($geometryPropertyName);   
$geometryProperty->
    SetGeometryTypes(MgFeatureGeometricType::Surface);  
// Add the geometry property to the class definition
$classDefinition->GetProperties()->Add($geometryProperty); 
  
// Create a feature schema
$featureSchema = new MgFeatureSchema("SHP_Schema", 
    "Line schema");
// Add the feature schema to the class definition
$featureSchema->GetClasses()->Add($classDefinition);             
  
// Create the feature source
$wkt = $map->GetMapSRS();
$sdfParams = new MgCreateSdfParams("spatial context", 
    $wkt, $featureSchema);  
$featureService->CreateFeatureSource($resourceIdentifier, 
    $sdfParams);