Insert new feature object on SHP File

4 messages Options
Embed this post
Permalink
Matteo

Insert new feature object on SHP File

Reply Threaded More More options
Print post
Permalink
Hi all,
  I'm new on FDO. I try to insert a new feature object on a shp file with VB.NET but i get this error "The type of geometry ( 'PolyLineM') geographical entity creates a conflict with the type of shape file ( 'Polyline')."
This is the code:
Dim objCmdI As Commands.Feature.IInsert = objConn.CreateCommand(Commands.CommandType.CommandType_Insert)
        objCmdI.SetFeatureClassName(objClass.Name)
        Dim objPropsValues As Commands.PropertyValueCollection = objCmdI.PropertyValues()
        Dim objPropV As Commands.PropertyValue = New Commands.PropertyValue()
        objPropV.SetName("ID")
        objPropV.Value = New OSGeo.FDO.Expression.Int32Value(2)


        objPropsValues.Add(objPropV)
        objPropV = New Commands.PropertyValue()
        objPropV.SetName("Geometry")
        Dim objGeomV As Geometry.FgfGeometryFactory = New Geometry.FgfGeometryFactory()

        Dim objCoords(5) As Double
        objCoords(0) = 0
        objCoords(1) = 0
        objCoords(2) = 10
        objCoords(3) = 10
        objCoords(4) = 50
        objCoords(5) = 20

        Dim objLine As Geometry.ILineString = objGeomV.CreateLineString(2, 3, objCoords)
       
        objPropV.Value = New OSGeo.FDO.Expression.GeometryValue(objGeomV.GetFgf(objLine))
        objPropsValues.Add(objPropV)
        objCmdI.Execute()
        objConn.Flush()

Can you help me?
Regards,
Matteo
Jason Birch

Re: Insert new feature object on SHP File

Reply Threaded More More options
Print post
Permalink
I'm not an FDO coder, but there are a couple things I'd look at.

First, FDODimensionality isn't an integer value representing the number of dimensions, it's a bit-field enumeration. In this case, 2 evaluates to FdoDimensionality_M (although, since the value of FdoDimensionality_XY is 0, this is included by default in the evaluation of FdoDimensionality_M - neat).


Second, the docs for CreateLineString indicate that it's looking for the number of ordinates, not co-ordinates.  I'm not sure if this is just a terminology issue, but perhaps it is looking for 6 in your case.


Jason

2009/11/1 Matteo <[hidden email]>

Hi all,
 I'm new on FDO. I try to insert a new feature object on a shp file with
VB.NET but i get this error "The type of geometry ( 'PolyLineM')
geographical entity creates a conflict with the type of shape file (
'Polyline')."
This is the code:
Dim objCmdI As Commands.Feature.IInsert =
objConn.CreateCommand(Commands.CommandType.CommandType_Insert)
       objCmdI.SetFeatureClassName(objClass.Name)
       Dim objPropsValues As Commands.PropertyValueCollection =
objCmdI.PropertyValues()
       Dim objPropV As Commands.PropertyValue = New
Commands.PropertyValue()
       objPropV.SetName("ID")
       objPropV.Value = New OSGeo.FDO.Expression.Int32Value(2)


       objPropsValues.Add(objPropV)
       objPropV = New Commands.PropertyValue()
       objPropV.SetName("Geometry")
       Dim objGeomV As Geometry.FgfGeometryFactory = New
Geometry.FgfGeometryFactory()

       Dim objCoords(5) As Double
       objCoords(0) = 0
       objCoords(1) = 0
       objCoords(2) = 10
       objCoords(3) = 10
       objCoords(4) = 50
       objCoords(5) = 20

       Dim objLine As Geometry.ILineString = objGeomV.CreateLineString(2,
3, objCoords)

       objPropV.Value = New
OSGeo.FDO.Expression.GeometryValue(objGeomV.GetFgf(objLine))
       objPropsValues.Add(objPropV)
       objCmdI.Execute()
       objConn.Flush()

Can you help me?
Regards,
Matteo

--
View this message in context: http://n2.nabble.com/Insert-new-feature-object-on-SHP-File-tp3928348p3928348.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
Matteo

Re: Insert new feature object on SHP File

Reply Threaded More More options
Print post
Permalink
Thanks a lot Jason. Now work fine.
Regards,
Matteo
Jason Birch wrote:
I'm not an FDO coder, but there are a couple things I'd look at.

First, FDODimensionality isn't an integer value representing the number of
dimensions, it's a bit-field enumeration. In this case, 2 evaluates to
FdoDimensionality_M (although, since the value of FdoDimensionality_XY is 0,
this is included by default in the evaluation of FdoDimensionality_M -
neat).

http://fdo.osgeo.org/files/fdo/docs/FDO_API/d3/d95/group__enums_g3778ef9845e2ba00e8669c32ec42e113.htm#g3778ef9845e2ba00e8669c32ec42e113

Second, the docs for CreateLineString indicate that it's looking for the
number of ordinates, not co-ordinates.  I'm not sure if this is just a
terminology issue, but perhaps it is looking for 6 in your case.

http://fdo.osgeo.org/files/fdo/docs/FDO_API/d1/d7d/class_fdo_fgf_geometry_factory_0e122ad008ada729f974e407aa1285dd.htm#0e122ad008ada729f974e407aa1285dd

Jason

2009/11/1 Matteo <matteo.conte1979@libero.it>

