How to add your knowledge

Capabilities

    Table of contents
    1. 1. Use Cases
    2. 2. C#
      1. 2.1. Command
      2. 2.2. Connection
      3. 2.3. Expression
      4. 2.4. Filter
      5. 2.5. Geometry
      6. 2.6. Raster
      7. 2.7. Schema

    The following code samples are a representative listing of the capability methods in each category. For a complete listing consult the API reference documentation.

    The capabilities for a provider are statically defined. You create a connection object for the provider and use this object to query the capabilities. The connection does not have to be open.

    Some capabilities are defined as booleans, for example, support for the DISTINCT operator in a SQL SELECT statement. Sample code for this is shown in the Command section. Some capabilities are defined by arrays of enumerated type values, for example, the feature commands. The presence of the capability is determined by testing each value in the array for its equality with one of the values in the enumerated type range; sample code that tests for the presence of the create data store command is shown in the Command section.

    The schema capabilities include a string type that defines the characters that may not appear in a schema name and two integer types that define the maximum decimal precision and scale.

    Use Cases

    • Get the capabilities of a provider.
    • Write code that executes if the provider currently in use supports it.

    C#

    The following namespaces and types are used:

    • OSGeo.FDO.Commands for CommandType
    • OSGeo.FDO.Commands.Locking for LockType
    • OSGeo.FDO.Commands.SpatialContext for SpatialContextExtentType
    • OSGeo.FDO.Common for GeometryComponentType, GeometryType
    • OSGeo.FDO.Connections.Capabilities for ICommandCapabilties, IConnectionCapabilities, IExpressionCapabilities, IFilterCapabilities, IGeometryCapabilities, IRasterCapabilities, ISchemaCapabilities, FunctionDefinitionCollection, FunctionDefinition, ReadOnlySignatureDefinitionCollection, SignatureDefinition, ReadOnlyArgumentDefinitionCollection, ArgumentDefinition, ThreadCapability
    • OSGeo.FDO.Expression for ExpressionType
    • OSGeo.FDO.Filter for ConditionType, DistanceOperations, SpatialOperations
    • OSGeo.FDO.Schema for ClassType, DataType, PropertyType

    Command

     ICommandCapabilities cmdCapabilities = conn.CommandCapabilities;
     int[] commands = cmdCapabilities.Commands;
    Boolean supportsSelectDistinct = cmdCapabilities.SupportsSelectDistinct();
    CommandType cmdType = (CommandType)commands[0];
    Boolean supportsCreateDataStore = false;
     for (int i = 0; i < commands.GetLength(0); i++) {
    	if (commands[i] == (int)CommandType.CommandType_CreateDataStore)
    	supportsCreateDataStore = true; 
    

    Connection

    IConnectionCapabilities connCapabilities = conn.ConnectionCapabilities;
    LockType[] lockTypes = connCapabilities.LockTypes;
    SpatialContextExtentType[] spatialContextExtentTypes = connCapabilities.SpatialContextTypes;
    ThreadCapability threadCapability = connCapabilities.ThreadCapability;
    Boolean supportsConfiguration = connCapabilities.SupportsConfiguration();
    

    Expression

    IExpressionCapabilities exprCapabilities = connection.ExpressionCapabilities;
    ExpressionType[] expressionTypes = exprCapabilities.ExpressionTypes;
    FunctionDefinitionCollection functions = exprCapabilities.Functions;
    FunctionDefinition function = functions[0];
    ReadOnlySignatureDefinitionCollection signatureDefs = function.Signatures;
    SignatureDefinition signatureDef = signatureDefs[0];
    PropertyType returnPropertyType = signatureDef.ReturnPropertyType;
    if (returnPropertyType == PropertyType.PropertyType_DataProperty)
     {
     DataType returnDataType = signatureDef.ReturnType;
    }
    ReadOnlyArgumentDefinitionCollection arguments = signatureDef.Arguments;
    ArgumentDefinition argDef = arguments[0];
    PropertyType argPropertyType = argDef.PropertyType;
    if (argPropertyType == PropertyType.PropertyType_DataProperty)
    {
    DataType argDataType = argDef.DataType;
    }
    

    Filter

    IFilterCapabilities filterCapabilities = conn.FilterCapabilities;
    Boolean supportsGeodesicDistance = filterCapabilities.SupportsGeodesicDistance();
    ConditionType[] conditionTypes = filterCapabilities.ConditionTypes;
    DistanceOperations[] distanceOperations = filterCapabilities.DistanceOperations;
    SpatialOperations[] spatialOperations = filterCapabilities.SpatialOperations;
    

    Geometry

    IGeometryCapabilities geometryCapabilities = conn.GeometryCapabilities;
    GeometryType[] geometryTypes = geometryCapabilities.GeometryTypes;
    GeometryComponentType[] geometryComponentTypes = geometryCapabilities.GeometryComponentTypes;
     int dimensionalities = geometryCapabilities.Dimensionalities;
     Boolean HasZ = (dimensionalities & 1) == 1;
    Boolean HasM = (dimensionalities & 2) == 2;
    
    Note

    The dimensionalities integer contains bit-field definitions. XY is 0 because all spatial data has at least an X and Y coordinate. Z is 1 and M is 2. Use bitwise AND (&) to combine and bitwise OR (|) to separate.

    Raster

     IRasterCapabilities rasterCapabilities = conn.RasterCapabilities;
    Boolean supportsRaster = rasterCapabilities.SupportsRaster();
    

    Schema

    ISchemaCapabilities schemaCapabilities = conn.SchemaCapabilities;
    DataType[] dataTypes = schemaCapabilities.DataTypes;
    ClassType[] classTypes = schemaCapabilities.ClassTypes;
    string reservedCharactersForName = schemaCapabilities.ReservedCharactersForName;
    int maximumDecimalPrecision = schemaCapabilities.MaximumDecimalPrecision;
    DataType[] supportedAutoGeneratedTypes = schemaCapabilities.SupportedAutoGeneratedTypes;
    DataType[] supportedIdentityPropertyTypes = schemaCapabilities.SupportedIdentityPropertyTypes;
    Boolean supportsAutoIdGeneration = schemaCapabilities.SupportsAutoIdGeneration;