Ejemplo n.º 1
0
 def get(self):
     self.response.out.write('hello<br/>')
     brom = Neighborhood.gql("WHERE name = :1", "b_woods").get()
     card = Neighborhood.gql("WHERE name = :1", "card").get()
     distance = geomath.distance(brom.location,
                                 card.location) * 0.000621371192
     self.response.out.write("%.2f miles" % distance)
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 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.º 4
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()
Ejemplo n.º 6
0
 def get(self):
     self.response.out.write('hello<br/>')
     brom = Neighborhood.gql("WHERE name = :1", "b_woods").get()
     card = Neighborhood.gql("WHERE name = :1", "card").get()
     distance = geomath.distance(brom.location, card.location) * 0.000621371192
     self.response.out.write("%.2f miles" % distance)
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()