Comment ajouter vos connaissances

Temporary Feature Sources

    Many geometric analysis operations require creating new features and new feature sources. For example, drawing a buffer around a point on a map requires a layer to display the buffer polygon, and the layer requires a feature source.

    To create a temporary feature source, perform the following steps:

    • Create a feature class definition.
    • Determine what properties you need to store for the features. Add the property definitions to the feature class definition.
    • Create a feature schema containing the feature class definition.
    • Determine the SRS for the feature source. This can be the same as the SRS used for the map.
    • Create a feature source using the schema and the SRS. The feature source can be stored in the session repository.

    It is possible for a single feature source to contain more than one feature class. A feature source that is to be used for temporary data, however, normally contains one feature class.

    A feature schema (MgFeatureSchema object) contains class definitions (MgClassDefinition objects) for each feature class in the schema.

    Each class definition contains property definitions for each property in the feature class. The property definitions can be the following types:

    • MgDataPropertyDefinition
    • MgGeometryPropertyDefinition
    • MgObjectPropertyDefinition
    • MgRasterPropertyDefinition

    MgDataPropertyDefinition is used to define simple properties like numbers or strings. MgGeometryPropertyDefinition is used to define geometric properties. Most feature classes will have a geometric property to describe the feature’s location.

    For example, the following creates a temporary feature source to hold buffer features. The feature source contains a single feature class named BufferClass.

    Features in BufferClass have two properties. ID is an autogenerated unique ID number, and BufferGeometry contains the geometry for the buffer polygon.

    The FDO technology supporting the Feature Service allows for multiple spatial reference systems within a single feature source. However, this capability is dependent on the data provider, and does not apply to the SDF provider that is used for creating feature sources within Infrastructure Map Server. For temporary feature sources, you must define a single default SRS for the feature source, and you must set any geometry properties to use the same SRS. The name of the SRS is user-defined.

    $bufferClass = new MgClassDefinition();
    $bufferClass->SetName('BufferClass');
    $properties = $bufferClass->GetProperties();
     
    $idProperty = new MgDataPropertyDefinition('ID');
    $idProperty->SetDataType(MgPropertyType::Int32);
    $idProperty->SetReadOnly(true);
    $idProperty->SetNullable(false);
    $idProperty->SetAutoGeneration(true);
    $properties->Add($idProperty);
     
    $polygonProperty = new 
       MgGeometricPropertyDefinition('BufferGeometry');
    $polygonProperty->
       SetGeometryTypes(MgFeatureGeometricType::Surface);
    $polygonProperty->SetHasElevation(false);
    $polygonProperty->SetHasMeasure(false);
    $polygonProperty->SetReadOnly(false);
    $polygonProperty->SetSpatialContextAssociation('defaultSrs');
    $properties->Add($polygonProperty);
     
    $idProperties = $bufferClass->GetIdentityProperties();
    $idProperties->Add($idProperty);
     
    $bufferClass->SetDefaultGeometryPropertyName('BufferGeometry');
     
    $bufferSchema = new MgFeatureSchema('BufferLayerSchema', 
       'temporary schema to hold a buffer');
    $bufferSchema->GetClasses()->Add($bufferClass);
     
    $sdfParams = new MgCreateSdfParams('defaultSrs', $wkt, 
       $bufferSchema);
     
    $featureService->CreateFeatureSource($bufferFeatureResId, 
       $sdfParams);
    

    To display features from a temporary feature source in a map, create a layer definition that refers to the feature source. Use the techniques described in Modifying Maps and Layers.