protected function getCurrentScale() { if ($this->unitsPerMeter === null) { $this->unitsPerMeter = self::NO_PROJECTION; $projRep = new MapProjection($this->mapProjection); if (!$projRep->isGeographic()) { $unitsPerMeter = $projRep->getUnitsPerMeter(); if ($unitsPerMeter) { $this->unitsPerMeter = $unitsPerMeter; } } } if ($this->unitsPerMeter != self::NO_PROJECTION) { $metersPerPixel = $this->getHorizontalRange() / $this->imageWidth / $this->unitsPerMeter; return $metersPerPixel / self::LIFE_SIZE_METERS_PER_PIXEL; } else { $range = $this->getHorizontalRange(); $zoomLevel = ceil(log(360 / $range, 2)); return oldPixelScaleForZoomLevel($zoomLevel); } }
public function projectPoint($point) { list($x, $y) = self::getXYFromPoint($point); error_log("projecting $x, $y"); if ($this->srcProj == $this->dstProj) { return array('lon' => $x, 'lat' => $y); } $result = $point; if ($this->srcProjSpec) { $fromProjection = new MapProjection($this->srcProjSpec); if (!$fromProjection->isGeographic()) { $fromProjection->setXY(array('x' => $x, 'y' => $y)); $result = $fromProjection->getLatLon(); } } if ($this->dstProjSpec) { $toProjection = new MapProjection($this->dstProjSpec); if (!$toProjection->isGeographic()) { list($x, $y) = self::getXYFromPoint($result); $toProjection->setLatLon(array('lon' => $x, 'lat' => $y)); $result = $toProjection->getXY(); } } list($x, $y) = self::getXYFromPoint($result); error_log("result: $x, $y"); return $result; }