Skip to content

Commit 38dc16f

Browse files
authored
Merge pull request #286 from JamesParrott/Synced_with_PyShp
Delete dormant commented code blocks
2 parents 11107c8 + 9582858 commit 38dc16f

File tree

1 file changed

+0
-113
lines changed

1 file changed

+0
-113
lines changed

shapefile.py

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -874,42 +874,6 @@ class ShapefileException(Exception):
874874
"""An exception to handle shapefile specific problems."""
875875
pass
876876

877-
# def warn_geojson_collection(shapes):
878-
# # collect information about any potential errors with the GeoJSON
879-
# errors = {}
880-
# for i,shape in enumerate(shapes):
881-
# shape_errors = shape._errors
882-
# if shape_errors:
883-
# for error in shape_errors.keys():
884-
# errors[error] = errors[error] + [i] if error in errors else []
885-
886-
# # warn if any errors were found
887-
# if errors:
888-
# messages = ['Summary of possibles issues encountered during shapefile to GeoJSON conversion:']
889-
890-
# # polygon orphan holes
891-
# orphans = errors.get('polygon_orphaned_holes', None)
892-
# if orphans:
893-
# msg = 'GeoJSON format requires that all interior holes be contained by an exterior ring, \
894-
# but the Shapefile contained {} records of polygons where some of its interior holes were \
895-
# orphaned (not contained by any other rings). The rings were still included but were \
896-
# encoded as GeoJSON exterior rings instead of holes. Shape ids: {}'.format(len(orphans), orphans)
897-
# messages.append(msg)
898-
899-
# # polygon only holes/wrong orientation
900-
# only_holes = errors.get('polygon_only_holes', None)
901-
# if only_holes:
902-
# msg = 'GeoJSON format requires that polygons contain at least one exterior ring, but \
903-
# the Shapefile contained {} records of polygons where all of its component rings were stored as interior \
904-
# holes. The rings were still included but were encoded as GeoJSON exterior rings instead of holes. \
905-
# Shape ids: {}'.format(len(only_holes), only_holes)
906-
# messages.append(msg)
907-
908-
# if len(messages) > 1:
909-
# # more than just the "Summary of..." header
910-
# msg = '\n'.join(messages)
911-
# logger.warning(msg)
912-
913877
class Reader(object):
914878
"""Reads the three files of a shapefile as a unit or
915879
separately. If one of the three files (.shp, .shx,
@@ -2556,83 +2520,6 @@ def field(self, name, fieldType="C", size="50", decimal=0):
25562520
"Shapefile Writer reached maximum number of fields: 2046.")
25572521
self.fields.append((name, fieldType, size, decimal))
25582522

2559-
## def saveShp(self, target):
2560-
## """Save an shp file."""
2561-
## if not hasattr(target, "write"):
2562-
## target = os.path.splitext(target)[0] + '.shp'
2563-
## self.shp = self.__getFileObj(target)
2564-
## self.__shapefileHeader(self.shp, headerType='shp')
2565-
## self.shp.seek(100)
2566-
## self._shp.seek(0)
2567-
## chunk = True
2568-
## while chunk:
2569-
## chunk = self._shp.read(self.bufsize)
2570-
## self.shp.write(chunk)
2571-
##
2572-
## def saveShx(self, target):
2573-
## """Save an shx file."""
2574-
## if not hasattr(target, "write"):
2575-
## target = os.path.splitext(target)[0] + '.shx'
2576-
## self.shx = self.__getFileObj(target)
2577-
## self.__shapefileHeader(self.shx, headerType='shx')
2578-
## self.shx.seek(100)
2579-
## self._shx.seek(0)
2580-
## chunk = True
2581-
## while chunk:
2582-
## chunk = self._shx.read(self.bufsize)
2583-
## self.shx.write(chunk)
2584-
##
2585-
## def saveDbf(self, target):
2586-
## """Save a dbf file."""
2587-
## if not hasattr(target, "write"):
2588-
## target = os.path.splitext(target)[0] + '.dbf'
2589-
## self.dbf = self.__getFileObj(target)
2590-
## self.__dbfHeader() # writes to .dbf
2591-
## self._dbf.seek(0)
2592-
## chunk = True
2593-
## while chunk:
2594-
## chunk = self._dbf.read(self.bufsize)
2595-
## self.dbf.write(chunk)
2596-
2597-
## def save(self, target=None, shp=None, shx=None, dbf=None):
2598-
## """Save the shapefile data to three files or
2599-
## three file-like objects. SHP and DBF files can also
2600-
## be written exclusively using saveShp, saveShx, and saveDbf respectively.
2601-
## If target is specified but not shp, shx, or dbf then the target path and
2602-
## file name are used. If no options or specified, a unique base file name
2603-
## is generated to save the files and the base file name is returned as a
2604-
## string.
2605-
## """
2606-
## # Balance if already not balanced
2607-
## if shp and dbf:
2608-
## if self.autoBalance:
2609-
## self.balance()
2610-
## if self.recNum != self.shpNum:
2611-
## raise ShapefileException("When saving both the dbf and shp file, "
2612-
## "the number of records (%s) must correspond "
2613-
## "with the number of shapes (%s)" % (self.recNum, self.shpNum))
2614-
## # Save
2615-
## if shp:
2616-
## self.saveShp(shp)
2617-
## if shx:
2618-
## self.saveShx(shx)
2619-
## if dbf:
2620-
## self.saveDbf(dbf)
2621-
## # Create a unique file name if one is not defined
2622-
## if not shp and not shx and not dbf:
2623-
## generated = False
2624-
## if not target:
2625-
## temp = tempfile.NamedTemporaryFile(prefix="shapefile_",dir=os.getcwd())
2626-
## target = temp.name
2627-
## generated = True
2628-
## self.saveShp(target)
2629-
## self.shp.close()
2630-
## self.saveShx(target)
2631-
## self.shx.close()
2632-
## self.saveDbf(target)
2633-
## self.dbf.close()
2634-
## if generated:
2635-
## return target
26362523

26372524
# Begin Testing
26382525
def test(**kwargs):

0 commit comments

Comments
 (0)