-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpatialDB.py
More file actions
26 lines (21 loc) · 900 Bytes
/
SpatialDB.py
File metadata and controls
26 lines (21 loc) · 900 Bytes
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
"""
class to handle interaction with spatial DB
"""
from PostGIS import *
class SpatialDB():
def __init__(self, KBobj, args):
self.KB = KBobj
self.db_user = os.environ['USER']
self.dbname = args.dbname
def db_session(self): # Things we do offline for all images at once
# Open connection to PostGRE SQL DB
self.connection, self.cursor = connect_DB(self.db_user,self.dbname)
if self.connection is not None:
# Load knowledge base
self.KB = self.KB.load_data(self)
# Create 3D spatial abstractions for objects in map and update spatial table
self.ids_tbprocessed = create_boxes(self) # done once for all objects
# Commit all changes to DB
self.connection.commit()
# Close connection, to avoid db issues
disconnect_DB(self.connection, self.cursor)