-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualizer.py
36 lines (26 loc) · 935 Bytes
/
visualizer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import matplotlib.pyplot as plt
from postgis_connection import PostgisInterface
from shapely import wkb
def walls():
query = 'select ST_points(ST_force2d(surface)) from walls1'
return query
def centroid():
query = 'select st_centroid(st_orientedEnvelope(projection_2d)) ' \
'from semantic_map ' \
'where st_centroid(st_orientedEnvelope(projection_2d)) IS NOT NULL '
return query
if __name__ == '__main__':
db_interface = PostgisInterface()
db_interface.connect_db('gianluca', 'gis_database')
counter = 0
records = db_interface.query_db(walls())
for r in records:
mp = wkb.loads(r[0], hex=True)
x1, y1 = [mp[0].x, mp[1].x], [mp[0].y, mp[1].y]
plt.plot(x1, y1)
records = db_interface.query_db(centroid())
for r in records:
mp = wkb.loads(r[0], hex=True)
plt.plot(mp.x, mp.y, 'r+')
plt.axis('scaled')
plt.show()