Esempio n. 1
0
def add_building(jwt):
    body = request.get_json()
    ownerID = body.get('ownerID')
    name = body.get('name')
    address = body.get('address')
    description = body.get('description')
    number_of_units = body.get('number_of_units')
    building_image = body.get('building_image')

    if not ('ownerID' in body and 'name' in body and 'address' in body
            and 'description' in body and 'number_of_units' in body):
        abort(422)
    try:
        new_building = Building(ownerID=ownerID,
                                name=name,
                                address=address,
                                description=description,
                                number_of_units=number_of_units,
                                building_image=building_image)
        new_building.insert()
        return jsonify({
            'success': True,
            'created': [new_building.show()],
        })
    except Exception:
        abort(422)
Esempio n. 2
0
 def post(self, uuid):
     landlord = Landlord()
     landlord.uuid = uuid1().get_hex()
     landlord.building_uuid = uuid
     landlord.cell = self.request.get('cell')
     landlord.email = self.request.get('email')
     landlord.contact_phone = self.request.get('contact_phone')
     landlord.contact_person = self.request.get('contact_person')
     landlord.budget = int(self.request.get('budget'))
     unconverted_date = self.request.get('kurcina')
     converted_date = datetime.strptime(unconverted_date, '%d-%m-%Y')
     landlord.last_contact = converted_date
     users.get_current_user()
     user = self.user_info
     landlord.brokers_name = user.get('user_name')
     user_id = user.get('user_id')
     landlord.user = ndb.Key(User, user_id)
     buildingz = Building.query(Building.uuid == uuid).get()
     building_id = buildingz.key.id()
     landlord.building = ndb.Key(Building, building_id)
     marcipan = landlord.put()
     time.sleep(2)
     kurcina = marcipan.id()
     mrgud = ndb.Key(Landlord, kurcina)
     buildingz.landlord = mrgud
     buildingz.last_updated = datetime.now()
     buildingz.put()
     time.sleep(2)
     self.redirect('/landlords')
Esempio n. 3
0
    def get(self):
        user = self.user_info
        real_user_id = user.get('user_id')
        key = ndb.Key(User, real_user_id)
        q = Building.query(Building.user == key)
        buildings = q.fetch()
        kurac = []
        for building in buildings:
            #print building.tenants
            kurac.append(len(building.tenants))
            print kurac
        #print buildings

        print len(kurac)
        print kurac
        admin = user.get('isAdmin')
        if admin is True:
            template_values = {
                'kurac': kurac,
                'buildings': buildings,
                'user': user,
                'admin': admin,
            }
        else:
            template_values = {
                'kurac': kurac,
                'buildings': buildings,
                'user': user,
            }

        path = os.path.join(os.path.dirname(__file__), 'templates/view-buildings-list.html')
        self.response.write(template.render(path, template_values))
Esempio n. 4
0
    def get(self):
        user = self.user_info
        real_user_id = user.get('user_id')
        q = Building.query()
        buildings = q.fetch()
        some_json = []
        for building in buildings:
            some_json.append(OrderedDict([('lat', float(building.lat)), ('lng', float(building.lng)), ('content', building.uuid)]))
        mirakuru = json.dumps(some_json)
        admin = user.get('isAdmin')
        if admin is True:
            template_values = {
                'buildings': buildings,
                'mirakuru': mirakuru,
                'user': user,
                'admin': admin,
            }
        else:
            template_values = {
                'buildings': buildings,
                'mirakuru': mirakuru,
                'user': user,
            }

        path = os.path.join(os.path.dirname(__file__), 'templates/view-buildings.html')
        self.response.write(template.render(path, template_values))
Esempio n. 5
0
    def post(self, uuid):

        tenant = Tenant()
        tenant.uuid = uuid1().get_hex()
        tenant.tenant_name = self.request.get('tenant_name')
        tenant.address = self.request.get('address')
        tenant.cell = self.request.get('cell')
        tenant.email = self.request.get('email')
        tenant.contact_person = self.request.get('contact_person')
        tenant.contact_phone = self.request.get('contact_phone')
        unconverted_date = self.request.get('kurcina')
        converted_date = datetime.strptime(unconverted_date, '%d-%m-%Y')
        tenant.lease_expire = converted_date
        users.get_current_user()
        user = self.user_info
        tenant.brokers_name = user.get('user_name')
        user_id = user.get('user_id')
        tenant.user = ndb.Key(User, user_id)
        tenant.building_uuid = uuid
        building = Building.query(Building.uuid == uuid).get()
        building_id = building.key.id()
        tenant.building = ndb.Key(Building, building_id)
        marcipan = tenant.put()
        time.sleep(2)
        kurcina = marcipan.id()
        mrgud = ndb.Key(Tenant, kurcina)
        building.tenants.append(mrgud)
        building.last_updated = datetime.now()
        building.put()
        time.sleep(2)
        self.redirect('/viewtenants/' + uuid)
    def test_admin_delete_building(self):
        building = Building(address="Alyasmin",
                            description="3 floors building",
                            name="Tlal",
                            number_of_units=9,
                            ownerID=1234567890,
                            building_image="https://dangerwordfilm.files.\
                wordpress.com/2014/04/coming-soon.png")
        building.insert()
        building_id = building.id

        self.headers.update({'Authorization': 'Bearer ' + str(admin_token)})
        res = self.client.delete(f'/buildings/\
            {building_id}',
                                 headers=self.headers)
        data = json.loads(res.data)
        self.assertEqual(res.status_code, 200)
