[mapguide-users] Re: Retrieve fields names and attributes from Postgres table

ar_gaeta ar_gaeta at yahoo.it
Tue May 31 05:47:40 EDT 2011


Thanks Jackie for your help, I've advanced a lot, but I'm still in trouble.
I'm able to get the name of the field/column, but I'm not able to get the
property.
This is my new code:

MgLayer layer = (MgLayer)map.GetLayers().GetItem(layername);
MgClassDefinition ClassDef = layer.GetClassDefinition();
	
String desc = ClassDef.GetDescription();
String name = ClassDef.GetName(); //I get the layername back
String geom = ClassDef.GetDefaultGeometryPropertyName(); //get the name of
the geometric field

MgPropertyDefinitionCollection PropDefColl = new
MgPropertyDefinitionCollection();
PropDefColl = ClassDef.GetProperties();
int count = PropDefColl.GetCount(); //OK! Counts the fields of my postgres
table
	
MgPropertyDefinition PropDef = PropDefColl.GetItem(4); //I take the 5th
field from my table
String desc2 = PropDef.GetDescription();
String name2 = PropDef.GetQualifiedName(); //name of the field:
schema.table.field
short type = PropDef.GetPropertyType();	//a number for MgFeaturePropertyType
String name3 = PropDef.GetName(); //simple name of the field
	
//'Decoding MgFeaturePropertyType:
//AssociationProperty = 103
//DataProperty = 100
//GeometricProperty = 102
//ObjectProperty = 101
//RasterProperty = 104
	
//'Now I try to retrieve the type of the field: string, int, double, etc...
MgDataPropertyDefinition DataProp = new MgDataPropertyDefinition(name2);
//"name2" is the name of the property from I want retrieve information, and
must be a string: it is correct??
int type2 = DataProp.GetDataType(); //a number for MgPropertyType
	
//'Decoding MgPropertyType (the more important):
//string = 9
//int16 = 6
//double = 5
//int32 = 7
//geometry = 13	
	

But this doesn't work. I think the problem is in the definition of the
MgDataPropertyDefinition, but I don't know how to solve it...
	
Thanks again!

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Retrieve-fields-names-and-attributes-from-Postgres-table-tp6418612p6422045.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list