Hi,
For the SDF provider (versions 3.2.1 and later), it is possible to add a
property to an existing feature class, using ApplySchema. However, if
the class has features, the property must be nullable.
Brent.
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Traian
Stanev
Sent: Tuesday, September 18, 2007 4:02 PM
To: mapguide-users@lists.osgeo.org
Subject: RE: [mapguide-users] Create new column in data source
Hello,
In general, changing the definition of feature classes is done using an
ApplySchema command. However, I don't think the SHP and SDF providers
support modification of the feature class in the way that you want (i.e.
add a column). You would have to copy the original data into a new
feature source that also contains the new column in addition to all the
existing ones.
Traian
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jim O'Leary
Sent: Tuesday, September 18, 2007 2:20 PM
To: mapguide-users@lists.osgeo.org
Subject: Re: [mapguide-users] Create new column in data source
I am able to add the new property to the class definition like this:
$propertyCollection = new MgPropertyCollection();
$textProperty = new MgDataPropertyDefinition('AText');
$textProperty-SetDataType(MgPropertyType::String);
$textProperty-SetReadOnly(false);
$textProperty-SetLength(255);
$resId = new MgResourceIdentifier($layer-GetFeatureSourceId()); //
$layer
is already defined
$schemaClass = explode(':', $layer-GetFeatureClassName());
$classDefinition = $featureService-GetClassDefinition($resId,
$schemaClass[0], $schemaClass[1]);
$properties = $classDefinition-GetProperties();
$properties-Add($textProperty);
Looping through the properties shows that the property has been added:
$numberProperties = $properties-GetCount();
for($i=0;$i$numberProperties;$i++)
{
$propertyDef = $properties-GetItem($i);
print $propertyDef-GetName() . br;
}
However, the new property appears to be only in memory. Is there a way
to
permanently ALTER (to use an SQL term) the class with the new property?
Thanks
Jim O'Leary wrote:
I would like my user to be able to add a new column to a SHP / SDF
file at
run time. I have the code from the GT sample that shows how to create
a
new MgDataPropertyDefinition:
$textProperty = new MgDataPropertyDefinition('Text');
$textProperty-SetDataType(MgPropertyType::String);
$textProperty-SetReadOnly(false);
$textProperty-SetLength(255);
However, this code goes on to create a new class and then a new
feature
source. I already have those, but want only to add this new column.
Any
suggestions?
Thanks.
--
View this message in context:
http://www.nabble.com/Create-new-column-in-data-source-tf4471689s16610.h
tml#a12763007
Sent from the MapGuide Users mailing list archive at Nabble.com.
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
___
mapguide-users mailing list
mapguide-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users