Esempio n. 7
0
def building():
    conditioned_floor_area = 100
    return Building(heat_mass_capacity=165000 * conditioned_floor_area,
                    heat_transmission=200,
                    maximum_cooling_power=float("-inf"),
                    maximum_heating_power=float("inf"),
                    initial_building_temperature=22,
                    time_step_size=timedelta(hours=1),
                    conditioned_floor_area=conditioned_floor_area)
Esempio n. 8
0
def fully_damped_building():
    conditioned_floor_area = 1
    return Building(heat_mass_capacity=3600 * conditioned_floor_area,
                    heat_transmission=0,
                    maximum_cooling_power=-1,
                    maximum_heating_power=1,
                    initial_building_temperature=22,
                    time_step_size=timedelta(hours=1),
                    conditioned_floor_area=conditioned_floor_area)
Esempio n. 9
0
def test_maximum_cooling_power_cannot_be_positive():
    with pytest.raises(ValueError):
        conditioned_floor_area = 100
        Building(heat_mass_capacity=165000 * conditioned_floor_area,
                 heat_transmission=200,
                 maximum_cooling_power=0.01,
                 maximum_heating_power=float("inf"),
                 initial_building_temperature=22,
                 time_step_size=timedelta(hours=1),
                 conditioned_floor_area=conditioned_floor_area)
Esempio n. 10
0
    def get(self, uuid):
        tenant = Tenant.query(Tenant.uuid == uuid).get()
        tenant_id = tenant.key.id()
        tenant_key = ndb.Key(Tenant, tenant_id)
        building_tenant = Building.query(Building.tenants == tenant_key).get()
        if tenant:
            tenant.key.delete()
            building_tenant.tenants.remove(tenant_key)
            building_tenant.put()

            self.redirect('/tenants')
        else:
            self.abort(404)
Esempio n. 11
0
    def get(self, uuid):
        landlord = Landlord.query(Landlord.uuid == uuid).get()
        landlord_id = landlord.key.id()
        landlord_key = ndb.Key(Landlord, landlord_id)
        building_landlord = Building.query(Building.tenants == landlord_key).get()

        if landlord:
            landlord.key.delete()
            building_landlord.landlord.remove(landlord_key)
            building_landlord.put()
            self.redirect('/landlords')
        else:
            self.abort(404)
Esempio n. 12
0
class BuildingService(object):

    collection = Building._get_collection()

    def create_building(self, name):
        building = {Building.NAME: name, Building.DOMAINS: []}
        self.collection.insert(building)

    def remove_building(self, name):
        self.collection.remove({Building.NAME: name})

    def retrieve_building(self, name):
        self.collection.find_one({Building.NAME: name}, {'_id': 0})
Esempio n. 13
0
 def post(self, uuid):
     landlord = Landlord.query(Landlord.uuid == uuid).get()
     building = Building.query(Building.user == landlord.key()).get()
     building.last_updated = datetime.now()
     building.put()
     landlord.budget = int(self.request.get('budget'))
     landlord.cell = self.request.get('cell')
     landlord.email = self.request.get('email')
     landlord.contact_phone = self.request.get('contact_phone')
     landlord.contact_person = self.request.get('contact_person')
     unconverted_date = self.request.get('kurcina')
     if unconverted_date:
         converted_date = datetime.strptime(unconverted_date, '%d-%m-%Y')
         landlord.last_contact = converted_date
     landlord.put()
     self.redirect('/landlord')
Esempio n. 14
0
 def get(self, uuid):
     user = self.user_info
     admin = user.get('isAdmin')
     building = Building.query(Building.uuid == uuid).get()
     if admin is True:
         template_values = {
             'building': building,
             'user': user,
             'admin': admin,
         }
     else:
         template_values = {
             'building': building,
             'user': user,
         }
     path = os.path.join(os.path.dirname(__file__), 'templates/add-landlord.html')
     self.response.write(template.render(path, template_values))
