[mapguide-users] Trying to add another class definition to a SDF
Jamo
adam.jamison at portbris.com.au
Thu May 21 02:26:32 EDT 2009
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-tp2950536p2950536.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list