Пример #1
0
    def get_records(self):
        """
        Query City of Boston Feature Server, and return a list of features
        
        :return: list of features corresponding to query
        """
        logger.debug('')

        return get_features_from_feature_server(self.resource_url, self.query)
Пример #2
0
def get_truck_locations():
    """
    Get the location of the food trucks in Boston TODAY

    :return: a list of features with unique food truck locations
    """
    trucks = gis_utils.get_features_from_feature_server(BASE_URL, QUERY)
    truck_unique_locations = []
    for t in trucks:
        if t['attributes']['Day'] == DAY:
            truck_unique_locations.append(t)
    return truck_unique_locations
Пример #3
0
def get_truck_locations(given_address):
    """
    Get the location of the food trucks in Boston TODAY within 1 mile
    of a given_address

    :return: a list of features with unique food truck locations
    """
    formatted_address = '{x_coordinate}, {y_coordinate}'.format(
        x_coordinate=given_address['x'], y_coordinate=given_address['y'])
    QUERY["geometry"] = formatted_address

    trucks = gis_utils.get_features_from_feature_server(BASE_URL, QUERY)
    truck_unique_locations = []
    for t in trucks:
        if t['attributes']['Day'] == DAY:
            truck_unique_locations.append(t)
    return truck_unique_locations
def get_farmers_markets_today(mycity_request):
    """
    Get all available farmers markets today

    :param mycity_request: MyCityRequestDataModel object
    :return: MyCityResponseObject
    """
    mycity_response = MyCityResponseDataModel()

    # List all available farmers markets today
    markets = gis_utils.get_features_from_feature_server(BASE_URL, QUERY)

    try:
        # Loop through the list of available farmers markets at a certain day
        markets_today = []
        for m in markets:
            if m not in markets_today and \
                    m['attributes']['Day_of_Week'] == DAY:
                markets_today.append(m)

        response = 'Available farmers markets today are:\n'
        for m in markets_today:
            response += m['attributes']['Name'] + ' located at ' + \
                        m['attributes']['Address'] + ' from ' + \
                        m['attributes']['Hours'] + '. '
        mycity_response.output_speech = response

    except BadAPIResponse:
        mycity_response.output_speech = \
            "Hmm something went wrong. Maybe try again?"

    # Setting reprompt_text to None signifies that we do not want to reprompt
    # the user. If the user does not respond or says something that is not
    # understood, the session will end.
    mycity_response.reprompt_text = None
    mycity_response.session_attributes = mycity_request.session_attributes
    mycity_response.card_title = "Farmers Markets"
    mycity_response.should_end_session = True

    return mycity_response