>
> Hi all,
>  I'm new on FDO. I try to insert a new feature object on a shp file with
> VB.NET but i get this error "The type of geometry ( 'PolyLineM')
> geographical entity creates a conflict with the type of shape file (
> 'Polyline')."
> This is the code:
> Dim objCmdI As Commands.Feature.IInsert =
> objConn.CreateCommand(Commands.CommandType.CommandType_Insert)
>        objCmdI.SetFeatureClassName(objClass.Name)
>        Dim objPropsValues As Commands.PropertyValueCollection =
> objCmdI.PropertyValues()
>        Dim objPropV As Commands.PropertyValue = New
> Commands.PropertyValue()
>        objPropV.SetName("ID")
>        objPropV.Value = New OSGeo.FDO.Expression.Int32Value(2)
>
>
>        objPropsValues.Add(objPropV)
>        objPropV = New Commands.PropertyValue()
>        objPropV.SetName("Geometry")
>        Dim objGeomV As Geometry.FgfGeometryFactory = New
> Geometry.FgfGeometryFactory()
>
>        Dim objCoords(5) As Double
>        objCoords(0) = 0
>        objCoords(1) = 0
>        objCoords(2) = 10
>        objCoords(3) = 10
>        objCoords(4) = 50
>        objCoords(5) = 20
>
>        Dim objLine As Geometry.ILineString = objGeomV.CreateLineString(2,
> 3, objCoords)
>
>        objPropV.Value = New
> OSGeo.FDO.Expression.GeometryValue(objGeomV.GetFgf(objLine))
>        objPropsValues.Add(objPropV)
>        objCmdI.Execute()
>        objConn.Flush()
>
> Can you help me?
> Regards,
> Matteo
>
> --
> View this message in context:
> http://n2.nabble.com/Insert-new-feature-object-on-SHP-File-tp3928348p3928348.html
> Sent from the FDO Users mailing list archive at Nabble.com.
> _______________________________________________
> fdo-users mailing list
> fdo-users@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fdo-users
>

_______________________________________________
fdo-users mailing list
fdo-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fdo-users
Gavin Cramer

RE: Insert new feature object on SHP File

Reply Threaded More More options
Print post
Permalink
It is good to see that you got your code working.

I noticed that you were providing a value for the ID property.  In SHP, I believe that the identifier is always auto-generated.  Perhaps the SHP Provider is not checking, but some providers are more strict and may throw an exception if you supply a value for an auto-generated property.

To find out whether a property is auto-generated, you can use the FdoIDescribeSchema command, and search the resulting object tree for the needed property.  The FdoDataPropertyDefinition:: GetIsAutoGenerated() method will say whether the property is auto-generated (in which case, it is best to not provide a value during an Insert).

Gavin


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Matteo
Sent: Sunday, November 01, 2009 4:39 PM
To: [hidden email]
Subject: Re: [fdo-users] Insert new feature object on SHP File


Thanks a lot Jason. Now work fine.
Regards,
Matteo

Jason Birch wrote:

>
> I'm not an FDO coder, but there are a couple things I'd look at.
>
> First, FDODimensionality isn't an integer value representing the number of
> dimensions, it's a bit-field enumeration. In this case, 2 evaluates to
> FdoDimensionality_M (although, since the value of FdoDimensionality_XY is
> 0,
> this is included by default in the evaluation of FdoDimensionality_M -
> neat).
>
> http://fdo.osgeo.org/files/fdo/docs/FDO_API/d3/d95/group__enums_g3778ef9845e2ba00e8669c32ec42e113.htm#g3778ef9845e2ba00e8669c32ec42e113
>
> Second, the docs for CreateLineString indicate that it's looking for the
> number of ordinates, not co-ordinates.  I'm not sure if this is just a
> terminology issue, but perhaps it is looking for 6 in your case.
>
> http://fdo.osgeo.org/files/fdo/docs/FDO_API/d1/d7d/class_fdo_fgf_geometry_factory_0e122ad008ada729f974e407aa1285dd.htm#0e122ad008ada729f974e407aa1285dd
>
> Jason
>
> 2009/11/1 Matteo <[hidden email]>
>
>>
>> Hi all,
>>  I'm new on FDO. I try to insert a new feature object on a shp file with
>> VB.NET but i get this error "The type of geometry ( 'PolyLineM')
>> geographical entity creates a conflict with the type of shape file (
>> 'Polyline')."
>> This is the code:
>> Dim objCmdI As Commands.Feature.IInsert =
>> objConn.CreateCommand(Commands.CommandType.CommandType_Insert)
>>        objCmdI.SetFeatureClassName(objClass.Name)
>>        Dim objPropsValues As Commands.PropertyValueCollection =
>> objCmdI.PropertyValues()
>>        Dim objPropV As Commands.PropertyValue = New
>> Commands.PropertyValue()
>>        objPropV.SetName("ID")
>>        objPropV.Value = New OSGeo.FDO.Expression.Int32Value(2)
>>
>>
>>        objPropsValues.Add(objPropV)
>>        objPropV = New Commands.PropertyValue()
>>        objPropV.SetName("Geometry")
>>        Dim objGeomV As Geometry.FgfGeometryFactory = New
>> Geometry.FgfGeometryFactory()
>>
>>        Dim objCoords(5) As Double
>>        objCoords(0) = 0
>>        objCoords(1) = 0
>>        objCoords(2) = 10
>>        objCoords(3) = 10
>>        objCoords(4) = 50
>>        objCoords(5) = 20
>>
>>        Dim objLine As Geometry.ILineString = objGeomV.CreateLineString(2,
>> 3, objCoords)
>>
>>        objPropV.Value = New
>> OSGeo.FDO.Expression.GeometryValue(objGeomV.GetFgf(objLine))
>>        objPropsValues.Add(objPropV)
>>        objCmdI.Execute()
>>        objConn.Flush()
>>
>> Can you help me?
>> Regards,
>> Matteo
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/Insert-new-feature-object-on-SHP-File-tp3928348p3928348.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
>
>

--
View this message in context: http://n2.nabble.com/Insert-new-feature-object-on-SHP-File-tp3928348p3928709.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