예제 #1
0
    def reverse_way_by_id(self, wid):
        sql = "select id, source, target, x1, y1, x2, y2, st_astext(geom_way) as geom from " + self.tbname + " where id = %s"
        self.cursor.execute(sql, (wid, ))
        row = self.cursor.fetchone()
        t = int(row['source'])
        s = int(row['target'])
        x2 = float(row['x1'])
        y2 = float(row['y1'])
        x1 = float(row['x2'])
        y1 = float(row['y2'])
        geom = row['geom']
        lonlats = list(cg.geom2lonlats(geom))
        lonlats.reverse()
        geom = cg.lonlats2geom(lonlats)

        print geom
        sql = "update " + self.tbname + " set (source, target, x1, y1, x2, y2, geom_way) = (%s,%s,%s,%s,%s,%s,st_geomfromtext(%s,%s)) where id = %s"
        self.cursor.execute(sql, (s, t, x1, y1, x2, y2, geom, 4326, wid))
        self.conn.commit()
예제 #2
0
 def reverse_way_by_id(self, wid):
     sql = "select id, source, target, x1, y1, x2, y2, st_astext(geom_way) as geom from " + self.tbname + " where id = %s"
     self.cursor.execute(sql, (wid,))
     row = self.cursor.fetchone()
     t = int(row['source'])
     s = int(row['target'])
     x2 = float(row['x1'])
     y2 = float(row['y1'])
     x1 = float(row['x2'])
     y1 = float(row['y2'])
     geom = row['geom']
     lonlats = list(cg.geom2lonlats(geom))
     lonlats.reverse()
     geom = cg.lonlats2geom(lonlats)
    
     print geom
     sql = "update " + self.tbname + " set (source, target, x1, y1, x2, y2, geom_way) = (%s,%s,%s,%s,%s,%s,st_geomfromtext(%s,%s)) where id = %s"
     self.cursor.execute(sql, (s,t,x1,y1,x2,y2,geom,4326,wid))
     self.conn.commit()
예제 #3
0
 def get_geom(self):
     lonlats = [rd['gps_lonlat'] for rd in self.rds]
     return cg.lonlats2geom(lonlats)
예제 #4
0
 def as_geom(self):
     return cg.lonlats2geom(self.get_lonlats())