[Gdal-dev] Seg fault with CreateFeature
Tyler Mitchell
TMitchell at lignum.com
Tue Dec 16 19:59:57 EST 2003
This is one of my first attempts at creating a layer and wondered if anyone
can notice any obvious problem with my methodology. Python certainly
doesn't like it - I get a core dump after my last command.
The basic idea is:
1) open a DGN layer, read a feature and geometry and the Style String.
2) Create a new shape file and put the geometry into it, calculate the
string data type field to hold the style string value
I'm running gdal from CVS today this morning on Cygwin. I'm getting errors
on win32 as well, which points to my SetGeometry syntax. What am I doing
wrong?
Tyler
Here is my output, followed by the raw script
----------------
Interactive OUTPUT
-----------------
Python 2.3 (#1, Aug 27 2003, 16:44:27)
[GCC 3.2 20020927 (prerelease)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ogr
>>> dsin = ogr.Open("c:/tmp/dgnshp/cp200.dgn")
>>> layin = dsin.GetLayer()
>>> layin.GetName()
'elements'
>>> dsout = ogr.GetDriver(0).CreateDataSource("c:/tmp/dgnshp/ogrout")
>>> layout = dsout.CreateLayer("newlayer",None,3)
>>> flddefout = ogr.FieldDefn( "stylestr",4)
>>> layout.CreateField(flddefout)
0
>>> featin = layin.GetFeature(18)
>>> featin.GetField("Type")
14
>>> featout = ogr.Feature( flddefout )
>>> geoin = featin.GetGeometryRef()
>>> featout.SetGeometryDirectly( geoin )
0
>>> featout.SetField(0,featin.GetStyleString)
>>> layout.CreateFeature(featout)
Segmentation fault (core dumped)
----------------
Stripped down script
-----------------
import ogr
dsin = ogr.Open("c:/tmp/dgnshp/cp200.dgn")
layin = dsin.GetLayer()
layin.GetName()
#'elements'
dsout = ogr.GetDriver(0).CreateDataSource("c:/tmp/dgnshp/ogrout")
layout = dsout.CreateLayer("newlayer",None,3)
flddefout = ogr.FieldDefn( "stylestr",4)
layout.CreateField(flddefout)
#0
featin = layin.GetFeature(18)
featin.GetField("Type")
#14
featout = ogr.Feature( flddefout )
geoin = featin.GetGeometryRef()
featout.SetGeometryDirectly( geoin )
#0
featout.SetField(0,featin.GetStyleString)
layout.CreateFeature(featout)
#Segmentation fault (core dumped)
More information about the Gdal-dev
mailing list