public static function getTileCoordinates($xTile, $yTile, $zoom, $lat, $lon)
 {
     $bb = BoundingBox::tile2boundingBox($xTile, $yTile, $zoom);
     $minlat = $bb->south;
     $minlon = $bb->west;
     $maxlat = $bb->north;
     $maxlon = $bb->east;
     $deltalat = $maxlat - $minlat;
     $deltalon = $maxlon - $minlon;
     $x = ($lat - $minlat) / $deltalat * 256;
     $y = 256 - ($lon - $minlon) / $deltalon * 256;
     return array($x, $y);
 }
Esempio n. 2
0
 /**
  * @param \DarkLuk42\BoundingBox $bb area to check for cropping
  * @param \DarkLuk42\Color       $color color to be cropped
  * @param bool                   $cropTransparent if colors with alpha on invisible should be cropped too
  *
  * @return \DarkLuk42\BoundingBox area to be cropped
  */
 public function cropRightByColor(BoundingBox $bb, Color $color, $cropTransparent = true)
 {
     $binaryColor = $color->toBinary();
     // right to left
     for ($x = $bb->getRight(); $x >= $bb->getLeft(); $x--) {
         for ($y = $bb->getTop(); $y <= $bb->getBottom(); $y++) {
             if ($binaryColor != $this->colorAt($x, $y) && (!$cropTransparent || $this->colorAt($x, $y) >> 24 < 127)) {
                 break 2;
             }
         }
         $bb->setWidthByRight($x);
     }
     return $bb;
 }
Esempio n. 3
0
 public function scaleAs(BoundingBox $from, BoundingBox $to)
 {
     $this->scaleWidth($to->getWidth() / $from->getWidth());
     $this->addLeft(($to->getLeft() - $from->getLeft()) / $to->getWidth() * $this->getWidth());
     $this->scaleHeight($to->getHeight() / $from->getHeight());
     $this->addTop(($to->getTop() - $from->getTop()) / $to->getHeight() * $this->getHeight());
 }
Esempio n. 4
0
 /**
  * Deprectated method which has been used for
  * debug purposes in the past.
  */
 public static function debugtile($lat, $lon, $zoom)
 {
     $img = Map::getMapTile($lat, $lon, $zoom);
     $red = imagecolorallocate($img, 255, 0, 0);
     list($xTile, $yTile) = Map::getTileNumbers($lat, $lon, $zoom);
     list($x, $y) = BoundingBox::getTileCoordinates($xTile, $yTile, $zoom, $lat, $lon);
     $x = floor($x);
     $y = floor($y);
     imagerectangle($img, $x - 5, $y - 5, $x + 5, $y + 5, $red);
     header("Content-Type: image/png");
     imagepng($img);
 }