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 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"
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
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()
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()