engine/process.py
def gjson(self, geom_type, survey, question, answer, count):
        """From all data collected by all users under a survey
           create a GeoJson using the template. Return it either
           for point(s) or polygon(s)."""
        source = {'result': {"type": "FeatureCollection", "name": "Places",
                  "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}}, "features": []},
                  'check': 0}

        cursor.execute(f"select id, user_name, survey, entr_time, photo, video, st_astext({geom_type})"
                       f" from {self.db}features where survey = {survey} and ans_check = 1 order by id")
        fetched = cursor.fetchall()

        for i in range(len(fetched)):
            row = fetched[i]
            elem = {"id": row[0], "user_name": f"{row[1]}", "survey": f"{row[2]}", "entr_time": f"{row[3]}",
                    "photo": f"{row[4]}", "video": f"{row[5]}"}

            # Assigning the pre-set IDs in the test mode
            if self.db == 'test_':
                elem = self.elem_process(elem, i)

            for j in range(count):
                elem[f"quest_{j + 1}"] = f"{question[j][0]}"
                elem[f"ans_{j + 1}"] = f"{answer[0][0]}"
                del answer[0]
            if row[6]:
                source['check'] = 1
                if geom_type == 'point':
                    source['result']["features"].append({"type": "Feature", "properties": elem,
                                                         "geometry": {"type": "Point",
                                                                      "coordinates": self.point(row[6])}})
                elif geom_type == 'polygon':
                    source['result']["features"].append({"type": "Feature", "properties": elem,
                                                         "geometry": {"type": "MultiPolygon",
                                                                      "coordinates": [[self.polygon(row[6])]]}})
        return source
From all data collected by all users under a survey
           create a GeoJson using the template. Return it either
           for point(s) or polygon(s).
From all data collected by all users under a survey
create a GeoJson using the template.
From all data collected by all users under a survey create a GeoJson using the template .
def gjson(self, geom_type, survey, question, answer, count):
        source = {'result': {"type": "FeatureCollection", "name": "Places",
                  "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:OGC:1.3:CRS84"}}, "features": []},
                  'check': 0}
        cursor.execute(f"select id, user_name, survey, entr_time, photo, video, st_astext({geom_type})"
                       f" from {self.db}features where survey = {survey} and ans_check = 1 order by id")
        fetched = cursor.fetchall()
        for i in range(len(fetched)):
            row = fetched[i]
            elem = {"id": row[0], "user_name": f"{row[1]}", "survey": f"{row[2]}", "entr_time": f"{row[3]}",
                    "photo": f"{row[4]}", "video": f"{row[5]}"}
            if self.db == 'test_':
                elem = self.elem_process(elem, i)
            for j in range(count):
                elem[f"quest_{j + 1}"] = f"{question[j][0]}"
                elem[f"ans_{j + 1}"] = f"{answer[0][0]}"
                del answer[0]
            if row[6]:
                source['check'] = 1
                if geom_type == 'point':
                    source['result']["features"].append({"type": "Feature", "properties": elem,
                                                         "geometry": {"type": "Point",
                                                                      "coordinates": self.point(row[6])}})
                elif geom_type == 'polygon':
                    source['result']["features"].append({"type": "Feature", "properties": elem,
                                                         "geometry": {"type": "MultiPolygon",
                                                                      "coordinates": [[self.polygon(row[6])]]}})
        return source
def gjson ( self , geom_type , survey , question , answer , count ) : source = { 'result' : { "type" : "FeatureCollection" , "name" : "Places" , "crs" : { "type" : "name" , "properties" : { "name" : "urn:ogc:def:crs:OGC:1.3:CRS84" } } , "features" : [ ] } , 'check' : 0 } cursor . execute ( f"select id, user_name, survey, entr_time, photo, video, st_astext({geom_type})" f" from {self.db}features where survey = {survey} and ans_check = 1 order by id" ) fetched = cursor . fetchall ( ) for i in range ( len ( fetched ) ) : row = fetched [ i ] elem = { "id" : row [ 0 ] , "user_name" : f"{row[1]}" , "survey" : f"{row[2]}" , "entr_time" : f"{row[3]}" , "photo" : f"{row[4]}" , "video" : f"{row[5]}" } if self . db == 'test_' : elem = self . elem_process ( elem , i ) for j in range ( count ) : elem [ f"quest_{j + 1}" ] = f"{question[j][0]}" elem [ f"ans_{j + 1}" ] = f"{answer[0][0]}" del answer [ 0 ] if row [ 6 ] : source [ 'check' ] = 1 if geom_type == 'point' : source [ 'result' ] [ "features" ] . append ( { "type" : "Feature" , "properties" : elem , "geometry" : { "type" : "Point" , "coordinates" : self . point ( row [ 6 ] ) } } ) elif geom_type == 'polygon' : source [ 'result' ] [ "features" ] . append ( { "type" : "Feature" , "properties" : elem , "geometry" : { "type" : "MultiPolygon" , "coordinates" : [ [ self . polygon ( row [ 6 ] ) ] ] } } ) return source
From all data collected by all users under a survey
create a GeoJson using the template.
From all data collected by all users under a survey create a GeoJson using the template .
"""From all data collected by all users under a survey
           create a GeoJson using the template. Return it either
           for point(s) or polygon(s).""" # Assigning the pre-set IDs in the test mode
self
geom_type
survey
question
answer
count