Exemplo n.º 1
0
    def testRoutesWithBounds(self):
        testUser = User.objects.create(username='******',
                                       email='*****@*****.**',
                                       pwHash=auth.encryptPass(
                                           'james', 'password'),
                                       lastLogin=dt.now())

        testRoute = Route.objects.create(user=testUser,
                                         name='route 1',
                                         private=True,
                                         mapThumbnail='thumb')
        PathPoint.objects.create(route=testRoute,
                                 orderNum=0,
                                 lat=Decimal('2.000000'),
                                 lng=Decimal('2.000000'))

        testRouteTwo = Route.objects.create(user=testUser,
                                            name='route 2',
                                            private=True,
                                            mapThumbnail='thumb')
        PathPoint.objects.create(route=testRouteTwo,
                                 orderNum=0,
                                 lat=Decimal('1.000000'),
                                 lng=Decimal('1.000000'))

        routes = Route.objects.filter(user__username__iexact='james2')
        coords = {
            'swLat': Decimal('0.0'),
            'swLng': Decimal('0.0'),
            'neLat': Decimal('1.5'),
            'neLng': Decimal('1.5'),
        }

        self.assertEqual(
            geography.routesWithinBounds(routes, coords).count(), 1)
Exemplo n.º 2
0
	def testRoutesWithBounds(self):
		testUser = User.objects.create(username='******', email='*****@*****.**', pwHash=auth.encryptPass('james', 'password'), lastLogin=dt.now())

		testRoute = Route.objects.create(user=testUser, name='route 1', private=True, mapThumbnail='thumb')
		PathPoint.objects.create(route=testRoute, orderNum=0, lat=Decimal('2.000000'), lng=Decimal('2.000000'))

		testRouteTwo = Route.objects.create(user=testUser, name='route 2', private=True, mapThumbnail='thumb')
		PathPoint.objects.create(route=testRouteTwo, orderNum=0, lat=Decimal('1.000000'), lng=Decimal('1.000000'))
		
		routes = Route.objects.filter(user__username__iexact='james2')
		coords = {
			'swLat': Decimal('0.0'),
			'swLng': Decimal('0.0'),
			'neLat': Decimal('1.5'),
			'neLng': Decimal('1.5'),
		}
		
		self.assertEqual(geography.routesWithinBounds(routes, coords).count(), 1) 
Exemplo n.º 3
0
def routesWithinBounds(routes, boundsString):
	return geography.routesWithinBounds(routes, geography.getCoordsFromBounds(boundsString))