MapGuide API Reference
 All Classes Functions Variables Enumerations Enumerator Friends
Feature Schema

Modules

 MgPropertyDefinition
 MgClassDefinition
 MgDataPropertyDefinition
 MgGeometricPropertyDefinition
 MgGeometryTypeInfo
 MgObjectPropertyDefinition
 MgObjectPropertyType
 MgRasterPropertyDefinition

Detailed Description

A feature schema is a class or set of classes that define the structure of data contained in a feature source (datastore), for example, an Oracle database. A feature class consists of a set of properties. Each property has a set of attributes appropriate to the type of information it contains. Class and property here correspond roughly to table and column in a relational database.

The class and property definition classes have methods for both getting and setting attributes. In general, however, the set methods are of no use except in the case of the FDO Provider for SDF. MgFeatureService::CreateFeatureSource permits you to create an SDF schema, that is, an SDF file containing a schema. The intent is that this method be used as part of a mechanism for caching feature data locally. The schema used for this SDF cache file would typically be the schema extracted by MgFeatureService::DescribeSchema Method from the feature source whose features are being cached. It is possible to create a schema from scratch; see the sample code below.

Five property types are distinguished, and there is a property definition class for each type. The five types are:

Example (C#)
using OSGeo.MapGuide;
MgDataPropertyDefinition dataProperty;
MgGeometricPropertyDefinition geometricProperty;
MgClassDefinition classDef = new MgClassDefinition();

className = "SdfFeatureClass";

classDef.SetName(className);
classDef.SetDefaultGeometryPropertyName("theFeatureGeometry");

// feature geometry property that takes 2D XY geometries
geometricProperty = new MgGeometricPropertyDefinition("theFeatureGeometry");
geometricProperty.SetGeometryTypes(MgFeatureGeometricType.Point |
   MgFeatureGeometricType.Curve | MgFeatureGeometricType.Surface);
geometricProperty.SetHasElevation(false);
geometricProperty.SetHasMeasure(false);
geometricProperty.SetReadOnly(false);
geometricProperty.SetSpatialContextAssociation(spatialContextName);
classDef.GetProperties().Add(geometricProperty);

// non-feature geometry
geometricProperty = new MgGeometricPropertyDefinition("aNonFeatureGeometry");
geometricProperty.SetGeometryTypes(MgFeatureGeometricType.Point |
  MgFeatureGeometricType.Curve | MgFeatureGeometricType.Surface);
geometricProperty.SetHasElevation(false);
geometricProperty.SetHasMeasure(false);
geometricProperty.SetReadOnly(false);
geometricProperty.SetSpatialContextAssociation(spatialContextName);
classDef.GetProperties().Add(geometricProperty);

// identity property
dataProperty = new MgDataPropertyDefinition("FeatId");
dataProperty.SetDataType(MgPropertyType.Int32);
dataProperty.SetAutoGeneration(false);
dataProperty.SetNullable(false);
dataProperty.SetReadOnly(true);
classDef.GetIdentityProperties().Add(dataProperty);
classDef.GetProperties().Add(dataProperty);

// boolean property
dataProperty = new MgDataPropertyDefinition("aBoolean");
dataProperty.SetDataType(MgPropertyType.Boolean);
dataProperty.SetNullable(true);
dataProperty.SetReadOnly(false);
classDef.GetProperties().Add(dataProperty);

// byte property
dataProperty = new MgDataPropertyDefinition("aByte");
dataProperty.SetDataType(MgPropertyType.Byte);
dataProperty.SetNullable(true);
dataProperty.SetReadOnly(false);
classDef.GetProperties().Add(dataProperty);

// DataTime property
dataProperty = new MgDataPropertyDefinition("aDateTime");
dataProperty.SetDataType(MgPropertyType.DateTime);
dataProperty.SetNullable(true);
dataProperty.SetReadOnly(false);
classDef.GetProperties().Add(dataProperty);

// cannot create Decimal property because MgPropertyType.Decimal doesn't exist
// even though SDF schema capabilities says that Decimal property is supported

// double property
dataProperty = new MgDataPropertyDefinition("aDouble");
dataProperty.SetDataType(MgPropertyType.Double);
dataProperty.SetNullable(true);
dataProperty.SetReadOnly(false);
classDef.GetProperties().Add(dataProperty);

// Int16 property
dataProperty = new MgDataPropertyDefinition("anInt16");
dataProperty.SetDataType(MgPropertyType.Int16);
dataProperty.SetNullable(true);
dataProperty.SetReadOnly(false);
classDef.GetProperties().Add(dataProperty);

// Int32 property
dataProperty = new MgDataPropertyDefinition("anInt32");
dataProperty.SetDataType(MgPropertyType.Int32);
dataProperty.SetNullable(true);
dataProperty.SetReadOnly(false);
classDef.GetProperties().Add(dataProperty);

// Int64 property
dataProperty = new MgDataPropertyDefinition("anInt64");
dataProperty.SetDataType(MgPropertyType.Int64);
dataProperty.SetNullable(true);
dataProperty.SetReadOnly(false);
classDef.GetProperties().Add(dataProperty);

// Single property
dataProperty = new MgDataPropertyDefinition("aSingle");
dataProperty.SetDataType(MgPropertyType.Single);
dataProperty.SetNullable(true);
dataProperty.SetReadOnly(false);
classDef.GetProperties().Add(dataProperty);

// String property
dataProperty = new MgDataPropertyDefinition("aString");
dataProperty.SetDataType(MgPropertyType.String);
dataProperty.SetNullable(true);
dataProperty.SetReadOnly(false);
classDef.GetProperties().Add(dataProperty);

schema = new MgFeatureSchema();
schemaName = "SdfFeatureClassSchema";
schema.SetName(schemaName);
schema.GetClasses().Add(classDef);