Add point to SHP file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Add point to SHP file

sekko970
Dear all,
I have problem in adding a point to an existing shapefile.

Running command.Execute, the following error is shown:
"'FdoPtr::operator->': Cannot execute function due to invalid value for the input parameter(s) 'p'. "

This is my code:

        Dim connManager As OSGeo.FDO.IConnectionManager = OSGeo.FDO.ClientServices.FeatureAccessManager.GetConnectionManager()
        Dim conn As OSGeo.FDO.Connections.IConnection = connManager.CreateConnection("OSGeo.SHP.3.4")
        conn.ConnectionString = "DefaultFileLocation=C:\WebSites\GeoT\userdata\Buffer.shp;"
        conn.Open()

        Dim command As IInsert = CType(conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Insert), IInsert)
        Dim factory As New FgfGeometryFactory()
        Dim position As IDirectPosition = factory.CreatePositionXYZ(1501015.85932722, 4431050.33027523, 0)
        Dim point As IPoint = factory.CreatePoint(position)
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("FeatID", New Int32Value(5)))
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("Z", New DecimalValue(12)))
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("N", New DecimalValue(23)))
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("Geometry", New GeometryValue(factory.GetFgf(point))))

        Try
            Dim reader As IFeatureReader = command.Execute()
            If reader.ReadNext() Then
            End If
        Catch ex As Exception
        Finally
            conn.Close()
        End Try


Have you any idea?
F.

Reply | Threaded
Open this post in threaded view
|

Re: Add point to SHP file

Jackie Ng
You haven't specified the feature class the insert command will be inserting into.

- Jackie

sekko970 wrote
Dear all,
I have problem in adding a point to an existing shapefile.

Running command.Execute, the following error is shown:
"'FdoPtr::operator->': Cannot execute function due to invalid value for the input parameter(s) 'p'. "

This is my code:

        Dim connManager As OSGeo.FDO.IConnectionManager = OSGeo.FDO.ClientServices.FeatureAccessManager.GetConnectionManager()
        Dim conn As OSGeo.FDO.Connections.IConnection = connManager.CreateConnection("OSGeo.SHP.3.4")
        conn.ConnectionString = "DefaultFileLocation=C:\WebSites\GeoT\userdata\Buffer.shp;"
        conn.Open()

        Dim command As IInsert = CType(conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Insert), IInsert)
        Dim factory As New FgfGeometryFactory()
        Dim position As IDirectPosition = factory.CreatePositionXYZ(1501015.85932722, 4431050.33027523, 0)
        Dim point As IPoint = factory.CreatePoint(position)
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("FeatID", New Int32Value(5)))
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("Z", New DecimalValue(12)))
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("N", New DecimalValue(23)))
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("Geometry", New GeometryValue(factory.GetFgf(point))))

        Try
            Dim reader As IFeatureReader = command.Execute()
            If reader.ReadNext() Then
            End If
        Catch ex As Exception
        Finally
            conn.Close()
        End Try


Have you any idea?
F.
Reply | Threaded
Open this post in threaded view
|

Re: Add point to SHP file

sekko970
You are right, now it works!
F.


Jackie Ng wrote
You haven't specified the feature class the insert command will be inserting into.

- Jackie

sekko970 wrote
Dear all,
I have problem in adding a point to an existing shapefile.

Running command.Execute, the following error is shown:
"'FdoPtr::operator->': Cannot execute function due to invalid value for the input parameter(s) 'p'. "

This is my code:

        Dim connManager As OSGeo.FDO.IConnectionManager = OSGeo.FDO.ClientServices.FeatureAccessManager.GetConnectionManager()
        Dim conn As OSGeo.FDO.Connections.IConnection = connManager.CreateConnection("OSGeo.SHP.3.4")
        conn.ConnectionString = "DefaultFileLocation=C:\WebSites\GeoT\userdata\Buffer.shp;"
        conn.Open()

        Dim command As IInsert = CType(conn.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Insert), IInsert)
        Dim factory As New FgfGeometryFactory()
        Dim position As IDirectPosition = factory.CreatePositionXYZ(1501015.85932722, 4431050.33027523, 0)
        Dim point As IPoint = factory.CreatePoint(position)
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("FeatID", New Int32Value(5)))
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("Z", New DecimalValue(12)))
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("N", New DecimalValue(23)))
        command.PropertyValues.Add(New OSGeo.FDO.Commands.PropertyValue("Geometry", New GeometryValue(factory.GetFgf(point))))

        Try
            Dim reader As IFeatureReader = command.Execute()
            If reader.ReadNext() Then
            End If
        Catch ex As Exception
        Finally
            conn.Close()
        End Try


Have you any idea?
F.
Reply | Threaded
Open this post in threaded view
|

Re: Add point to SHP file

veersh
This post has NOT been accepted by the mailing list yet.
In reply to this post by sekko970
If I use the statement "OSGeo.FDO.ClientServices.FeatureAccessManager.GetConnectionManager();"
I am getting error like "External component has thrown an exception."


I Use AutoCAD Map 3D 2011
VS 2005


Can anyone please help me asap.


Thanks in Advance.
Hi,

I had referenced following dlls into my project
OSGeo.FDO
OSGeo.FDO.Connection
OSGeo.FDO.Geometry

I have write code under load enent
private void Form1_Load(object sender, EventArgs e)
        {
            try
            {

                IProviderRegistry FDORegistry = FeatureAccessManager.GetProviderRegistry();
                string tmpStr = "";
                ProviderCollection providers = FDORegistry.GetProviders();
                int nCout = providers.Count;

                System.Collections.IEnumerator Iterator = providers.GetEnumerator();
                foreach (Provider provider in providers)
                {
                    String outStr = "Provider List:\r\n" + provider.DisplayName;
                    outStr += tmpStr;
                    tmpStr = String.Format("|- LibraryPath:{0} \r\n", provider.LibraryPath);
                    outStr += tmpStr;
                    tmpStr = String.Format("|- Version:{0} \r\n", provider.Version);
                    outStr += tmpStr;
                    tmpStr = String.Format("|- Description:{0} \r\n", provider.Description);
                    outStr += tmpStr;
                    outPut.Text = outStr;
                }
            }
            catch (OSGeo.FDO.Common.Exception ex)
            //catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

It gives error exceptional error like "External component has thrown an exception."
I am using AutoCAD MAP 3D 2011 & VS-2005

Can you please provide the solution Why???