def setUp(self): "Clear tables" # Logout self.app.get(url("person_logout")) # Delete all people Session.rollback() Session.query(model.Person).delete() Session.query(model.PersonCandidate).delete() Session.commit()
def setUp(self): 'Clear tables' # Logout self.app.get(url('person_logout')) # Delete all people Session.rollback() Session.query(model.Person).delete() Session.query(model.PersonCandidate).delete() Session.commit()
if simplified: # If a bounding box is specified, if bbox: # Convert bounding box to a metric coordinate system try: multiPoint = shapely.wkb.loads( str( Session.execute( geoalchemy.functions.wkb( geoalchemy.functions.transform( geoalchemy.WKTSpatialElement( 'MULTIPOINT(%s %s, %s %s)' % (minY, minX, maxY, maxX), srid), 3857))).fetchone()[0])) except sa.exc.InternalError: Session.rollback() y1, x1, y2, x2 = -20037508.34, -20037508.34, 20037508.34, 20037508.34 else: y1, x1 = multiPoint.geoms[0].coords[0] y2, x2 = multiPoint.geoms[1].coords[0] metersPerPixel = min(abs(x2 - x1), abs(y2 - y1)) / 256. # If a bounding box is not specified, else: metersPerPixel = 0.2 # Define transformation in a metric coordinate system simplify = lambda x: sa.func.ST_SimplifyPreserveTopology( geoalchemy.functions.transform(x, 3857), metersPerPixel) # If simplification is not desired, else: simplify = lambda x: x # Prepare query
restrict = lambda x: x # Load simplified simplified = request.params.get('simplified', 1) try: simplified = int(simplified) except ValueError: abort(400, 'Could not parse simplified=%s as an integer' % simplified) # If simplification is desired, if simplified: # If a bounding box is specified, if bbox: # Convert bounding box to a metric coordinate system try: multiPoint = shapely.wkb.loads(str(Session.execute(geoalchemy.functions.wkb(geoalchemy.functions.transform(geoalchemy.WKTSpatialElement('MULTIPOINT(%s %s, %s %s)' % (minY, minX, maxY, maxX), srid), 3857))).fetchone()[0])) except sa.exc.InternalError: Session.rollback() y1, x1, y2, x2 = -20037508.34, -20037508.34, 20037508.34, 20037508.34 else: y1, x1 = multiPoint.geoms[0].coords[0] y2, x2 = multiPoint.geoms[1].coords[0] metersPerPixel = min(abs(x2 - x1), abs(y2 - y1)) / 256. # If a bounding box is not specified, else: metersPerPixel = 0.2 # Define transformation in a metric coordinate system simplify = lambda x: sa.func.ST_SimplifyPreserveTopology(geoalchemy.functions.transform(x, 3857), metersPerPixel) # If simplification is not desired, else: simplify = lambda x: x # Prepare query featureQuery = restrict(Session.query(model.Feature.id, geoalchemy.functions.wkb(geoalchemy.functions.transform(simplify(model.Feature.geometry), srid)), model.Feature.properties).join(model.Feature.tags).filter(model.Tag.id.in_([x.id for x in tags])).filter(model.getFeatureFilter(personID)))