def __init__(self, filename): if not filename.endswith("shp"): dbffilename = filename + ".dbf" shpfilename = filename + ".shp" else: dbffilename = filename.split(".")[0] + ".dbf" shpfilename = filename Parser.__init__(self, shpfilename, base.LITTLE_ENDIAN) self.bbox = [] self.features = [] self.ignore_fields = [] self.dbf_parser = DbfParser(dbffilename) self.shape_type = None self.last_read_type = None self.bbox_cache = None self.shape_types = { 0: self.NullShape, 1: self.Point, 3: self.PolyLine, 5: self.Polygon, 8: self.MultiPoint, 11: self.PointZ, 13: self.PolyLineZ, 15: self.PolygonZ, 18: self.MultiPointZ, 21: self.PointM, 23: self.PolyLineM, 25: self.PolygonM, 28: self.MultiPointM, 31: self.MultiPatch, }
def __init__(self, filename): Parser.__init__(self, filename) # creates self.fd self.fields = [] self.records = [] self.headers_done = False self.records_done = False self.data_types = { 'C': self.read_string_trim, # < 254 bytes 'N': self.read_string_trim, # string repr of number, < 18 bytes #'L': self.read_logical, # 1 byte #'D': self.read_date, # YYYYMMDD #'M': self.read_memo, # 10 byte pointer 'F': self.read_string_trim, # 20 bytes #'B': self.read_binary, #'G': self.read_ole, #'P': self.read_picture, #'Y': self.read_currency, #'T': self.read_datetime, 'I': self.read_word, # 4 byte little endian #'V': self.read_varifield, #'X': self.read_variant, #'@': self.read_timestamp, # 8 bytes: 2 longs 'O': self.read_double, # 8 bytes '+': self.read_word, # autoincrement value, 4 byte long }