Opened 11 years ago

Last modified 11 years ago

#5181 closed defect

In Python, calls on a Point geometry cause crash — at Initial Version

Reported by: lakshmanok Owned by: hobu
Priority: normal Milestone:
Component: PythonBindings Version: 1.10.0
Severity: major Keywords:
Cc:

Description

In Python, calls on a Point geometry cause the interpreter to crash. The Windows error reads "calls on a pure virtual function".

I have attached a bare-bones Python script that will cause the crash. The shapefile that I was using is attached, but the bug is not limited to this shapefile. I believe that the crash happens on any shapefile that contains Points. I was able to reproduce the bug on the point shapefile available at: http://invisibleroads.com/tutorials/_downloads/gdal-shapefile-points.zip

thanks Lak

import sys import os import shutil from osgeo import ogr, osr

def get_location(feature):

geometry = feature.GetGeometryRef() x = geometry.GetX() #### Causes Crash y = geometry.GetY() return x,y

### my workaround ... to get it to work ##def get_location(feature): ## s = feature.ExportToJson() ## c = s[s.find(')+1 : s.find(')].split(',') ## x,y = float(c[0]),float(c[1]) ## return x,y

# read input inputshp = 'IOW_Fire_Hydrants.shp' datasource = ogr.GetDriverByName('ESRI Shapefile').Open(inputshp) if datasource is None:

print 'Could not open ' + inputshp sys.exit(-1)

inlayer = datasource.GetLayer() get_location(inlayer.GetFeature(1))

Change History (2)

by lakshmanok, 11 years ago

Attachment: IsleOfWright.zip added

Example shapefile with Points that illustrates the bug

by lakshmanok, 11 years ago

Attachment: point_geometry_crash.py added
Note: See TracTickets for help on using tickets.