Beispiel #1
0
 def __init__(self, name, latitude, longitude, radius, include, exclude,
              days):
     """Initialize the Spot Crime sensor."""
     import spotcrime
     self._name = name
     self._include = include
     self._exclude = exclude
     self.days = days
     self._spotcrime = spotcrime.SpotCrime((latitude, longitude), radius,
                                           None, None, self.days)
     self._attributes = None
     self._state = None
     self._previous_incidents = set()
     self._attributes = {ATTR_ATTRIBUTION: spotcrime.ATTRIBUTION}
Beispiel #2
0
def get_crimes(rental, radius):
    crimes = spotcrime.SpotCrime((float(rental['lat']), float(rental['long'])),
                                 radius / 100,
                                 None, ['Other'],
                                 days=365)
    return crimes.get_incidents()
Beispiel #3
0
 def test_get_incidents(self):
     sc = spotcrime.SpotCrime(NEWARK, 0.01, None, None, 10)
     incidents = sc.get_incidents()
     self.assertIsInstance(incidents, list)
Beispiel #4
0
 def test_get_map_url(self):
     sc = spotcrime.SpotCrime(NEWARK, 0.01, None, None, 10)
     self.assertTrue(sc.get_map_url().startswith('https://spotcrime.com'))