zhikrullah / pyshp

Automatically exported from code.google.com/p/pyshp
MIT License
0 stars 0 forks source link

delete method of Editor class will not delete the 0th shape of the shapefile #42

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. >> e = shapefile.Editor(shapefile="shapefiles/test/polygon.shp")
2. >> print "No. of shapes: %i" % len(e.shapes())
3. >> e.delete(0)
4. >> print "No. of shapes: %i" % len(e.shapes())

What is the expected output? What do you see instead?

I expect the number of shapes to be reduced by one after the delete method is 
called. Instead the number of shapes remains the same.

What version of the product are you using? On what operating system?

Using shapefile-1.1.6-b.py under Python 2.7 under linux (Fedora 14).

Please provide any additional information below.

The problem is caused by the way that the delete method determines whether 
points, shapes, or parts are to be deleted.  This logic fails because Python 
evaluates 0 shape index as "False" when it applies the filtering logic.  The 
attached patch fixes the problem.

Original issue reported on code.google.com by jeffreyb...@gmail.com on 30 Dec 2012 at 1:45

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by jlawh...@geospatialpython.com on 2 May 2013 at 4:56