Esempio n. 15
0
 def get(self, uuid):
     building = Building.query(Building.uuid == uuid).get()
     tenant = Tenant.query(Tenant.building_uuid == uuid).get()
     landlord = Landlord.query(Landlord.building_uuid == uuid).get()
     if building:
         building.key.delete()
         if tenant:
             tenant.key.delete()
         else:
             self.redirect("/viewbuildings-list")
         if landlord:
             landlord.key.delete()
         else:
             self.redirect("/viewbuildings-list")
         self.redirect("/viewbuildings-list")
     else:
         self.abort(403)
Esempio n. 16
0
 def post(self, uuid):
     note = LandlordNote()
     landlord = Landlord.query(Landlord.uuid == uuid).get()
     landlord_id = landlord.key.id()
     building = Building.query(Building.user == landlord.key()).get()
     building.last_updated = datetime.now()
     building.put()
     note.landlord = ndb.Key(Landlord, landlord_id)
     note.landlord_uuid = uuid
     note.text = self.request.get('description')
     real_note = note.put()
     real_note_key = real_note.id()
     idzor = real_note_key
     mrav = ndb.Key(LandlordNote, idzor)
     landlord.notes.append(mrav)
     landlord.put()
     self.redirect('/landlords')
Esempio n. 17
0
 def get(self, uuid):
     user = self.user_info
     admin = user.get('isAdmin')
     files = Landlord.query(Landlord.building_uuid == uuid)
     building = Building.query(Building.uuid == uuid).get()
     landlords = files.order(-Landlord.contact_person).fetch()
     if admin is True:
         template_values = {
             'user': user,
             'building': building,
             'landlords': landlords,
             'admin': admin,
         }
     else:
         template_values = {
             'user': user,
             'building': building,
             'landlords': landlords,
         }
     path = os.path.join(os.path.dirname(__file__), 'templates/l-dashboard-2.html')
     self.response.write(template.render(path, template_values))
Esempio n. 18
0
def add_building():
    session_db = Session()
    flats = session_db.query(Flat).all()
    for flat in flats:
        query = session_db.query(Building)\
            .filter(Building.address.in_([flat.street]))\
            .filter(Building.latitude.in_([flat.latitude]))\
            .filter(Building.longitude.in_([flat.longitude]))
        if not session_db.query(query.exists()).scalar():
            try:
                building = Building(
                    address=flat.street,
                    longitude=flat.longitude,
                    latitude=flat.latitude,
                    count_floor=int(flat.floor[flat.floor.index('/')+1:]),
                    year_build=flat.year_build
                )
                session_db.add(building)
            except:
                print('ex')

    session_db.commit()
Esempio n. 19
0
def open_building():
    building = Building(elevators=6, floors=20)

    # randomly add people into building for simulation
    people = 11
    for person in range(0, people):
        location = randint(0, building.floor_count - 1)
        destination_options = [
            x for x in range(0, building.floor_count) if x != location
        ]
        destination = choice(destination_options)

        building.add_person(location, destination)

    for person in building.people:
        building.deploy_elevator(person)
        time.sleep(.5)
Esempio n. 20
0
    def get(self, uuid):
        user = self.user_info
        building = Building.query(Building.uuid == uuid).get()
        serve_me = images.get_serving_url(building.picture, size=None, crop=False, secure_url=None)
        tenants = []
        if building.tenants:
            for tenant in building.tenants:
                kurac = tenant.id()
                tenant = Tenant.get_by_id(kurac)
                tenants.append(tenant)
        else:
            tenant = None

        if building.landlord:
            smajser = building.landlord.id()
            landlord = Landlord.get_by_id(smajser)
        else:
            landlord = None
        admin = user.get('isAdmin')
        if admin is True:
            template_values = {
                'landlord': landlord,
                'serve_me': serve_me,
                'building': building,
                'user': user,
                'admin': admin,
                'tenants': tenants,
            }
        else:
            template_values = {
                'landlord': landlord,
                'serve_me': serve_me,
                'building': building,
                'user': user,
            }

        path = os.path.join(os.path.dirname(__file__), 'templates/view-building.html')
        self.response.write(template.render(path, template_values))
Esempio n. 21
0
 def get(self, uuid):
     user = self.user_info
     admin = user.get('isAdmin')
     files = Tenant.query(Tenant.building_uuid == uuid)
     building = Building.query(Building.uuid == uuid).get()
     tenants = files.order(-Tenant.contact_person).fetch()
     if admin is True:
         template_values = {
             #'list_list': list_list,
             'user': user,
             'building': building,
             'tenants': tenants,
             'admin': admin,
         }
     else:
         template_values = {
             #'list_list': list_list,
             'user': user,
             'building': building,
             'tenants': tenants,
         }
     path = os.path.join(os.path.dirname(__file__), 'templates/dashboard-2.html')
     self.response.write(template.render(path, template_values))
Esempio n. 22
0
    def post(self, uuid):
        user = self.user_info
        print user
        user_uuid = user.get('uuid')
        user_object = User.query(User.uuid == user_uuid).get()
        real_key = user_object.key.id()
        real_user_key = ndb.Key(User, real_key)
        building = Building.query(Building.user == real_user_key).get()
        building.last_updated = datetime.now()
        building.put()

        note = TenantNote()
        tenant = Tenant.query(Tenant.uuid == uuid).get()
        tenant_id = tenant.key.id()
        note.tenant = ndb.Key(Tenant, tenant_id)
        note.tenant_uuid = uuid
        note.text = self.request.get('description')
        real_note = note.put()
        real_note_key = real_note.id()
        idzor = real_note_key
        mrav = ndb.Key(TenantNote, idzor)
        tenant.notes.append(mrav)
        tenant.put()
        self.redirect('/tenants')
Esempio n. 23
0
def get_building_with_specs(user_id, building_type, specs):
    return Building(user_id=user_id,
                    building_type=building_type,
                    storage_capacity=specs.get('initial_capacity', 0),
                    production_capacity=specs.get('initial_production', 0))
Esempio n. 24
0
def _create_building(sess, user_id, building_type):
    new_building = Building(user_id=user_id, building_type=building_type)
    sess.add(new_building)
    sess.flush()
    result = new_building.id
    return result
Esempio n. 25
0
 def add_building(session, building_url):
     new_building = Building(url=building_url)
     session.add(new_building)
     return new_building
Esempio n. 26
0
    def createBuilding(self, building):
        db.begin()
        try:
            Building(name=building.get("name")).save()
            if building.get("floors") is not None:
                for floor in building.get("floors"):
                    Floor(level=floor.get("level"),
                          buildingName=building.get("name")).save()

                    if floor.get("waypoints") is not None:
                        for waypoint in floor.get("waypoints"):
                            if ("type" in waypoint):
                                if (waypoint.get("type") ==
                                        WAYPOINT_TYPES["ClassRoom"]):
                                    classRoom = ClassRoom(
                                        name=waypoint.get("name"),
                                        markerId=waypoint.get("markerId"),
                                        buildingName=building.get("name"),
                                        floorLevel=floor.get("level"),
                                        shapeType=waypoint.get("shapeType"),
                                        color=waypoint.get("color"),
                                        width=waypoint.get("width"),
                                        length=waypoint.get("length"),
                                        x=waypoint.get("x"),
                                        y=waypoint.get("y")).save()
                                    for schedule in waypoint["schedule"]:
                                        group = Group.nodes.get_or_none(
                                            name=schedule["group"],
                                            buildingName=building.get("name"))
                                        if group is None:
                                            group = Group(
                                                name=schedule["group"],
                                                buildingName=building.get(
                                                    "name")).save()
                                        group.classes.connect(
                                            classRoom, {
                                                'course':
                                                schedule["course"],
                                                'dayOfWeek':
                                                schedule["dayOfWeek"],
                                                'startTime':
                                                schedule["startTime"],
                                                'finishTime':
                                                schedule["finishTime"]
                                            })
                                elif (waypoint.get("type") ==
                                      WAYPOINT_TYPES["Office"]):
                                    office = Office(
                                        name=waypoint.get("name"),
                                        markerId=waypoint.get("markerId"),
                                        buildingName=building.get("name"),
                                        floorLevel=floor.get("level"),
                                        shapeType=waypoint.get("shapeType"),
                                        color=waypoint.get("color"),
                                        width=waypoint.get("width"),
                                        length=waypoint.get("length"),
                                        x=waypoint.get("x"),
                                        y=waypoint.get("y")).save()
                                    for prof in waypoint["professors"]:
                                        teacher = Teacher.nodes.get_or_none(
                                            name=prof,
                                            buildingName=building.get("name"))
                                        if teacher is None:
                                            teacher = Teacher(
                                                name=prof,
                                                buildingName=building.get(
                                                    "name")).save()
                                        teacher.office.connect(office)
                                elif (waypoint.get("type") ==
                                      WAYPOINT_TYPES["Connector"]):
                                    Connector(
                                        name=waypoint.get("name"),
                                        markerId=waypoint.get("markerId"),
                                        buildingName=building.get("name"),
                                        floorLevel=floor.get("level"),
                                        shapeType=waypoint.get("shapeType"),
                                        color=waypoint.get("color"),
                                        width=waypoint.get("width"),
                                        length=waypoint.get("length"),
                                        x=waypoint.get("x"),
                                        y=waypoint.get("y")).save()
                                else:
                                    Waypoint(
                                        name=waypoint.get("name"),
                                        markerId=waypoint.get("markerId"),
                                        buildingName=building.get("name"),
                                        floorLevel=floor.get("level"),
                                        shapeType=waypoint.get("shapeType"),
                                        color=waypoint.get("color"),
                                        width=waypoint.get("width"),
                                        length=waypoint.get("length"),
                                        x=waypoint.get("x"),
                                        y=waypoint.get("y")).save()
                            else:
                                Waypoint(name=waypoint.get("name"),
                                         markerId=waypoint.get("markerId"),
                                         buildingName=building.get("name"),
                                         floorLevel=floor.get("level"),
                                         shapeType=waypoint.get("shapeType"),
                                         color=waypoint.get("color"),
                                         width=waypoint.get("width"),
                                         length=waypoint.get("length"),
                                         x=waypoint.get("x"),
                                         y=waypoint.get("y")).save()

                    if floor.get("hallways") is not None:
                        for hallway in floor.get("hallways"):
                            Hallway(name=hallway["name"],
                                    markerId=hallway["markerId"],
                                    buildingName=building.get("name"),
                                    floorLevel=floor.get("level"),
                                    shapeType=hallway["shapeType"],
                                    color=hallway["color"],
                                    width=hallway["width"],
                                    length=hallway["length"],
                                    x=hallway["x"],
                                    y=hallway["y"]).save()

                if building.get("floors") is not None:
                    for floor in building.get("floors"):
                        if floor.get("waypoints") is not None:
                            for waypoint in floor.get("waypoints"):
                                base = Waypoint.nodes.get(
                                    name=waypoint.get("name"),
                                    floorLevel=floor.get("level"),
                                    buildingName=building.get("name"))
                                for neighbor in waypoint["neighbors"]:
                                    base.neighbors.connect(
                                        Waypoint.nodes.get(
                                            name=neighbor.get("name"),
                                            floorLevel=floor.get("level"),
                                            buildingName=building.get("name")),
                                        {
                                            'direction':
                                            neighbor.get("direction")
                                        })
            self.checkBuilding(building.get("name"))
            db.commit()
            return self.get(building.get("name")), 200
        except Exception as e:
            db.rollback()
            return str(e), 500
