[mapguide-users] Create new column in data source
Traian Stanev
traian.stanev at autodesk.com
Tue Sep 18 16:01:38 EDT 2007
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: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Jim O'Leary
Sent: Tuesday, September 18, 2007 2:20 PM
To: mapguide-users at 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 at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
More information about the mapguide-users
mailing list