コード例 #1
0
 private function getRideNodeAddress(Address $rideNode, Address $home, $phone)
 {
     /*
      * retrieve address information from the ride node including
      * the poi name and poi phone number. If home address, the home phone no.
      */
     $part1 = $rideNode->getStreet() . ', ' . $rideNode->getPostalCode() . ' ' . $rideNode->getCity() . '.';
     if ($rideNode->getId() == $home->getId()) {
         /* the ride node is the home address */
         $part2 = '<br>' . $phone;
     } else {
         /** @var ArrayCollection $pois */
         $pois = $rideNode->getPois();
         $part2 = '';
         /** @var Poi $poi */
         foreach ($pois as $poi) {
             if ($poi->getIsActive() == true) {
                 $part2 .= '<br><b>' . $poi->getName() . '</b>' . '<br>' . $poi->getTelephone();
                 break;
                 // display only the first active poi
             }
         }
     }
     return $part1 . $part2;
 }
コード例 #2
0
 /**
  * @param Address $address
  * @return AddressHandleDTO
  */
 public static function toAddressHandleDTO(Address $address)
 {
     $addressHandleDTO = new AddressHandleDTO();
     $addressHandleDTO->id = $address->getId();
     $addressHandleDTO->displayName = $address->toString();
     $addressHandleDTO->street = $address->getStreet();
     $addressHandleDTO->postalCode = $address->getPostalCode();
     $addressHandleDTO->city = $address->getCity();
     $addressHandleDTO->country = $address->getCountry();
     $addressHandleDTO->lat = $address->getLat();
     $addressHandleDTO->lng = $address->getLng();
     $addressHandleDTO->source = $address->getSource();
     return $addressHandleDTO;
 }
コード例 #3
0
ファイル: POITest.php プロジェクト: binaryfr3ak/sfitixi
 public function testPoiCRUD()
 {
     $address = Address::registerAddress('Grundstrasse 12', '6431', 'Schwyz', 'Schweiz', 'Spital Schwyz', 47.17546, 8.517752, 'Spital');
     $this->init->addressRepo->store($address);
     $poiKeyword1 = POIKeyword::registerPOIKeyword('Tet1234');
     $poiKeyword2 = POIKeyword::registerPOIKeyword('Test2345');
     $poiKeyword3 = POIKeyword::registerPOIKeyword('Test3456');
     $this->init->poiKeywordRepo->store($poiKeyword1);
     $this->init->poiKeywordRepo->store($poiKeyword2);
     $this->init->poiKeywordRepo->store($poiKeyword3);
     $poi = POI::registerPoi('Krankenhaus', $address, 'Therapie', '041 818 21 21');
     $poi->assignKeyword($poiKeyword1);
     $poi->assignKeyword($poiKeyword2);
     $poi->assignKeyword($poiKeyword3);
     $this->init->poiRepo->store($poi);
     $this->init->em->flush();
     $poiFind = $this->init->poiRepo->find($poi->getId());
     $this->assertEquals($poi, $poiFind);
     $poi->updatePOIData('Altersheim Wohnwohl', null, 'Pflege', '041 818 31 31', 'Gutes Heim');
     $this->init->poiRepo->store($poi);
     $this->init->em->flush();
     $poiFind = $this->init->poiRepo->find($poi->getId());
     $this->assertEquals($poi, $poiFind);
     $this->poiRemove($poi);
 }