Esempio n. 27
0
async def addB(n, p):
    b = Building(name=n, parid=p)
    await b.save()
    return b
Esempio n. 28
0
	def post(self):
		user = users.get_current_user()
		if user:
			missedLectureCheck(user)
			#logging.info(self.request.body)
			data = json.loads(self.request.body)
			latitude = data["lat"]
			longitude = data["lon"]

			day = datetime.date.today().weekday()
			hour = datetime.datetime.now().hour
			minute = datetime.datetime.now().minute
			if minute > 45:
				hour = hour + 1

			thisLecture = None
			thisUser = None
			poly = []			

			userQuery = User.query(User.userid == user.user_id())
			for userEntity in userQuery:
				thisUser = userEntity
				for lecture in userEntity.lectures:
					#checks for a lecture that matches the current day and time
					if(lecture.day == day and (lecture.time <= hour and lecture.time + lecture.duration > hour)):
						thisLecture = lecture
						locations = lecture.location.split(";");
						for location in locations:
							#need to make multiple polys for each lecture, for each possible location
							buildingQuery = Building.query(Building.number == location)
							for building in buildingQuery:
								buildingCoords = []
								for coordinate in building.coordinates:
									c = (coordinate.lon, coordinate.lat)
									buildingCoords.append(c)
								poly.append(buildingCoords)

			noLecture = False
			checkedIn = False

			#checks if there is no current lecture
			if thisLecture is None:
				noLecture = True
				self.response.out.write(json.dumps({"valid":3}))
			else:
				#checks if the user has already checked in to this lecture
				for pastLecture in thisUser.history:
					if pastLecture.week == getCurrentWeek() and pastLecture.time == thisLecture.time and pastLecture.day == thisLecture.day:
						checkedIn = True
				if checkedIn:
					self.response.out.write(json.dumps({"valid":4}))	
			if not checkedIn and not noLecture:
				inBuilding = False
				for coords in poly:
					#checks user is at the correct location(s) for the lecture
					if not inBuilding and point_in_poly(longitude, latitude, coords):
						inBuilding = True

						attendedLecture = Lecture(module=thisLecture.module, title=thisLecture.title, location=thisLecture.location, day=thisLecture.day, time=thisLecture.time, duration=thisLecture.duration)

						attendedLecture.attended = True
						attendedLecture.week = getCurrentWeek()

						checkin = CheckIn(student=thisUser, lecture=attendedLecture)
						checkin.put()

						thisUser.history.append(attendedLecture)

						completedChalls = challengecheck(thisUser, attendedLecture, checkin)

						pointsEarned = 0
						
						challIcons = []
						challTitles = []
						challDescs = []
						challPoints = []

						for challenge in completedChalls:
							pointsEarned += challenge.points
							challTitles.append(challenge.title)
							challIcons.append(challenge.badge.iconName)
							challDescs.append(challenge.description)
							challPoints.append(challenge.points)

						thisUser.score = thisUser.score + 10 + thisUser.streak + pointsEarned
						thisUser.streak = thisUser.streak + 1
						thisUser.count = thisUser.count + 1

						thisUser.put()
						
						self.response.out.write(json.dumps({"valid":1, "score":thisUser.score, "count":thisUser.count, "streak":thisUser.streak, "icons":challIcons, "titles":challTitles, "points":challPoints, "descriptions":challDescs}))
				if not inBuilding: 
					self.response.out.write(json.dumps({"valid":2}))	
		else:
			self.redirect(users.create_login_url(self.request.uri))
