Ejemplo n.º 1
0
def save_neighborhoods(business_id, hood_jarray):
    for hood in hood_jarray:
        neighborhood = Neighborhood()
        neighborhood.business_id = business_id
        neighborhood.neighborhood_name = hood
        try:
            neighborhood.save()
        except InternalError:
            print "i dont care"
            pass
Ejemplo n.º 2
0
def add_neighborhood():
    data = request.json
    name = data['name']
    geom = data['geom']
    if geom:
        db.session.execute("delete from essex_neighborhood where name='%(name)s'" % data)
        for feature in geom['features']:
            coordinates = feature['geometry']['coordinates'][0]
            s = ', '.join([' '.join(map(str, cor)) for cor in coordinates])
            db.session.add(Neighborhood(feature['id'], name, 'SRID={};POLYGON(({}))'.format(4326, s)))
        db.session.commit()
        neighs, colors = getNeighborhoodFeatureCollection(name)
        return jsonify(neighs)
    return "OK"
Ejemplo n.º 3
0
def add_neighborhood():
    for item in neighborhoods:
        neighborhood = Neighborhood(name=item['Neighborhood'],
                                    zip_code=item['Zip'])
        session.add(neighborhood)
        session.commit()
def save_neighborhoods(business_id, hood_jarray):
    for hood in hood_jarray:
        neighborhood = Neighborhood()
        neighborhood.business_id = business_id
        neighborhood.neighborhood_name = hood
        neighborhood.save()