コード例 #4
0
 public function testRepeatedDrivingAssertionCRUD()
 {
     $driverCategory = $this->createDriverCategory('Zivildienst');
     $address = Address::registerAddress('Burstrasse 22c', '6333', 'Baar', 'Schweiz');
     $this->init->addressRepo->store($address);
     $driver = Driver::registerDriver('m', 'Max', 'Mühlemann', '041 222 32 32', $address, 'F3234141', $driverCategory, true, '', '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test');
     $this->init->driverRepo->store($driver);
     $shiftTypes[] = $this->createShiftType('Shift 1');
     $shiftTypes[] = $this->createShiftType('Shift 2');
     //weekly
     $repeatedDrivingAssertionWeekly = new RepeatedWeeklyDrivingAssertion();
     $repeatedDrivingAssertionWeekly->setWeekday(1);
     $repeatedDrivingAssertionWeekly->setShiftTypes($shiftTypes);
     $this->init->repeatedDrivingAssertionRepo->store($repeatedDrivingAssertionWeekly);
     $repeatedDrivingAssertionPlan = RepeatedDrivingAssertionPlan::registerRepeatedAssertionPlan('test', new \DateTime(), 'weekly', true);
     $repeatedDrivingAssertionPlan->assignDriver($driver);
     $repeatedDrivingAssertionPlan->assignRepeatedDrivingAssertion($repeatedDrivingAssertionWeekly);
     $this->init->repeatedDrivingAssertionPlanRepo->store($repeatedDrivingAssertionPlan);
     $this->init->em->flush();
     $find = $this->init->repeatedDrivingAssertionPlanRepo->find($repeatedDrivingAssertionPlan->getId());
     $this->assertEquals($find, $repeatedDrivingAssertionPlan);
     //monthly
     $repeatedDrivingAssertionMonthly = new RepeatedMonthlyDrivingAssertion();
     $repeatedDrivingAssertionMonthly->setRelativeWeekAsText('first');
     $repeatedDrivingAssertionMonthly->setWeekdayAsText('monday');
     $this->init->repeatedDrivingAssertionRepo->store($repeatedDrivingAssertionMonthly);
     $repeatedDrivingAssertionPlan = RepeatedDrivingAssertionPlan::registerRepeatedAssertionPlan('test', new \DateTime(), 'monthly', true);
     $repeatedDrivingAssertionPlan->assignDriver($driver);
     $repeatedDrivingAssertionPlan->assignRepeatedDrivingAssertion($repeatedDrivingAssertionMonthly);
     $this->init->repeatedDrivingAssertionPlanRepo->store($repeatedDrivingAssertionPlan);
     $this->init->em->flush();
     $find = $this->init->repeatedDrivingAssertionPlanRepo->find($repeatedDrivingAssertionPlan->getId());
     $this->assertEquals($find, $repeatedDrivingAssertionPlan);
 }
コード例 #5
0
 protected function createAddressHandleDTO(Address $address)
 {
     $handleDTO = new AddressHandleDTO();
     $handleDTO->id = $address->getId();
     $handleDTO->street = $address->getStreet();
     $handleDTO->postalCode = $address->getPostalCode();
     $handleDTO->city = $address->getCity();
     $handleDTO->country = $address->getCountry();
     $handleDTO->lat = $address->getLat();
     $handleDTO->lng = $address->getLng();
     $handleDTO->source = $address->getSource();
     return $handleDTO;
 }
コード例 #6
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $n = $input->getArgument('n');
     $routingMachine = $this->getContainer()->get('tixi_app.routingmachine');
     $address1 = Address::registerAddress('Rathausstrasse 1', '6340', 'Baar', 'Schweiz', 'Ganztagesschule mit Montessoriprofil', 47.194715, 8.526096000000001);
     $address2 = Address::registerAddress('Bahnhofstrasse 9', '6410', 'Arth', 'Schweiz', 'CSS', 47.049536, 8.547931);
     $routes = array();
     for ($i = 0; $i < $n; $i++) {
         array_push($routes, Route::registerRoute($address1, $address2));
     }
     $startTime = microtime(true);
     $routingMachine->fillRoutingInformationForMultipleRoutes($routes);
     $endTime = microtime(true);
     $output->writeln('Exectued ' . $n . ' OSRM requests in: ' . ($endTime - $startTime) . "s\n");
 }
コード例 #7
0
ファイル: CustodianTest.php プロジェクト: binaryfr3ak/sfitixi
 public function testCustodianCRUD()
 {
     $address = Address::registerAddress('Teststrasse 142', '6360', 'Cham', 'Schweiz');
     $this->init->addressRepo->store($address);
     $custodian = Custodian::registerCustodian('f', 'Toranto', 'Testinger', '041 324 33 22', $address, 'Herro', '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test', 'und auch Notizen');
     $passenger = Passenger::registerPassenger('f', 'Toranto', 'Testinger', '041 324 33 22', $address, 'Herro', true, false, '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test', 'und auch Notizen');
     $passenger2 = Passenger::registerPassenger('m', 'Toranto2', 'Testinger2', '041 324 33 222', $address, 'Herr', true, false, '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test', 'und auch Notizen');
     $custodian->assignPassenger($passenger);
     $custodian->assignPassenger($passenger2);
     $passenger->assignCustodian($custodian);
     $this->init->custodianRepo->store($custodian);
     $this->init->passengerRepo->store($passenger);
     $this->init->passengerRepo->store($passenger2);
     $this->init->em->flush();
     $custodianFind = $this->init->custodianRepo->find($custodian->getId());
     $this->assertEquals($custodian, $custodianFind);
     $this->custodianRemove($custodian);
 }
