Exemplo n.º 1
0
 def submit(self, table_name, form_obj, id):
     db = self.db
     r = Recorder(db, table_name)
     updated = True
     if id:
         result_msg = r.update(id, form_obj)
         form_obj['id'] = id
     else:
         result_msg = r.input(form_obj)
         updated = False
         form_obj['id'] = r.get_last_id()
     self.submitted.emit(updated, table_name, form_obj)
     return result_msg
Exemplo n.º 2
0
    def insertPolygon(self, geometry):
        
        # Convert geometry
        wktGeom = geometry.exportToWkt()
        # To force 2D geometry
        if len(wktGeom.split('Z')) > 1:
            wktGeom = wktGeom.split('Z')[0] + wktGeom.split('Z')[1]
            wktGeom = wktGeom.replace(" 0,", ",")
            wktGeom = wktGeom.replace(" 0)", ")")
        geom = "GeomFromText('"
        geom += wktGeom
        geom += "', 2154)"

        geomObj = {}
        geomObj['the_geom'] = geom
        
        db = DbManager(CarhabLayerRegistry.instance().getCurrentCarhabLayer().dbPath)
        
        r = Recorder(db, 'polygon')
        r.input(geomObj)
        
        db.commit()
        db.close()