|
|
|
vinay
|
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. ![]() 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(); |
||||||||||||||||
|
Jackie Ng
|
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
|
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
|
A Spatial Context is nothing more than a piece of metadata that indicates the coordinate system of the geometry objects in your spatial data source.
Could you elaborate more on what difficulty you are experiencing? - Jackie
|
||||||||||||||||
|
Dan Stoica
|
In reply to this post
by vinay
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: [hidden email] [mailto:[hidden email]] On Behalf Of vinay Sent: Thursday, February 19, 2009 10:35 PM To: [hidden email] 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 [hidden email] http://lists.osgeo.org/mailman/listinfo/fdo-users _______________________________________________ fdo-users mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/fdo-users |
||||||||||||||||
|
vinay
|
Some javascript/style in this post has been disabled (why?)
Hi
Dan
Thanks
for the information.
regards
Vinay
The information contained in this message is intended only for the recipient, and may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, please be aware that any dissemination or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify us by replying to the message and delete it from your system. Eagle Point reserves the right, subject to applicable local law, to monitor and review the content of any electronic message or information sent to or from Eagle Point employee e-mail addresses without informing the sender or recipient of the message. |
|||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |