[mapguide-users] Trying to add another class definition to a SDF

Jackie Ng jumpinjackie at gmail.com
Thu May 21 03:25:14 EDT 2009


MapGuide does not expose FDO's IApplySchema command. You will have to use the
FDO API directly if you want to modify existing schemas.

- Jackie


Jamo wrote:
> 
> I've been trying this code to add another class definition to a SDF, it
> only adds a new classDefinition when the users SDF already exists.... is
> this possible, everything seems to run through fine .... but no new
> class..
> 
>       if (ResourceService.ResourceExists(dataSourceId) == false)
>       {
> 
>         //create Feature Source
>         MgClassDefinition myClassDef = new MgClassDefinition();
>         myClassDef.SetName(layerName);
>         myClassDef.SetDescription(layerDesc);
> 
>         //TODO : make SHPGEOM a Variable...
>         myClassDef.SetDefaultGeometryPropertyName("GEOM");
> 
>         //Set KEY Property
>         MgDataPropertyDefinition prop = new
> MgDataPropertyDefinition("FeatId");
>         prop.SetDataType(MgPropertyType.Int32);
>         prop.SetAutoGeneration(true);
>         prop.SetReadOnly(true);
>         myClassDef.GetIdentityProperties().Add(prop);
>         myClassDef.GetProperties().Add(prop);
> 
>         //Set geometry property
>         MgGeometricPropertyDefinition geomProp = new
> MgGeometricPropertyDefinition("GEOM");
>         geomProp.SetGeometryTypes(MgFeatureGeometricType.Curve);
>         myClassDef.GetProperties().Add(geomProp);
> 
>         //Create the schema
>         MgFeatureSchema schema = new MgFeatureSchema("Default", "Default
> Feature Schema");
>         schema.GetClasses().Add(myClassDef);
> 
>         MgCreateSdfParams sdfParams = new MgCreateSdfParams("MGA-56 (GDA94
> / MGA zone 56)", map.GetMapSRS(), schema);
>         FeatureService.CreateFeatureSource(dataSourceId, sdfParams);
> 
>       }
>       else
>       {
>         //create Feature Source
>         MgClassDefinition myClassDef = new MgClassDefinition();
>         myClassDef.SetName(layerName);
>         myClassDef.SetDescription(layerDesc);
> 
>         //TODO : make SHPGEOM a Variable...
>         myClassDef.SetDefaultGeometryPropertyName("GEOM");
> 
>         //Set KEY Property
>         MgDataPropertyDefinition prop = new
> MgDataPropertyDefinition("FeatId");
>         prop.SetDataType(MgPropertyType.Int32);
>         prop.SetAutoGeneration(true);
>         prop.SetReadOnly(true);
>         myClassDef.GetIdentityProperties().Add(prop);
>         myClassDef.GetProperties().Add(prop);
> 
>         //Set geometry property
>         MgGeometricPropertyDefinition geomProp = new
> MgGeometricPropertyDefinition("GEOM");
>         geomProp.SetGeometryTypes(MgFeatureGeometricType.Curve);
>         myClassDef.GetProperties().Add(geomProp);
> 
>         FeatureService.DescribeSchema(dataSourceId,
> "Default")[0].GetClasses().Add(myClassDef);
>       }
> 
> 

-- 
View this message in context: http://n2.nabble.com/Trying-to-add-another-class-definition-to-a-SDF-tp2950536p2950667.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list