/**
  * @see sfValidatorBase
  */
 protected function doClean($value)
 {
     $value = (string) $value;
     $points = array();
     try {
         foreach (explode('|', $value) as $rawPoint) {
             $coords = explode(';', (string) $rawPoint);
             $point = new Point();
             $point->setLatitude($coords[0]);
             $point->setLongitude($coords[1]);
             $points[] = $point;
         }
     } catch (Exception $e) {
         throw new sfValidatorError($this, 'wrong_points');
     }
     if ($this->hasOption('required') && sizeof($points) == 0) {
         throw new sfValidatorError($this, 'required');
     }
     return $points;
     new Doctrine_Collection($table);
 }
 protected function wgtochina_lb($wg_flag, $wg_lng, $wg_lat, $wg_heit, $wg_week, $wg_time)
 {
     $x_add;
     $y_add;
     $h_add;
     $x_l;
     $y_l;
     $casm_v;
     $t1_t2;
     $x1_x2;
     $y1_y2;
     $point = new Point();
     if ($wg_heit > 5000) {
         return $point;
     }
     $x_l = $wg_lng;
     $x_l = $x_l / 3686400.0;
     $y_l = $wg_lat;
     $y_l = $y_l / 3686400.0;
     if ($x_l < 72.004) {
         return $point;
     }
     if ($x_l > 137.8347) {
         return $point;
     }
     if ($y_l < 0.8293) {
         return $point;
     }
     if ($y_l > 55.8271) {
         return $point;
     }
     if ($wg_flag == 0) {
         $this->IniCasm($wg_time, $wg_lng, $wg_lat);
         $point = new Point();
         $point->setLatitude($wg_lng);
         $point->setLongitude($wg_lat);
         return $point;
     }
     $this->casm_t2 = $wg_time;
     $t1_t2 = ($this->casm_t2 - $this->casm_t1) / 1000.0;
     if ($t1_t2 <= 0) {
         $this->casm_t1 = $this->casm_t2;
         $this->casm_f = $this->casm_f + 1;
         $this->casm_x1 = $this->casm_x2;
         $this->casm_f = $this->casm_f + 1;
         $this->casm_y1 = $this->casm_y2;
         $this->casm_f = $this->casm_f + 1;
     } else {
         if ($t1_t2 > 120) {
             if ($this->casm_f == 3) {
                 $this->casm_f = 0;
                 $this->casm_x2 = $wg_lng;
                 $this->casm_y2 = $wg_lat;
                 $x1_x2 = $this->casm_x2 - $this->casm_x1;
                 $y1_y2 = $this->casm_y2 - $this->casm_y1;
                 $casm_v = sqrt($x1_x2 * $x1_x2 + $y1_y2 * $y1_y2) / t1_t2;
                 if ($casm_v > 3185) {
                     return $point;
                 }
             }
             $this->casm_t1 = $this->casm_t2;
             $this->casm_f = $this->casm_f + 1;
             $this->casm_x1 = $this->casm_x2;
             $this->casm_f = $this->casm_f + 1;
             $this->casm_y1 = $this->casm_y2;
             $this->casm_f = $this->casm_f + 1;
         }
     }
     $x_add = $this->Transform_yj5($x_l - 105, $y_l - 35);
     $y_add = $this->Transform_yjy5($x_l - 105, $y_l - 35);
     $h_add = $wg_heit;
     $x_add = $x_add + $h_add * 0.001 + $this->yj_sin2($wg_time * 0.0174532925199433) + $this->random_yj();
     $y_add = $y_add + $h_add * 0.001 + $this->yj_sin2($wg_time * 0.0174532925199433) + $this->random_yj();
     $point = new Point();
     $point->setX(($x_l + $this->Transform_jy5($y_l, $x_add)) * 3686400);
     $point->setY(($y_l + $this->Transform_jyj5($y_l, $y_add)) * 3686400);
     return $point;
 }
 public function buildMerchants($xml)
 {
     $merchants = new Merchants();
     $merchants->setPageOffset((string) $xml->PageOffset);
     $merchants->setTotalCount((string) $xml->TotalCount);
     // merchant
     $merchantArray = array();
     foreach ($xml->Merchant as $merchant) {
         $tmpMerchant = new Merchant();
         $tmpMerchant->setId((string) $merchant->Id);
         $tmpMerchant->setName((string) $merchant->Name);
         $tmpMerchant->setWebsiteUrl((string) $merchant->WebsiteUrl);
         $tmpMerchant->setPhoneNumber((string) $merchant->PhoneNumber);
         $tmpMerchant->setCategory((string) $merchant->Category);
         $tmpLocation = new Location();
         $location = $merchant->Location;
         $tmpLocation->setName((string) $location->Name);
         $tmpLocation->setDistance((string) $location->Distance);
         $tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
         $tmpAddress = new Address();
         $address = $location->Address;
         $tmpAddress->setLine1((string) $address->Line1);
         $tmpAddress->setLine2((string) $address->Line2);
         $tmpAddress->setCity((string) $address->City);
         $tmpAddress->setPostalCode((string) $address->PostCode);
         $tmpCountry = new Country();
         $tmpCountry->setName((string) $address->Country->Name);
         $tmpCountry->setCode((string) $address->Country->Code);
         $tmpCountrySubdivision = new CountrySubdivision();
         $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
         $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
         $tmpAddress->setCountry($tmpCountry);
         $tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
         $tmpPoint = new Point();
         $point = $location->Point;
         $tmpPoint->setLatitude((string) $point->Latitude);
         $tmpPoint->setLongitude((string) $point->Longitude);
         // ACCEPTANCE FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES>
         //$tmpAcceptance = new Acceptance();
         //$acceptance = $merchant->Acceptance;
         // FEATURES FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES>
         //$tmpFeatures = new Features();
         //$features =  $merchant->Features;
         $tmpLocation->setPoint($tmpPoint);
         $tmpLocation->setAddress($tmpAddress);
         $tmpMerchant->setLocation($tmpLocation);
         array_push($merchantArray, $tmpMerchant);
     }
     $merchants->setMerchant($merchantArray);
     return $merchants;
 }
 public function buildAtms($xml)
 {
     $pageOffset = (string) $xml->PageOffset;
     $totalCount = (string) $xml->TotalCount;
     $restaurantArray = array();
     foreach ($xml->Restaurant as $restaurant) {
         $tmpRestaurant = new Restaurant();
         $tmpRestaurant->setId((string) $restaurant->Id);
         $tmpRestaurant->setName((string) $restaurant->Name);
         $tmpRestaurant->setWebsiteUrl((string) $restaurant->WebsiteUrl);
         $tmpRestaurant->setPhoneNumber((string) $restaurant->PhoneNumber);
         $tmpRestaurant->setCategory((string) $restaurant->Category);
         $tmpRestaurant->setLocalFavoriteInd((string) $restaurant->LocalFavoriteInd);
         $tmpRestaurant->setHiddenGemInd((string) $restaurant->HiddenGemInd);
         $tmpLocation = new Location();
         $location = $restaurant->Location;
         $tmpLocation->setName((string) $location->Name);
         $tmpLocation->setDistance((string) $location->Distance);
         $tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
         $tmpAddress = new Address();
         $address = $location->Address;
         $tmpAddress->setLine1((string) $address->Line1);
         $tmpAddress->setLine2((string) $address->Line2);
         $tmpAddress->setCity((string) $address->City);
         $tmpAddress->setPostalCode((string) $address->PostCode);
         $tmpCountry = new Country();
         $tmpCountry->setName((string) $address->Country->Name);
         $tmpCountry->setCode((string) $address->Country->Code);
         $tmpCountrySubdivision = new CountrySubdivision();
         $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
         $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
         $tmpAddress->setCountry($tmpCountry);
         $tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
         $tmpPoint = new Point();
         $point = $location->Point;
         $tmpPoint->setLatitude((string) $point->Latitude);
         $tmpPoint->setLongitude((string) $point->Longitude);
         $tmpLocation->setPoint($tmpPoint);
         $tmpLocation->setAddress($tmpAddress);
         $tmpRestaurant->setLocation($tmpLocation);
         array_push($restaurantArray, $tmpRestaurant);
     }
     $restaurants = new Restaurants($pageOffset, $totalCount, $restaurantArray);
     return $restaurants;
 }