Esempio n. 29
0
def loadBuildings():
    b2 = Building(
        number="2",
        coordinates=[
            ndb.GeoPt(50.935625, -1.399638),
            ndb.GeoPt(50.937450, -1.398635),
            ndb.GeoPt(50.936862, -1.395631),
            ndb.GeoPt(50.934408, -1.39561),
        ],
    )
    b2.put()

    b2a = Building(
        number="2a",
        coordinates=[
            ndb.GeoPt(50.936293, -1.398331),
            ndb.GeoPt(50.936932, -1.397786),
            ndb.GeoPt(50.936626, -1.396432),
            ndb.GeoPt(50.935791, -1.396821),
        ],
    )
    b2a.put()

    b5 = Building(
        number="5",
        coordinates=[
            ndb.GeoPt(50.935158, -1.396452),
            ndb.GeoPt(50.936392, -1.396039),
            ndb.GeoPt(50.936040, -1.393147),
            ndb.GeoPt(50.934556, -1.393732),
        ],
    )
    b5.put()

    b7 = Building(
        number="7",
        coordinates=[
            ndb.GeoPt(50.935205, -1.39605),
            ndb.GeoPt(50.936527, -1.39554),
            ndb.GeoPt(50.935888, -1.391554),
            ndb.GeoPt(50.934211, -1.392649),
        ],
    )
    b7.put()

    b13 = Building(
        number="13",
        coordinates=[
            ndb.GeoPt(50.935334, -1.395867),
            ndb.GeoPt(50.936727, -1.394987),
            ndb.GeoPt(50.935946, -1.391404),
            ndb.GeoPt(50.934370, -1.392198),
        ],
    )
    b13.put()

    b16 = Building(
        number="16",
        coordinates=[
            ndb.GeoPt(50.937261, -1.39708),
            ndb.GeoPt(50.938437, -1.396393),
            ndb.GeoPt(50.938119, -1.394167),
            ndb.GeoPt(50.936612, -1.394537),
        ],
    )
    b16.put()

    b27 = Building(
        number="27",
        coordinates=[
            ndb.GeoPt(50.933654, -1.39598),
            ndb.GeoPt(50.935286, -1.394408),
            ndb.GeoPt(50.934756, -1.391742),
            ndb.GeoPt(50.933282, -1.392488),
        ],
    )
    b27.put()

    b32 = Building(
        number="32",
        coordinates=[
            ndb.GeoPt(50.935929, -1.39642),
            ndb.GeoPt(50.937004, -1.396817),
            ndb.GeoPt(50.937014, -1.395524),
            ndb.GeoPt(50.935783, -1.395218),
        ],
    )
    b32.put()

    b34 = Building(
        number="34",
        coordinates=[
            ndb.GeoPt(50.934127, -1.397085),
            ndb.GeoPt(50.935344, -1.396092),
            ndb.GeoPt(50.934948, -1.393475),
            ndb.GeoPt(50.933427, -1.39443),
        ],
    )
    b34.put()

    b35 = Building(
        number="35",
        coordinates=[
            ndb.GeoPt(50.934685, -1.395358),
            ndb.GeoPt(50.934719, -1.395513),
            ndb.GeoPt(50.934299, -1.394059),
            ndb.GeoPt(50.933488, -1.394676),
        ],
    )
    b35.put()

    b58 = Building(
        number="58",
        coordinates=[
            ndb.GeoPt(50.936172, -1.40054),
            ndb.GeoPt(50.937592, -1.400003),
            ndb.GeoPt(50.937220, -1.396795),
            ndb.GeoPt(50.935314, -1.397391),
        ],
    )
    b58.put()

    b59 = Building(
        number="59",
        coordinates=[
            ndb.GeoPt(50.936764, -1.398464),
            ndb.GeoPt(50.937825, -1.398721),
            ndb.GeoPt(50.937866, -1.397026),
            ndb.GeoPt(50.936821, -1.396591),
        ],
    )
    b59.put()

    b67 = Building(
        number="67",
        coordinates=[
            ndb.GeoPt(50.935966, -1.397648),
            ndb.GeoPt(50.937322, -1.397863),
            ndb.GeoPt(50.937487, -1.395679),
            ndb.GeoPt(50.935956, -1.395014),
        ],
    )
    b67.put()