コード例 #8
0
ファイル: RouteTest.php プロジェクト: binaryfr3ak/sfitixi
 /**
  * @expectedException Doctrine\DBAL\DBALException
  */
 public function testRouteCRUD()
 {
     $address = Address::registerAddress('Hauptweg 11', '6333', 'Baar', 'Schweiz', 'Wohnadresse', 47.17546, 8.517752, 'Wohnung');
     $address2 = Address::registerAddress('Hauptweg 22', '6333', 'Baar', 'Schweiz', 'Wohnadresse', 47.13546, 8.527752, 'Wohnung');
     $this->init->addressRepo->store($address);
     $this->init->addressRepo->store($address2);
     $this->init->em->flush();
     $route = Route::registerRoute($address, $address2, 8, 1200);
     $finds = $this->init->routeRepo->findBy(array('startAddress' => $address->getId(), 'targetAddress' => $address2->getId()));
     $this->assertCount(0, $finds);
     $this->init->routeRepo->store($route);
     $this->init->em->flush();
     $finds = $this->init->routeRepo->findBy(array('startAddress' => $address->getId(), 'targetAddress' => $address2->getId()));
     $this->assertCount(1, $finds);
     //duplicate entry Exception will appear
     $route2 = Route::registerRoute($address, $address2, 2, 312);
     $this->init->routeRepo->store($route2);
     $this->init->em->flush();
 }
コード例 #9
0
ファイル: PassengerTest.php プロジェクト: binaryfr3ak/sfitixi
 public function testPassengerCRUD()
 {
     $handicap = $this->createHandicap('hörbehindert');
     $insurance = $this->createInsurance('AHV');
     $category = $this->createPersonCategory('Sponsor');
     $address = Address::registerAddress('Teststrasse 142', '6360', 'Cham', 'Schweiz');
     $this->init->addressRepo->store($address);
     $passenger = Passenger::registerPassenger('f', 'Toranto', 'Testinger', '041 324 33 22', $address, 'Herro', true, false, '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test', 'und auch Notizen');
     $passenger->assignHandicap($handicap);
     $passenger->assignInsurance($insurance);
     $passenger->assignPersonCategory($category);
     $this->init->passengerRepo->store($passenger);
     $this->init->em->flush();
     $passengerFind = $this->init->passengerRepo->find($passenger->getId());
     $this->assertEquals($passenger, $passengerFind);
     $passenger->updatePassengerData('f', 'Mila', 'Tolina', '0293292323', $address, 'Lady', true, false, '*****@*****.**', new \DateTime(), new \DateTime(), 2, 'goodies', 'notices');
     $this->init->passengerRepo->store($passenger);
     $this->init->em->flush();
     $passengerFind = $this->init->passengerRepo->find($passenger->getId());
     $this->assertEquals($passenger, $passengerFind);
     $this->passengerCreateAbsent($passenger);
     $this->passengerRemove($passenger);
 }
コード例 #10
0
ファイル: DriverTest.php プロジェクト: binaryfr3ak/sfitixi
 public function testDriverCRUD()
 {
     $driverCategory = $this->createDriverCategory('Zivildienst');
     $address = Address::registerAddress('Burstrasse 22c', '6333', 'Baar', 'Schweiz');
     $this->init->addressRepo->store($address);
     $driver = Driver::registerDriver('m', 'Max', 'Mühlemann', '041 222 32 32', $address, 'F3234141', $driverCategory, true, 'Dr.', '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test');
     $this->init->driverRepo->store($driver);
     $this->init->em->flush();
     $driverFind = $this->init->driverRepo->find($driver->getId());
     $this->assertEquals($driverFind, $driver);
     $date = new \DateTime('2009-01-01');
     $address = Address::registerAddress('Hauptstrasse 11', '6430', 'Schwyz', 'Schweiz', 48.55446, 75.54658999999999, 'Wohnung', 1);
     $this->init->addressRepo->store($address);
     $driverCategory = $this->createDriverCategory('Freiwillig');
     $driver->updateDriverData('f', 'Muni', 'Meier', '041 333 32 32', $address, 'FEA12345', $driverCategory, false, 'Dr. med.', '*****@*****.**', $date, $date, 5, 'alles nur ein Test');
     $this->init->driverRepo->store($driver);
     $this->init->em->flush();
     /**@var $driverFind Driver */
     $driverFind = $this->init->driverRepo->findOneBy(array('licenceNumber' => 'FEA12345'));
     $this->assertEquals($driver, $driverFind);
     $this->driverCreateAbsent($driver);
     $this->driverSuperviseVehicle($driver);
     $this->driverRemove($driver);
 }