Exemple #5
0
 protected function parseTrackpoint(\SimpleXMLElement $trackpointNode)
 {
     // Skip the point if lat/lng not found
     if (!isset($trackpointNode->Position->LatitudeDegrees) || !isset($trackpointNode->Position->LongitudeDegrees)) {
         return;
     }
     $point = new Point();
     $point->setAltitude((double) $trackpointNode->AltitudeMeters);
     $point->setDistance((double) $trackpointNode->DistanceMeters);
     $point->setLatitude((double) $trackpointNode->Position->LatitudeDegrees);
     $point->setLongitude((double) $trackpointNode->Position->LongitudeDegrees);
     $point->setTime(new \DateTime($trackpointNode->Time));
     if (isset($trackpointNode->HeartRateBpm->Value)) {
         $point->setHeartRate((int) $trackpointNode->HeartRateBpm->Value);
     }
     if (isset($trackpointNode->Extensions->TPX->Speed)) {
         $point->setSpeed($this->convertSpeed((double) $trackpointNode->Extensions->TPX->Speed));
     } else {
         // TODO If no speed is set, we can calculate it from the point before.
     }
     return $point;
 }
 public function buildAtms($xml)
 {
     $atms = new Atms();
     $atms->setPageOffset($xml->PageOffset);
     $atms->setTotalCount($xml->TotalCount);
     $atmArray = array();
     foreach ($xml->Atm as $atm) {
         $tmpAtm = new Atm();
         $tmpAtm->setHandicapAccessible((string) $atm->HandicapAccessible);
         $tmpAtm->setCamera((string) $atm->Camera);
         $tmpAtm->setAvailability((string) $atm->Availability);
         $tmpAtm->setAccessFees((string) $atm->AccessFees);
         $tmpAtm->setOwner((string) $atm->Owner);
         $tmpAtm->setSharedDeposit((string) $atm->SharedDeposit);
         $tmpAtm->setSurchargeFreeAlliance((string) $atm->SurchargeFreeAlliance);
         $tmpAtm->setSponsor((string) $atm->Sponsor);
         $tmpAtm->setSupportEMV((string) $atm->SupportEMV);
         $tmpAtm->setSurchargeFreeAllianceNetwork((string) $atm->SurchargeFreeAllianceNetwork);
         $tmpLocation = new Location();
         $location = $atm->Location;
         $tmpLocation->setName((string) $location->Name);
         $tmpLocation->setDistance((string) $location->Distance);
         $tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
         $tmpAddress = new Address();
         $address = $location->Address;
         $tmpAddress->setLine1((string) $address->Line1);
         $tmpAddress->setLine2((string) $address->Line2);
         $tmpAddress->setCity((string) $address->City);
         $tmpAddress->setPostalCode((string) $address->PostCode);
         $tmpCountry = new Country();
         $tmpCountry->setName((string) $address->Country->Name);
         $tmpCountry->setCode((string) $address->Country->Code);
         $tmpCountrySubdivision = new CountrySubdivision();
         $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
         $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
         $tmpAddress->setCountry($tmpCountry);
         $tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
         $tmpPoint = new Point();
         $point = $location->Point;
         $tmpPoint->setLatitude((string) $point->Latitude);
         $tmpPoint->setLongitude((string) $point->Longitude);
         $tmpLocation->setPoint($tmpPoint);
         $tmpLocation->setAddress($tmpAddress);
         $tmpAtm->setLocation($tmpLocation);
         array_push($atmArray, $tmpAtm);
     }
     $atms->setAtm($atmArray);
     return $atms;
 }