Ejemplo n.º 1
0
    def handle(self, *args, **options):
        start_time = time.time()
        logger.info(u'Start agsp Waze Miner')
        t0 = time.time()

        routeComputer = RouteComputer()
        trajets = Trajet.objects.all()
        routeComputer.digData(trajets)
Ejemplo n.º 2
0
class TestModels(TestCase):
    def setUp(self):
        print u'test_trajet_computing'
        self.routeComputer = RouteComputer()

    def test_trajet_computing(self):
        print(u"---------- test_trajet_computing --------------")

        user = User.objects.create_user(username='******', password='******')

        print(u'premiere request')
        request = self.routeComputer.initRequest(
            user,
            '80 rue jean antoine injalbert 34130 castelnau le lez',
            2500,
            label=u'chezmoi')
        print_agsp_models()

        self.routeComputer.buildTrajetsList(request)
        print_agsp_models()

        self.assertEqual(len(Trajet.objects.all()), 30)

        print request.origin
        print("recherche dans la base avec un filtre")

        justic = Place.objects.get(name=u'MONTPELLIER AV DE LA JUSTICE')
        antig = Place.objects.get(name=u'MONTPELLIER ANTIGONE')
        ml = list()
        ml.append(justic)
        ml.append(antig)
        #trajets = Trajet.objects.filter(name="MONTPELLIER ANTIGONE => MONTPELLIER AV DE LA JUSTICE")
        trajets = Trajet.objects.filter(fromPlace=request.origin).filter(
            toPlace__in=ml)
        self.assertEqual(len(trajets), 2)
        print('******************************************************')

        for elem in trajets:
            print elem

        print('******************************************************')

        for plt in request.places.all():
            print plt

        print('******************************************************')
        print('Computing...')
        self.routeComputer.computeTrajetLength(request)

        print("End of program")
Ejemplo n.º 3
0
    def handle(self, *args, **options):
        start_time = time.time()
        logger.info(u'Start get trajet arround')
        adress = options['adress']
        logger.info(u'adress:%s ' % (adress))
        t0 = time.time()
        arround = options['arroundInMeter']
        logger.info(u'arround:%sm ' % (arround))

        routeComputer = RouteComputer()
        user = User.objects.get(username='******')
        request = routeComputer.initRequest(
            user,
            '80 rue jean antoine injalbert 34130 castelnau le lez',
            arround,
            label=u'CHEZMOIS')
        routeComputer.buildTrajetsList(request)

        logger.debug(
            "    objectList,userProfil = agsp.getObjectsList(token) [%06dms] "
            % (1000 * (time.time() - t0)))

        self.stdout.write(self.style.SUCCESS(u'END'))

        routeComputer.computeTrajetLength(request)
Ejemplo n.º 4
0
class TestModels(TestCase):
    def setUp(self):
        print u'test les models'
        self.routeComputer = RouteComputer()

    def test_duplicate_coords(self):
        print "---------- test_duplicate_coords --------------"
        place = self.routeComputer.getPlaceFromStringSearch(
            u'place de la comedie a montpellier')

        llong = place.lon
        llat = place.lat
        place, created = Place.objects.get_or_create(lon=llong, lat=llat)
        if created:
            print('new Place created')
        else:
            print('No place created, a place with the same coord exists')
        self.assertEqual(created, False)
Ejemplo n.º 5
0
 def setUp(self):
     print u'test les models'
     self.routeComputer = RouteComputer()
Ejemplo n.º 6
0
class TestModels(TestCase):
    def setUp(self):
        print u'test les models'
        self.routeComputer = RouteComputer()

    def test_duplicate_place_after_request(self):
        print(
            u"---------- test_duplicate_place_after_request 1500m --------------"
        )

        user = User.objects.create_user(username='******', password='******')

        print(u'premiere request')
        request = self.routeComputer.initRequest(
            user,
            '80 rue jean antoine injalbert 34130 castelnau le lez',
            1500,
            label=u'chezmoi')
        print_agsp_models()

        print('seconde requests')
        request = self.routeComputer.initRequest(
            user,
            '80 rue jean antoine injalbert 34130 castelnau le lez',
            1500,
            label=u'chezmoi')
        print_agsp_models()

        self.assertEqual(len(Place.objects.all()), 3)

        self.routeComputer.buildTrajetsList(request)
        print_agsp_models()

        self.routeComputer.buildTrajetsList(request)
        print_agsp_models()

        self.assertEqual(len(Trajet.objects.all()), 6)

    def test_duplicate_place_after_request_bigger_radius(self):
        print(
            u"---------- test_duplicate_place_after_request_bigger_radius 8000m --------------"
        )

        user = User.objects.create_user(username='******', password='******')

        print(u'premiere request')
        request = self.routeComputer.initRequest(
            user,
            '80 rue jean antoine injalbert 34130 castelnau le lez',
            8000,
            label=u'chezmoi')
        print_agsp_models()

        print('seconde requests')
        request = self.routeComputer.initRequest(
            user,
            '80 rue jean antoine injalbert 34130 castelnau le lez',
            8000,
            label=u'chezmoi')
        print_agsp_models()

        self.assertEqual(len(Place.objects.all()), 35)

        self.routeComputer.buildTrajetsList(request)
        print_agsp_models()

        self.routeComputer.buildTrajetsList(request)
        print_agsp_models()

        self.assertEqual(len(Trajet.objects.all()), 1190)
Ejemplo n.º 7
0
 def setUp(self):
     print u'test_trajet_computing'
     self.routeComputer = RouteComputer()