Beispiel #1
0
 def _read_header(self):
     prolog = binread(self.fd, ">iiiiii")
     # only the first field is used and has a fixed value
     if prolog[0] != self.SHP_FILE_CODE:
         print "warning: wrong file code"
     self.shp_filelength = binread_first(self.fd, ">i")
     self.shp_version = binread_first(self.fd, "<i")
     self.shp_shape_type = binread_first(self.fd, "<i")
     self.shp_bbox_xmin, self.shp_bbox_ymin = binread(self.fd, "<dd")
     self.shp_bbox_xmax, self.shp_bbox_ymax = binread(self.fd, "<dd")
     self.shp_bbox_zmin, self.shp_bbox_zmax = binread(self.fd, "<dd")
     self.shp_bbox_mmin, self.shp_bbox_mmax = binread(self.fd, "<dd")
Beispiel #2
0
 def _read_header(self):
     prolog = binread(self.fd, ">iiiiii")
     # only the first field is used and has a fixed value
     if prolog[0] != self.SHP_FILE_CODE:
         print "warning: wrong file code"
     self.shp_filelength = binread_first(self.fd, ">i")
     self.shp_version = binread_first(self.fd, "<i")
     self.shp_shape_type = binread_first(self.fd, "<i")
     self.shp_bbox_xmin, self.shp_bbox_ymin = binread(self.fd, "<dd")
     self.shp_bbox_xmax, self.shp_bbox_ymax = binread(self.fd, "<dd")
     self.shp_bbox_zmin, self.shp_bbox_zmax = binread(self.fd, "<dd")
     self.shp_bbox_mmin, self.shp_bbox_mmax = binread(self.fd, "<dd")
Beispiel #3
0
    def get_shapes(self):
        bytelength = self.shp_filelength * 2
        while self.fd.tell() < bytelength:
            r_id = binread_first(self.fd, ">i")
            r_content_length = binread_first(self.fd, ">i")
            r_shape = binread_first(self.fd, "<i")

            klass = shapes.type_to_class(r_shape)(r_id)
            klass.read(self.fd)
            yield klass

        if self.fd.tell() != bytelength:
            sys.stderr.write("warning: inexeact file end (differs from what header says)\n")

        # reposition fp just right after the header so we can start reading
        # again if we want to
        self.fd.seek(self.SHP_HEADER_SIZE)
        return
Beispiel #4
0
    def get_shapes(self):
        bytelength = self.shp_filelength * 2
        while self.fd.tell() < bytelength:
            r_id = binread_first(self.fd, ">i")
            r_content_length = binread_first(self.fd, ">i")
            r_shape = binread_first(self.fd, "<i")

            klass = shapes.type_to_class(r_shape)(r_id)
            klass.read(self.fd)
            yield klass

        if self.fd.tell() != bytelength:
            sys.stderr.write(
                "warning: inexeact file end (differs from what header says)\n")

        # reposition fp just right after the header so we can start reading
        # again if we want to
        self.fd.seek(self.SHP_HEADER_SIZE)
        return