本文整理汇总了PHP中Map类的典型用法代码示例。如果您正苦于以下问题:PHP Map类的具体用法?PHP Map怎么用?PHP Map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeAffectsGivenKeyOnly
/** @test */
public function removeAffectsGivenKeyOnly()
{
$map = new Map(array('foo' => 42, 'bar' => 1337));
$map->remove('foo');
$this->assertFalse($map->hasKey('foo'));
$this->assertEquals(1337, $map->get('bar'));
}
示例2: generate
/**
* Generates a request based on the current apache variables.
* @throws Exception
*/
public static function generate()
{
$headers = new Map(apache_request_headers());
$method = $_SERVER['REQUEST_METHOD'];
$path = $_SERVER['REQUEST_URI'];
switch ($headers->get('Content-Type', null)) {
case 'application/json':
$data = file_get_contents('php://input');
$values = json_decode($data, true);
$params = new Map($values);
break;
case 'application/x-www-form-urlencoded':
$params = new Map($_POST);
break;
default:
if ($method === 'GET') {
$params = new Map($_GET);
} else {
if ($method === 'POST' || $method === 'PUT') {
$params = new Map($_POST);
} else {
$params = new Map();
}
}
break;
}
return new Request($path, $method, $headers, $params);
}
示例3: testPropertyDescriptor
function testPropertyDescriptor()
{
$name_d1 = 'd1';
$name_d2 = 'd2';
$p = new MockPlugin($this);
$pi = new TestPluginInfo($p);
$d1 = new MockPropertyDescriptor($this);
$d1->setReturnReference('getName', $name_d1);
$d2 = new MockPropertyDescriptor($this);
$d2->setReturnReference('getName', $name_d2);
$d3 = new MockPropertyDescriptor($this);
$d3->setReturnReference('getName', $name_d1);
$pi->addPropertyDescriptor($d1);
$pi->addPropertyDescriptor($d2);
$pi->addPropertyDescriptor($d3);
$expected = new Map();
$expected->put($name_d2, $d2);
$expected->put($name_d1, $d3);
$descriptors = $pi->getpropertyDescriptors();
$this->assertTrue($expected->equals($descriptors));
$pi->removePropertyDescriptor($d3);
$descriptors = $pi->getpropertyDescriptors();
$this->assertFalse($expected->equals($descriptors));
$this->assertEqual($descriptors->size(), 1);
}
示例4: draw
/**
* draw point on map
*
* @param Map $map
*/
public function draw(Map $map)
{
$image = $map->getImage();
$color = $this->_getDrawColor($image);
$pointInPixels = $map->getPixelPointFromCoordinates($this->_coordinates['lon'], $this->_coordinates['lat']);
imagesetpixel($image, $pointInPixels['x'], $pointInPixels['y'], $color);
}
示例5: putImage
/**
* method puts image onto map image
*
* @param Map $map
* @param resources $imageToPut
*/
public function putImage(Map $map, $imageToPut)
{
$mapImage = $map->getImage();
$width = imagesx($imageToPut);
$height = imagesy($imageToPut);
imagecopy($mapImage, $imageToPut, imagesx($mapImage) - $width, 0, 0, 0, $width, $height);
}
示例6: draw
/**
* draw line on map
*
* @param Map $map
*/
public function draw(Map $map)
{
$image = $map->getImage();
$startPointInPixels = $map->getPixelPointFromCoordinates($this->_startPoint->getLon(), $this->_startPoint->getLat());
$endPointInPixels = $map->getPixelPointFromCoordinates($this->_endPoint->getLon(), $this->_endPoint->getLat());
$this->_drawLine($image, $startPointInPixels['x'], $startPointInPixels['y'], $endPointInPixels['x'], $endPointInPixels['y']);
}
示例7: parseFile
/**
* Returns all layers found in a mapfile
*
* $file [string] : file path
*/
public function parseFile($file)
{
if (is_file($file)) {
if (substr($file, -4) == '.map') {
//create a map object
try {
$projLib = getenv("PROJ_LIB");
$mapFileContent = $this->fopen_file_get_contents($file);
$mapFileContent = preg_replace('/(\\n|^)\\s*MAP\\s*(\\n|#)/', "\$0\nCONFIG PROJ_LIB {$projLib}\n", $mapFileContent, 1);
$oMap = ms_newMapObjFromString($mapFileContent, dirname($file));
} catch (Exception $e) {
$error = ms_getErrorObj();
throw new Exception($error->message);
exit;
}
$map = new Map($oMap);
$m = array();
$mapMetaData = array("wms_onlineresource");
$mapParameters = array("projection");
foreach ($mapMetaData as $metaData) {
$m[$metaData] = $map->getMeta($metaData);
}
foreach ($mapParameters as $parameter) {
$m[$parameter] = $map->getParam($parameter);
}
$layers = $map->parseLayers();
return $this->formatParsingOutput($m, $layers);
} else {
throw new Exception("Le fichier spécifié n'est pas un mapfile valide.");
}
} else {
throw new Exception("Le fichier n'existe pas.");
}
}
示例8: _setUpResultMapCorners
/**
* it sets coordinates of the left up and right down corners of the result map
*
* @param Map $resultMap
*/
protected function _setUpResultMapCorners(Map $resultMap)
{
$leftUpCorner = $this->_mapData->getLeftUpCornerPoint();
$resultMap->setLeftUpCorner($leftUpCorner['lon'], $leftUpCorner['lat']);
$rightDownCorner = $this->_mapData->getRightDownCornerPoint();
$resultMap->setRightDownCorner($rightDownCorner['lon'], $rightDownCorner['lat']);
}
示例9: testIsDocumentIgnoredDest
public function testIsDocumentIgnoredDest()
{
$this->assertTrue($this->map->isDocumentIgnored('dest-document-ignored', MapInterface::TYPE_DEST));
$this->assertTrue($this->map->isDocumentIgnored('dest-document-ignored1', MapInterface::TYPE_DEST));
// Second run to check cached value
$this->assertTrue($this->map->isDocumentIgnored('dest-document-ignored', MapInterface::TYPE_DEST));
}
示例10: map
public function map($input)
{
$output = null;
foreach ($this->map->getMapping() as $mapElement) {
$mapElement->map($input, $output);
}
return $output;
}
示例11: setValues
private function setValues(array $years, Map $mapGroupedData, $dualY = false, $setToAxis = false)
{
$groups = $mapGroupedData->values();
foreach ($groups as $groupedData) {
$group = $groupedData;
$this->groupValuesByYear($years, $group, $dualY, $setToAxis);
}
}
示例12: getMapCornerPositionsAndRouteCoordinates
function getMapCornerPositionsAndRouteCoordinates($id)
{
$map = new Map();
$map->Load($id);
$user = DataAccess::GetUserByID($map->UserID);
$categories = DataAccess::GetCategoriesByUserID($user->ID);
return Helper::GetOverviewMapData($map, true, false, false, $categories);
}
示例13: setMap
/**
* @param Map $map
* @param bool $stopPropagation
* @return $this
*/
public function setMap(Map $map, $stopPropagation = false)
{
if (!$stopPropagation) {
$map->addController($this, true);
}
$this->map = $map;
return $this;
}
示例14: Execute
public function Execute()
{
$viewData = array();
// no user specified - redirect to user list page
if (!getCurrentUser()) {
Helper::Redirect("users.php");
}
// user is hidden - redirect to user list page
if (!getCurrentUser()->Visible) {
Helper::Redirect("users.php");
}
// the requested map
$map = new Map();
$map->Load($_GET["map"]);
if (!$map->ID) {
die("The map has been removed.");
}
DataAccess::UnprotectMapIfNeeded($map);
if (Helper::MapIsProtected($map)) {
die("The map is protected until " . date("Y-m-d H:i:s", Helper::StringToTime($map->ProtectedUntil, true)) . ".");
}
if ($map->UserID != getCurrentUser()->ID) {
die;
}
$viewData["Comments"] = DataAccess::GetCommentsByMapId($map->ID);
$viewData["Name"] = $map->Name . ' (' . date(__("DATE_FORMAT"), Helper::StringToTime($map->Date, true)) . ')';
// previous map in archive
$previous = DataAccess::GetPreviousMap(getCurrentUser()->ID, $map->ID, Helper::GetLoggedInUserID());
$viewData["PreviousName"] = $previous == null ? null : $previous->Name . ' (' . date(__("DATE_FORMAT"), Helper::StringToTime($previous->Date, true)) . ')';
// next map in archive
$next = DataAccess::GetNextMap(getCurrentUser()->ID, $map->ID, Helper::GetLoggedInUserID());
$viewData["NextName"] = $next == null ? null : $next->Name . ' (' . date(__("DATE_FORMAT"), Helper::StringToTime($next->Date, true)) . ')';
$size = $map->GetMapImageSize();
$viewData["ImageWidth"] = $size["Width"];
$viewData["ImageHeight"] = $size["Height"];
DataAccess::IncreaseMapViews($map);
$viewData["Map"] = $map;
$viewData["BackUrl"] = isset($_SERVER["HTTP_REFERER"]) && basename($_SERVER["HTTP_REFERER"]) == "users.php" ? "users.php" : "index.php?" . Helper::CreateQuerystring(getCurrentUser());
$viewData["Previous"] = $previous;
$viewData["Next"] = $next;
$viewData["ShowComments"] = isset($_GET["showComments"]) && ($_GET["showComments"] = true) || !__("COLLAPSE_VISITOR_COMMENTS");
$viewData["FirstMapImageName"] = Helper::GetMapImage($map);
if ($map->BlankMapImage) {
$viewData["SecondMapImageName"] = Helper::GetBlankMapImage($map);
}
$viewData["QuickRouteJpegExtensionData"] = $map->GetQuickRouteJpegExtensionData();
if (isset($viewData["QuickRouteJpegExtensionData"]) && $viewData["QuickRouteJpegExtensionData"]->IsValid) {
$categories = DataAccess::GetCategoriesByUserID(getCurrentUser()->ID);
$viewData["OverviewMapData"][] = Helper::GetOverviewMapData($map, true, false, false, $categories);
$viewData["GoogleMapsUrl"] = "http://maps.google.com/maps" . "?q=" . urlencode(Helper::GlobalPath("export_kml.php?id=" . $map->ID . "&format=kml")) . "&language=" . Session::GetLanguageCode();
}
if (USE_3DRERUN == '1' && DataAccess::GetSetting("LAST_WORLDOFO_CHECK_DOMA_TIME", "0") + RERUN_FREQUENCY * 3600 < time()) {
$viewData["RerunMaps"] = Helper::GetMapsForRerunRequest();
$viewData["TotalRerunMaps"] = count(explode(",", $viewData["RerunMaps"]));
$viewData["ProcessRerun"] = true;
}
return $viewData;
}
示例15: _setUpResultMapCorners
/**
* it sets coordinates of the left up and right down corners of the result map
*
* @param Map $resultMap
*/
protected function _setUpResultMapCorners(Map $resultMap)
{
$centerPoint = $this->_mapData->getCenterPoint();
$centerPointInPixels = $this->_worldMap->getPixelXY($centerPoint['lon'], $centerPoint['lat']);
$leftUpPointInPixels = array('x' => $centerPointInPixels['x'] - round($this->_mapData->getWidth() / 2), 'y' => $centerPointInPixels['y'] - round($this->_mapData->getHeight() / 2));
$resultMap->setLeftUpCorner($this->_worldMap->getLon($leftUpPointInPixels['x']), $this->_worldMap->getLat($leftUpPointInPixels['y']));
$rightDownPointInPixels = array('x' => $centerPointInPixels['x'] + round($this->_mapData->getWidth() / 2), 'y' => $centerPointInPixels['y'] + round($this->_mapData->getHeight() / 2));
$resultMap->setRightDownCorner($this->_worldMap->getLon($rightDownPointInPixels['x']), $this->_worldMap->getLat($rightDownPointInPixels['y']));
}