Exemplo n.º 1
0
 def connect(self, connection_string=None):
     """Used in code to connect using last self.strcon"""
     if connection_string == None:
         s = self.connection_string()
     else:
         s = connection_string
     try:
         self._con = DictConnection(s)
         self.init = datetime.now()
         self._active = True
     except OperationalError as e:
         self._active = False
         print('Unable to connect: {}'.format(e))
Exemplo n.º 2
0
 def connect(self, connection_string=None):
     if connection_string==None:
         s=self.connection_string()
     else:
         s=connection_string
     try:
         self._con=DictConnection(s)
         self.init=datetime.now()
         self._active=True
         return True
     except OperationalError as e:
         self._active=False
         print('Unable to connect: {}'.format(e))
         print('Connection string used: {}'.format(s))
         return False
Exemplo n.º 3
0
from shapely.geometry.collection import GeometryCollection
from shapely.wkb import loads, dumps
from shapely.ops import cascaded_union, polygonize_full
from shapely.affinity import translate

from pyproj import Proj

from flask import Flask, abort, make_response
app = Flask(__name__)

# load configuration
with open('config.json', 'r') as fp:
    config = json.load(fp)

# create DB connection
db = DictConnection(config['db'])


# serve index.html on main route, yeah I know this is ugly
@app.route("/")
def index():
    with open('static/html/index.html', 'r') as fp:
        return fp.read()


# serve street geometry (WKB)
@app.route("/streets/<float:x1>/<float:y1>/<float:x2>/<float:y2>")
def render_streets(x1, y1, x2, y2):
    cursor = db.cursor()

    # types of roads to load and their width in meters