コード例 #11
0
 /**
  * @param \Tixi\CoreDomain\Address $address
  * @return ZonePlan[]
  */
 public function getZonePlanForAddress(Address $address)
 {
     $city = $address->getCity();
     $plz = $address->getPostalCode();
     return $this->getZonePlanForAddressData($city, $plz);
 }
コード例 #12
0
 /**
  * Handles a new Address object if register new one or get an existing one
  *
  * @param AddressHandleDTO $addressHandleDTO
  * @return mixed|void
  * @throws \Exception
  */
 public function handleAddress(AddressHandleDTO $addressHandleDTO)
 {
     /** @var AddressRepositoryDoctrine $addressRepository */
     $addressRepository = $this->container->get('address_repository');
     $address = null;
     if (null === $addressHandleDTO->id) {
         //create new address
         $address = Address::registerAddress($addressHandleDTO->street, $addressHandleDTO->postalCode, $addressHandleDTO->city, $addressHandleDTO->country, null, $addressHandleDTO->lat, $addressHandleDTO->lng, $addressHandleDTO->source);
         $addressRepository->store($address);
     } else {
         /** @var Address $address */
         $address = $addressRepository->find($addressHandleDTO->id);
         if (null === $address) {
             throw new \Exception('The address with id ' . $addressHandleDTO->id . ' does not exist');
         }
         if ($addressHandleDTO->source === Address::SOURCE_MANUAL) {
             $address->updateAddressData($addressHandleDTO->street, $addressHandleDTO->postalCode, $addressHandleDTO->city, $addressHandleDTO->country, null, $addressHandleDTO->lat, $addressHandleDTO->lng, $addressHandleDTO->source);
         }
     }
     return $address;
 }
コード例 #13
0
ファイル: TestInitial.php プロジェクト: binaryfr3ak/sfitixi
 public function createTestAddressAesch()
 {
     $address = Address::registerAddress('Test 9', '4147', 'Aesch', 'Schweiz', 'Test', 47.049536, 8.547931);
     $this->addressRepo->store($address);
     $this->em->flush();
     return $address;
 }
コード例 #14
0
ファイル: Address.php プロジェクト: binaryfr3ak/sfitixi
 public static function removeAddress(Address $address)
 {
     foreach ($address->getPois() as $p) {
         /** @var $p POI */
         POI::removePoi($p);
     }
 }
コード例 #15
0
ファイル: RideNode.php プロジェクト: binaryfr3ak/sfitixi
 /**
  * generates Hash from Start and Target Adress (Route Hashtable)
  * coordinates as string together, since calculate sum from both bigInts
  * would be the same ride from->to and to->from
  * @return string
  */
 public function getRideRouteHash()
 {
     return hash('md4', $this->startAddress->getHashFromBigIntCoordinates() . $this->targetAddress->getHashFromBigIntCoordinates());
 }
コード例 #16
0
 /**
  * @param Address $from
  * @param Address $to
  * @return Route
  */
 public function findRouteWithAddresses(Address $from, Address $to)
 {
     $qb = $this->createQueryBuilder('e')->where('e.startAddress = :startAddressId')->andWhere('e.targetAddress = :targetAddressId')->setParameter('startAddressId', $from->getId())->setParameter('targetAddressId', $to->getId());
     return $qb->getQuery()->getOneOrNullResult();
 }
コード例 #17
0
ファイル: POI.php プロジェクト: binaryfr3ak/sfitixi
 /**
  * @param Address $address
  */
 public function assignAddress(Address $address)
 {
     $this->address = $address;
     $address->assignPoi($this);
 }