[fdo-users] inserting data into a SDF file
Dan Stoica
dan.stoica at autodesk.com
Fri Feb 20 08:20:31 EST 2009
HI Vinay,
Regarding creating spatial contexts and in general when you need a working example: have a look into the SDF unit tests.
Regards,
Dan.
-----Original Message-----
From: fdo-users-bounces at lists.osgeo.org [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of vinay
Sent: Thursday, February 19, 2009 10:35 PM
To: fdo-users at lists.osgeo.org
Subject: Re: [fdo-users] inserting data into a SDF file
Hi Jackie,
Thanks for the tip. It worked. Also thanks for making fdotoolkit app open
source. It is very helpful for me to learn and understand different things
related to FDO seeing your source code.
I am having very hard time to understand spatialcontext concepts. When
creating the datastore for the sdf file i am want to create a default
spatialcontext but i am having difficulty in creating a default wkt
coordinate system. Do you have any suggestions.
Thanks in advance.
regards
Vinay
Jackie Ng wrote:
>
> If you look at the property value collection of the insert command in the
> debugger, you will see the count will increase in increments of 4.
>
> As a result, the insert command will use the same first 4 property values
> for every insert operation.
>
> To fix this, clear the property value collection of the insert command
> before setting the property values.
>
> Hope that helps.
>
> - Jackie
>
>
> vinay wrote:
>>
>> Hi All,
>>
>> I am using the FDO dlls from the MAP ObjectArx SDK 2009 in Visual studio
>> 2008. I am writing a small app to understand FDO API. I am able to create
>> a sdf file, describe schema for the sdf file, create feature class, etc.
>> I created four datapropertydefinitions in which one is an
>> identityProperty. I am inserting values into my properties in a for-loop.
>> When I open this sdf file in map 2009, all columns have the same values
>> except the auto generated property column as shown below.
>>
>> Please take a look in case I am missing something simple here.
>>
>> http://n2.nabble.com/file/n2349739/data.png
>>
>> Source code snippets for the sample app is below
>>
>> OSGeo.FDO.Schema.FeatureSchema Schema = new
>> OSGeo.FDO.Schema.FeatureSchema("SchemaOne", "Sample Schema");
>> OSGeo.FDO.Schema.FeatureClass ClassOne = new
>> OSGeo.FDO.Schema.FeatureClass("Class one", "Class one for Schema One");
>>
>>
>> OSGeo.FDO.Schema.DataPropertyDefinition DataProp1
>> = new OSGeo.FDO.Schema.DataPropertyDefinition("Prop1", "Property one");
>> OSGeo.FDO.Schema.DataPropertyDefinition DataProp2
>> = new OSGeo.FDO.Schema.DataPropertyDefinition("Prop2", "Property two");
>> OSGeo.FDO.Schema.DataPropertyDefinition DataProp3
>> = new OSGeo.FDO.Schema.DataPropertyDefinition("Prop3", "Property three");
>> OSGeo.FDO.Schema.DataPropertyDefinition DataProp4
>> = new OSGeo.FDO.Schema.DataPropertyDefinition("Prop4", "Property four");
>> DataProp1.DataType =
>> OSGeo.FDO.Schema.DataType.DataType_Int32;
>> DataProp1.IsAutoGenerated = true;
>> DataProp1.Nullable = false;
>>
>> DataProp2.DataType =
>> OSGeo.FDO.Schema.DataType.DataType_Decimal;
>> DataProp2.IsAutoGenerated = false;
>> DataProp2.Nullable = false;
>> DataProp2.ReadOnly = false;
>>
>> DataProp3.DataType =
>> OSGeo.FDO.Schema.DataType.DataType_Decimal;
>> DataProp3.IsAutoGenerated = false;
>> DataProp3.Nullable = false;
>> DataProp3.ReadOnly = false;
>>
>> DataProp4.DataType =
>> OSGeo.FDO.Schema.DataType.DataType_String;
>> DataProp4.IsAutoGenerated = false;
>> DataProp4.Nullable = false;
>> DataProp4.ReadOnly = false;
>> DataProp4.Length = 20;
>>
>> //Class one data props
>> ClassOne.Properties.Add(DataProp1);
>> ClassOne.IdentityProperties.Add(DataProp1);
>> ClassOne.Properties.Add(DataProp2);
>> ClassOne.Properties.Add(DataProp3);
>> ClassOne.Properties.Add(DataProp4);
>>
>>
>>
>> OSGeo.FDO.Connections.Capabilities.IConnectionCapabilities connCap =
>> conn.ConnectionCapabilities;
>> ITransaction fdoTrans = null;
>> if (connCap.SupportsTransactions())
>> fdoTrans = conn.BeginTransaction();
>>
>> using (OSGeo.FDO.Commands.Feature.IInsert insert
>> = conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Insert)
>> as OSGeo.FDO.Commands.Feature.IInsert)
>> {
>>
>> for (int nIndex = 1; nIndex < 5; nIndex++)
>> {
>>
>> OSGeo.FDO.Commands.PropertyValue
>> PropValue1 = null;
>> PropValue1 = new
>> OSGeo.FDO.Commands.PropertyValue();
>> PropValue1.SetName(DataProp1.Name);
>> PropValue1.Value = new
>> OSGeo.FDO.Expression.Int32Value(nIndex);
>> insert.PropertyValues.Add(PropValue1);
>>
>> PropValue1 = null;
>> PropValue1 = new
>> OSGeo.FDO.Commands.PropertyValue();
>> PropValue1.SetName(DataProp2.Name);
>> PropValue1.Value = new
>> OSGeo.FDO.Expression.DecimalValue(1000.50 + nIndex);
>> insert.PropertyValues.Add(PropValue1);
>>
>> PropValue1 = null;
>> PropValue1 = new
>> OSGeo.FDO.Commands.PropertyValue();
>> PropValue1.SetName(DataProp3.Name);
>> PropValue1.Value = new
>> OSGeo.FDO.Expression.DecimalValue(2000.50 + nIndex);
>> insert.PropertyValues.Add(PropValue1);
>>
>> PropValue1 = null;
>> PropValue1 = new
>> OSGeo.FDO.Commands.PropertyValue();
>> PropValue1.SetName(DataProp4.Name);
>> PropValue1.Value = new
>> OSGeo.FDO.Expression.StringValue("Note"+nIndex.ToString());
>> insert.PropertyValues.Add(PropValue1);
>>
>> try
>> {
>> using
>> (OSGeo.FDO.Commands.Feature.IFeatureReader reader = insert.Execute())
>> {
>> while (reader.ReadNext()) { }
>> }
>> }
>> catch (Exception ex)
>> {
>> //throw new
>> FeatureServiceException("Error inserting new feature", ex);
>> MessageBox.Show(ex.Message);
>> }
>> }
>> }
>> if (connCap.SupportsTransactions())
>> fdoTrans.Commit();
>> conn.Close();
>>
>>
>>
>
>
--
View this message in context: http://n2.nabble.com/inserting-data-into-a-SDF-file-tp2349739p2356982.html
Sent from the FDO Users mailing list archive at Nabble.com.
_______________________________________________
fdo-users mailing list
fdo-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fdo-users
More information about the fdo-users
mailing list