engine/process.py
def shp(self, geom_type, survey, question, answer, count):
        """Create a dictionary, were keys are names of the mandatory files of
           the shapefile format, values are empty binary objects. Using the Shapefile library
           write into the dictionary all data collected by all users under a survey.
           Return the dictionary either for point(s) or polygon(s)."""
        shp = {'shp': io.BytesIO(), 'shx': io.BytesIO(), 'dbf': io.BytesIO(), 'check': None}
        transit = []

        with shapefile.Writer(dbf=shp['dbf'], shp=shp['shp'], shx=shp['shx']) as w:
            w.field('ID')
            w.field('USER_NAME')
            w.field('SURVEY')
            w.field('TIME')
            w.field('PHOTO')
            w.field('VIDEO')

            for i in range(count):
                w.field(f"QUEST_{i + 1}")
                w.field(f"ANS_{i + 1}")

            cursor.execute(f"select id, user_name, survey, to_char(entr_time, 'DD-Mon-YYYY HH24:MI:SS'), "
                           f"photo, video, st_astext({geom_type}) from {self.db}features where "
                           f"survey = {survey} and ans_check = 1 order by id")
            for line in cursor.fetchall():
                elems = []
                for i in range(7):
                    elems.append(line[i])
                for j in range(count):
                    elems.append(question[j][0])
                    elems.append(answer[0][0])
                    del answer[0]
                transit.append(elems)

            # Assigning the pre-set IDs in the test mode
            if self.db == 'test_':
                transit = self.transit_process(transit)

            for row in transit:
                if row[6]:
                    shp['check'] = 1
                    if geom_type == 'point':
                        point_res = self.point(row[6])
                        w.point(point_res[0], point_res[1])
                    else:
                        w.poly([self.polygon(row[6])])
                    del row[6]
                    w.record(*row)

        return shp
Create a dictionary, were keys are names of the mandatory files of
           the shapefile format, values are empty binary objects. Using the Shapefile library
           write into the dictionary all data collected by all users under a survey.
           Return the dictionary either for point(s) or polygon(s).
Create a dictionary, were keys are names of the mandatory files of
the shapefile format, values are empty binary objects. Using the Shapefile library
write into the dictionary all data collected by all users under a survey.
Create a dictionary were keys are names of the mandatory files of the shapefile format values are empty binary objects . Using the Shapefile library write into the dictionary all data collected by all users under a survey .
def shp(self, geom_type, survey, question, answer, count):
        shp = {'shp': io.BytesIO(), 'shx': io.BytesIO(), 'dbf': io.BytesIO(), 'check': None}
        transit = []
        with shapefile.Writer(dbf=shp['dbf'], shp=shp['shp'], shx=shp['shx']) as w:
            w.field('ID')
            w.field('USER_NAME')
            w.field('SURVEY')
            w.field('TIME')
            w.field('PHOTO')
            w.field('VIDEO')
            for i in range(count):
                w.field(f"QUEST_{i + 1}")
                w.field(f"ANS_{i + 1}")
            cursor.execute(f"select id, user_name, survey, to_char(entr_time, 'DD-Mon-YYYY HH24:MI:SS'), "
                           f"photo, video, st_astext({geom_type}) from {self.db}features where "
                           f"survey = {survey} and ans_check = 1 order by id")
            for line in cursor.fetchall():
                elems = []
                for i in range(7):
                    elems.append(line[i])
                for j in range(count):
                    elems.append(question[j][0])
                    elems.append(answer[0][0])
                    del answer[0]
                transit.append(elems)
            if self.db == 'test_':
                transit = self.transit_process(transit)
            for row in transit:
                if row[6]:
                    shp['check'] = 1
                    if geom_type == 'point':
                        point_res = self.point(row[6])
                        w.point(point_res[0], point_res[1])
                    else:
                        w.poly([self.polygon(row[6])])
                    del row[6]
                    w.record(*row)
        return shp
def shp ( self , geom_type , survey , question , answer , count ) : shp = { 'shp' : io . BytesIO ( ) , 'shx' : io . BytesIO ( ) , 'dbf' : io . BytesIO ( ) , 'check' : None } transit = [ ] with shapefile . Writer ( dbf = shp [ 'dbf' ] , shp = shp [ 'shp' ] , shx = shp [ 'shx' ] ) as w : w . field ( 'ID' ) w . field ( 'USER_NAME' ) w . field ( 'SURVEY' ) w . field ( 'TIME' ) w . field ( 'PHOTO' ) w . field ( 'VIDEO' ) for i in range ( count ) : w . field ( f"QUEST_{i + 1}" ) w . field ( f"ANS_{i + 1}" ) cursor . execute ( f"select id, user_name, survey, to_char(entr_time, 'DD-Mon-YYYY HH24:MI:SS'), " f"photo, video, st_astext({geom_type}) from {self.db}features where " f"survey = {survey} and ans_check = 1 order by id" ) for line in cursor . fetchall ( ) : elems = [ ] for i in range ( 7 ) : elems . append ( line [ i ] ) for j in range ( count ) : elems . append ( question [ j ] [ 0 ] ) elems . append ( answer [ 0 ] [ 0 ] ) del answer [ 0 ] transit . append ( elems ) if self . db == 'test_' : transit = self . transit_process ( transit ) for row in transit : if row [ 6 ] : shp [ 'check' ] = 1 if geom_type == 'point' : point_res = self . point ( row [ 6 ] ) w . point ( point_res [ 0 ] , point_res [ 1 ] ) else : w . poly ( [ self . polygon ( row [ 6 ] ) ] ) del row [ 6 ] w . record ( * row ) return shp
Create a dictionary, were keys are names of the mandatory files of
the shapefile format, values are empty binary objects.
Create a dictionary were keys are names of the mandatory files of the shapefile format values are empty binary objects .
"""Create a dictionary, were keys are names of the mandatory files of
           the shapefile format, values are empty binary objects. Using the Shapefile library
           write into the dictionary all data collected by all users under a survey.
           Return the dictionary either for point(s) or polygon(s).""" # Assigning the pre-set IDs in the test mode
self
geom_type
survey
question
answer
count