Esempio n. 1
0
 def setUp(self):
     self.gis_client = SteerClearGISClient(shapefile_filename)
Esempio n. 2
0
# setup sms client for twilio api
from steerclear.utils import sms
sms_client = sms.SteerClearSMSClient(app.config['TWILIO_ACCOUNT_SID'],
                                     app.config['TWILIO_AUTH_TOKEN'],
                                     app.config['TWILIO_NUMBER'])

# setup google distance matrix api client
from steerclear.utils.eta import SteerClearDMClient
dm_client = SteerClearDMClient()

# setup and load in shapefiles of the campus map and steerclear radius polygons
from steerclear.utils.polygon import SteerClearGISClient
from os import path
steerclear_dirname = path.dirname(path.abspath(__file__))
campus_map_filename = steerclear_dirname + '/static/shapefiles/campus_map/campus_map.shp'
campus_gis_client = SteerClearGISClient(campus_map_filename)

steerclear_radius_filename = steerclear_dirname + '/static/shapefiles/steerclear-radius/steerclear-radius.shp'
radius_gis_client = SteerClearGISClient(steerclear_radius_filename)

from steerclear.api.views import api_bp
from steerclear.driver_portal.views import driver_portal_bp
from steerclear.login.views import login_bp

# register all blueprints to the app
app.register_blueprint(api_bp)
app.register_blueprint(driver_portal_bp)
app.register_blueprint(login_bp)

if not app.debug:
    import logging
Esempio n. 3
0
class SteerClearGISClientTestCase(unittest.TestCase):

    def setUp(self):
        self.gis_client = SteerClearGISClient(shapefile_filename)

    """
    test_is_on_campus_major_points_on_campus
    ----------------------------------------
    Tests that major buildings that are actually on the wm
    campus are classified as being on campus
    """
    def test_is_on_campus_major_points_on_campus(self):
        # test with lat/long of william and mary
        self._test_point((37.272433, -76.716922), True)

        # test with lat/long of sadler center
        self._test_point((37.271819, -76.714061), True)

        # test point near randolph complex
        self._test_point((37.270857, -76.719126), True)

        # test point near swem library
        self._test_point((37.269832, -76.716803), True)

        # test point near botetourt
        self._test_point((37.270255, -76.721078), True)

    """
    test_is_on_campus_points_near_perimeter_of_campus
    -------------------------------------------------
    Tests that points that are still on the campus
    but are on the perimeter of the main campus are
    still classified as being on campus
    """
    def test_is_on_campus_points_near_perimeter_of_campus(self):
        # test point near barret hall
        self._test_point((37.269028, -76.711410), True)

        # test point near jefferson hall
        self._test_point((37.269501, -76.710186), True)

        # test point near colonial williamsburg but still on campus
        self._test_point((37.270837, -76.707575), True)

        # test point near blow hall
        self._test_point((37.272114, -76.709993), True)

        # test point near bryan hall
        self._test_point((37.272938, -76.712275), True)

        # test point near zable hall
        self._test_point((37.273959, -76.713427), True)

        # test point near frat castles
        self._test_point((37.274754, -76.718091), True)

        # test point near rec center
        self._test_point((37.274705, -76.720931), True)

        # test point near jamestown south
        self._test_point((37.268358, -76.712992), True)

        # test point near PBK
        self._test_point((37.267523, -76.714738), True)

        # test point near business school
        self._test_point((37.266099, -76.717825), True)

    """
    test_is_on_campus_points_not_on_campus
    --------------------------------------
    Tests that points that are not on campus
    are classified as being not on campus
    """
    def test_is_on_campus_points_not_on_campus(self):
        # test point near ludwell
        self._test_point((37.264771, -76.719619), False)

        # test along jamestown rd
        self._test_point((37.265336, -76.718569), False)

        # test point near churches on jamestown rd
        self._test_point((37.266251, -76.716797), False)

        # test point on indian springs
        self._test_point((37.267543, -76.714164), False)

        # test point on carry street
        self._test_point((37.268366, -76.712508), False)

        # test point on griffin street
        self._test_point((37.268717, -76.711640), False)

        # test point near campus center
        self._test_point((37.269858, -76.708828), False)

        # test point on armistead
        self._test_point((37.272021, -76.709213), False)

        # test point by wawa
        self._test_point((37.273089, -76.711508), False)

        # test point by college deli
        self._test_point((37.273596, -76.712561), False)

        # test point near ho house
        self._test_point((37.274293, -76.713327), False)

        # test point on harrison
        self._test_point((37.274293, -76.713327), False)

        # test point on dillard
        self._test_point((37.276227, -76.716053), False)

        # test point on matoaka court
        self._test_point((37.276803, -76.721015), False)

    """
    _test_point
    -----------
    Helper method for testing if a lat/long point
    is on campus or not

    :point:     (lat, long) tuple
    :result:    Boolean specifying if the point is on campus
    """
    def _test_point(self, point, result):
        r = self.gis_client.is_in_polygon(point)
        self.assertEqual(r, result)