Esempio n. 30
0
    from filip.models.base import NgsiVersion

    header = InstanceHeader(cb_url=cb_url,
                            iota_url=iota_url,
                            ngsi_version=NgsiVersion.v2,
                            service="example",
                            service_path="/")

    my_floor = Floor(id="my-first-floor", header=header)

    # If we work with the often with the same header we can also set a
    # default header in the semantic_manager. If a class without a header
    # parameter is created it gets automatically assigned this default header.

    semantic_manager.set_default_header(header)
    my_building = Building(id="building1")

    # ## 2.2 Immutability
    #
    # These defining information of an instance are immutable and can not
    # be changed after the creation.
    # They are further bundled into an identifier object that is used as an
    # identity by the system: The InstanceIdentifier

    # We can have a look at this identifier, and see that the header was
    # correctly set:
    print("\u0332".join("Instance Identifier of my_building:"))
    print(my_building.get_identifier())
    print("")

    # ## 2.3 Device Classes
Esempio n. 31
0
def construct_building(building_type, inventory):
    check_if_enough_inventory_for_buildings('construct', building_type, inventory)
    inventory['steel'] -= Building.TYPES_COST[building_type]
    return Building(building_type)
Esempio n. 32
0
 def post(self):
     building = Building()
     building.name = self.request.get('name')
     building.suburb = self.request.get('suburb')
     building.address = self.request.get('address')
     address = self.request.get('address')
     new_address = address.replace(' ', '%20')
     url = "https://maps.googleapis.com/maps/api/geocode/json?address=%s" % new_address
     response = urlfetch.fetch(url)
     #response = urllib2.urlopen(url).read()
     jsongeocode = json.loads(response.content)
     places = json.dumps([s['place_id'] for s in jsongeocode['results']])
     place = places.strip('["]')
     building.place = place
     lat = json.dumps([s['geometry']['location']['lat'] for s in jsongeocode['results']])
     lng = json.dumps([s['geometry']['location']['lng'] for s in jsongeocode['results']])
     building.lat = lat.strip('[]')
     building.lng = lng.strip('[]')
     building.uuid = uuid1().get_hex()
     user = self.user_info
     building.brokers_name = user.get('user_name')
     user_id = user.get('user_id')
     building.user = ndb.Key(User, user_id)
     mars = str(building.uuid)
     upload_files = self.get_uploads('file')
     blob_info = upload_files[0]
     blob = blob_info.key()
     building.picture = blob
     time.sleep(2)
     building.put()
     self.redirect("/viewbuildings-list")
        return "Social Sciences and Media Studies"
    elif (abbrev == "TD-E"):
        return "Theater/Dance East"
    elif (abbrev == "TD-W"):
        return "Theater/Dance West"
    elif (abbrev == "WEBB"):
        return "Webb Hall/Geological Sciences Building"
    else:
        return abbrev


for building in scrape.getBuildingsOrdered():
    name = building.getName().rstrip()
    if (len(Building.query.filter_by(name=name).all()) == 0):
        print("Adding:", building.name)
        b = Building(name=name, full_name=get_pretty_name(name).strip())
        db.session.add(b)

db.session.commit()

for building in scrape.getBuildingsOrdered():
    b = Building.query.filter_by(name=building.getName().rstrip()).first()
    for room in building.getRooms2():

        if (not (room in b.rooms)):
            print("Adding:", room.number)
            r1 = Room(roomnumber=room.number.rstrip(), building_id=b.id)
            db.session.add(r1)

