Add point to SHP file

3 messages Options
Embed this post
Permalink
sekko970

Add point to SHP file

Reply Threaded More More options
Print post
Permalink
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.

Jackie Ng

Re: Add point to SHP file

Reply Threaded More More options
Print post
Permalink
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.
sekko970

Re: Add point to SHP file

Reply Threaded More More options
Print post
Permalink
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.