Ejemplo n.º 1
0
 protected function __construct(LatLng $sw, LatLng $ne)
 {
     $s = $sw->lat();
     $w = $sw->lng();
     $n = $ne->lat();
     $e = $ne->lng();
     // Wrap latitudes around the globe
     $s = Geo::wrapLat($s);
     $n = Geo::wrapLat($n);
     // Compute difference in longitude extremities
     $lngDiff = $e - $w;
     // Compute new longitudes
     if ($lngDiff >= 360) {
         $e = 180;
         $w = -180;
     } else {
         $e = Geo::wrapLng($e);
         $w = Geo::wrapLng($w);
     }
     // Assign bounds' attributes
     $this->s = $s;
     $this->w = $w;
     $this->n = $n;
     $this->e = $e;
 }
Ejemplo n.º 2
0
 /**
  * @param int $id
  * @param int $userId
  * @param int $nearId
  * @param int $countryId
  * @param string $name
  * @param string $label
  * @param string $cat
  * @param string $sub
  * @param LatLng $latLng
  * @param Polygon $border
  * @param string[] $attrs
  */
 public static function updateEdit($id, $userId, $nearId, $countryId, $name, $label, $cat, $sub, $latLng, $border, $attrs)
 {
     db()->update()->table('poi_edit')->set('nearId', $nearId)->set('countryId', $countryId)->set('userId', $userId)->set('name', $name)->set('label', $label)->set('cat', $cat)->set('sub', $sub)->set('lat', $latLng->lat())->set('lng', $latLng->lng())->set('border', $border === NULL ? 'NULL' : $border->toWKT())->op(GEOM_FROM_TEXT)->set('attrs', json_encode($attrs))->set('timestamp')->op('CURRENT_TIMESTAMP')->where('id', EQ, $id)->andCond('userId', EQ, $userId)->exec();
 }
Ejemplo n.º 3
0
 /**
  * Computes the coordinates of a point at the distance $d and in the
  * direction $dir from the given coordinates.
  * 
  * @param LatLng $latlng
  * @param type $d Distance in km.
  * @param type $dir Diretion in degrees.
  * @return \LatLng
  */
 public static function proximity(LatLng $latlng, $d, $dir)
 {
     $lat = deg2rad($latlng->lat());
     $lng = deg2rad($latlng->lng());
     $dir = deg2rad($dir);
     $lat = asin(sin($lat) * cos($d / GEO_R) + cos($lat) * sin($d / GEO_R) * cos($dir));
     $lng = $lng + atan2(sin($dir) * sin($d / GEO_R) * cos($lat), cos($d / GEO_R) - sin($lat) * sin($lat));
     return new LatLng(rad2deg($lat), rad2deg($lng));
 }
Ejemplo n.º 4
0
 /**
  * @param LatLng $center
  */
 public function setCenter(LatLng $center)
 {
     $cy = merLat($center->lat());
     $cLng = $center->lng();
     $yDiff = merLat($this->n) - merLat($this->s);
     $lngDiff = $this->e - $this->w;
     $this->n = meriLat($cy + $yDiff / 2);
     $this->s = meriLat($cy - $yDiff / 2);
     $this->e = $cLng + $lngDiff / 2;
     $this->w = $cLng - $lngDiff / 2;
 }