db.session.commit()
Esempio n. 34
0
def generate():
    buildings = [{
        'name': 'Unisinos',
        'geom':
        'POLYGON((-29.792974824703958 -51.158196330070496, -29.79401762517251 -51.15791738033295, -29.794669369947076 -51.1580353975296, -29.795432836998465 -51.1590975522995, -29.79611250398447 -51.15941941738129, -29.796624578801172 -51.1591511964798, -29.79744389305685 -51.157477498054504, -29.798402854629657 -51.156179308891296, -29.7985425084609 -51.15565359592438, -29.798346993042582 -51.15478456020355, -29.797350789502037 -51.153475642204285, -29.796959753625753 -51.152220368385315, -29.796820097585293 -51.15100800991058, -29.7963731969459 -51.15040719509125, -29.795814568339743 -51.150203347206116, -29.79454833195276 -51.15001022815704, -29.79401762517251 -51.15008533000946, -29.792686190511297 -51.1510294675827, -29.791550267216632 -51.15134060382843, -29.792974824703958 -51.158196330070496))',
        'stroke_color': '000000',
        'stroke_opacity': 0.8,
        'stroke_weight': 1,
        'fill_color': '000000',
        'fill_opacity': 0.4,
    }, {
        'name': 'Centro A',
        'geom':
        'POLYGON((-29.792974824703958 -51.158207058906555, -29.79248135283728 -51.15581452846527, -29.79398038248575 -51.155449748039246, -29.79402693584204 -51.154956221580505, -29.7943434980904 -51.15452706813812, -29.794883513732213 -51.154505610466, -29.795274557722546 -51.15480601787567, -29.795600426547136 -51.15540683269501, -29.795525942337928 -51.15628659725189, -29.795814568339743 -51.15741312503815, -29.796103193509005 -51.15764915943146, -29.797211134007373 -51.157456040382385, -29.797388030934346 -51.15757405757904, -29.796596647515113 -51.1591511964798, -29.796103193509005 -51.15940868854523, -29.79544214753631 -51.15910828113556, -29.794678680555958 -51.15802466869354, -29.79401762517251 -51.15790665149689, -29.792974824703958 -51.158207058906555))',
        'stroke_color': '50514F',
        'stroke_opacity': 0.8,
        'stroke_weight': 1,
        'fill_color': '50514F',
        'fill_opacity': 0.4,
    }, {
        'name': 'Centro B',
        'geom':
        'POLYGON((-29.792472042023952 -51.15577161312103, -29.792053054527678 -51.15361511707306, -29.795153520460268 -51.15261733531952, -29.79538628429624 -51.15381896495819, -29.795004551321096 -51.15452706813812, -29.794883513732213 -51.154441237449646, -29.79430625552492 -51.154462695121765, -29.793971071811892 -51.15492403507233, -29.793924518429623 -51.15539610385895, -29.792472042023952 -51.15577161312103))',
        'stroke_color': 'F25F5C',
        'stroke_opacity': 0.8,
        'stroke_weight': 1,
        'fill_color': 'F25F5C',
        'fill_opacity': 0.4,
    }, {
        'name': 'Centro C',
        'geom':
        'POLYGON((-29.792034432820458 -51.15358293056488, -29.795153520460268 -51.15256369113922, -29.794985930163108 -51.15159809589386, -29.794920756082853 -51.15005314350128, -29.79408279984098 -51.15006387233734, -29.793151729120222 -51.150729060173035, -29.792704812097245 -51.15100800991058, -29.79155957811571 -51.15134060382843, -29.792034432820458 -51.15358293056488))',
        'color': '000000',
        'stroke_color': 'FFE066',
        'stroke_opacity': 0.8,
        'stroke_weight': 1,
        'fill_color': 'FFE066',
        'fill_opacity': 0.4,
    }, {
        'name': 'Centro D',
        'geom':
        'POLYGON((-29.795395594838418 -51.15364730358124, -29.797239065121897 -51.153250336647034, -29.79696906402153 -51.15226328372955, -29.796838718401958 -51.15110456943512, -29.796391817845727 -51.150439381599426, -29.79592629431048 -51.150246262550354, -29.794957998419612 -51.15006387233734, -29.79502317247561 -51.15157663822174, -29.795395594838418 -51.15364730358124))',
        'stroke_color': '247BA0',
        'stroke_opacity': 0.8,
        'stroke_weight': 1,
        'fill_color': '247BA0',
        'fill_opacity': 0.4,
    }, {
        'name': 'Centro E',
        'geom':
        'POLYGON((-29.795041793626687 -51.15453779697418, -29.795432836998465 -51.15382969379425, -29.795404905379733 -51.15367949008942, -29.79724837549168 -51.15329325199127, -29.79759285856436 -51.15385115146637, -29.798365613575065 -51.15483820438385, -29.7985425084609 -51.15565359592438, -29.79838423410409 -51.156200766563416, -29.797406651645325 -51.15750968456268, -29.797211134007373 -51.15740239620209, -29.79611250398447 -51.15760624408722, -29.795833189343526 -51.15737020969391, -29.79555387392288 -51.156232953071594, -29.79562835811129 -51.15539610385895, -29.79528386827512 -51.15475237369537, -29.795041793626687 -51.15453779697418))',
        'stroke_color': '70C1B3',
        'stroke_opacity': 0.8,
        'stroke_weight': 1,
        'fill_color': '70C1B3',
        'fill_opacity': 0.4,
    }]

    for building in buildings:
        b = Building(building)
        db.session.add(b)
        db.session.commit()