Beispiel #1
0
    def get_camera_data(self, link):
        """ Get the description, city name, and the image url of the given camera

            The link is url to a camera.
            This function creates parser for that and extracts the needed data.

            Args:
                link: url to a camera webpage that contains more detailed info about the camera

            Return:
                descrip: description about the given camera
                city: city name of the given camera
                img_src: image url of the given camera
        """
        # create html parser for the camera
        soup_cam = Useful.get_parser_with_soup(self, self.home_url + link)

        # get the description, city name, and img_src of the camera
        description = self.get_descrip(soup_cam)
        city = description
        img_src = self.get_img_src(soup_cam)
        state = self.state
        country = self.country

        camera_data = CameraData(img_src, country, state, city, description)

        return camera_data
Beispiel #2
0
    def get_data(self, a_tag):
        """ Get the img_src of the given camera 
                the detailed location information
                the city name about one camera

            The arguement link is a BeautifulSoup element that contains the html data about one camera.
            This function extracts the needed data in the <a href=""> tag.

            Args:
                a_tag: Selenium element that contains the html data about one camera

            Return:
                camera_data: CameraData instance that contains the parsed information about the given camera
        """
        link_to_cam = a_tag.get('href')

        img_src = self.get_img_src(self.parent_url + link_to_cam)
        city = a_tag.text.split("-")[0]
        description = Useful.get_token_between(self,
                                               a_tag.text.encode("UTF-8"), "(",
                                               ")").strip()
        state = self.state
        country = self.country

        camera_data = CameraData(img_src, country, state, city, description)

        return camera_data
    def get_camera_data(self, cam):
        """ Get the description, image url, and city name of the given camera

            The cam is a BeautifulSoup element that contains the infomation about one camera in <a href=""> tag
            This function extracts the description, image url, and city name of the given data

            Args:
                cam: BeautifulSoup element that contains the infomation about one camera in <a href=""> tag

            Return:
                camera_data: CameraData instance that contains the parsed information about a camera
        """
        # create parser for a camera
        soup_cam = self.get_parser_with_soup(self.home_url + cam.get('href'))

        # create img_src, city, descrip for Geocoding
        img_src = self.get_img_src(soup_cam)
        description = ""
        city = cam.text
        state = self.state
        country = self.country

        camera_data = CameraData(img_src, country, state, city, description)

        return camera_data
    def get_camera_data(self, cam_element):
        img_src = self.get_img_src(cam_element)
        description = self.get_description(cam_element)
        city = self.get_city(cam_element, description)
        state = self.state
        country = self.country

        camera_data = CameraData(img_src, country, state, city, description)

        return camera_data
Beispiel #5
0
    def get_camera_data(self, cam):
        img_src = self.get_img_src(cam)
        city = self.get_city(cam)
        description = city
        state = self.state
        country = self.country

        print(img_src, city)

        camera_data = CameraData(img_src, country, state, city, description)

        return camera_data
    def get_camera_data(self, cam):
        img_tag = cam.find("img")

        img_src     = img_tag.get("src")
        description = img_tag.get("alt")
        city        = self.get_city(description)
        state       = self.state
        country     = self.country

        camera_data = CameraData(img_src, country, state, city, description)

        return camera_data
Beispiel #7
0
    def get_camera_data(self, cam, municipality):
        parser_for_cam_webpage = self.get_parser_with_soup(self.home_url + cam.get('href'))

        img_src     = self.get_img_src(parser_for_cam_webpage)
        description = self.get_description(cam)
        city        = municipality
        state       = self.state
        country     = self.country

        print(img_src, description, city)
        
        camera_data = CameraData(img_src, country, state, city, description)

        return camera_data
Beispiel #8
0
    def get_data(self, cam):
        """ Get the country-code, state-code, city name, image URL, and description about the given camera

            The cam contains all the information about one camera.
            This function extracts the needed data from cam.

            Args:
                cam: BeautifulSoup4 element that contains all the information about one camera

            Return:
                camera_data: CameraData instance that contains the parsed information of a camera
        """
        # extract the description text
        text = cam.find("p", {"class": "description"}).text.encode("UTF-8")

        img_src = self.get_img_src(cam)
        descrip = ""
        city = cam.find("p", {"class": "one-webcam-header"}).text.strip()
        country, state = self.get_country_state(text)

        camera_data = CameraData(img_src, country, state, city, descrip)

        return camera_data
Beispiel #9
0
import random
from ControllerState import ControllerState
from CameraData import BoundingBox
from CameraData import CameraData

TURNING_VELOCITY = .1
FORWARD_VELOCITY = .1
BOX_SIZE_LIMIT = 200
MAXIUMUM_WAIT_TIME = 60
cam_dat = CameraData()
front_sensor_dat = False
timer = 0
robot_state = "RANDOM_SEARCH"
pos = None
"""
Does random search (roomba) until target is found.
"""


def randomSearch():
    global cam_dat, front_sensor_dat, robot_state
    new_command = ControllerState()

    if not cam_dat:  # target not found yet
        if front_sensor_dat:
            new_command.right_analog_x = TURNING_VELOCITY  # just turn
        else:
            new_command.left_analog_y = FORWARD_VELOCITY  # go forward
    robot_state = "MOVE_TO_TARGET"

    return new_command