当前位置: 首页>>代码示例>>PHP>>正文


PHP Map类代码示例

本文整理汇总了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'));
 }
开发者ID:ulrichsg,项目名称:php-collections,代码行数:8,代码来源:MapTest.php

示例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);
 }
开发者ID:NJIT-CS490-project,项目名称:CS490-backend-api,代码行数:32,代码来源:Request.php

示例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);
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:25,代码来源:PluginInfoTest.php

示例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);
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:12,代码来源:Point.php

示例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);
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:13,代码来源:RightUpCorner.php

示例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']);
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:12,代码来源:Line.php

示例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.");
     }
 }
开发者ID:nbtetreault,项目名称:igo,代码行数:39,代码来源:MapfileParser.php

示例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']);
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:12,代码来源:FromBoundaryBox.php

示例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));
 }
开发者ID:rsavchuk,项目名称:data-migration-tool-ce,代码行数:7,代码来源:MapTest.php

示例10: map

 public function map($input)
 {
     $output = null;
     foreach ($this->map->getMapping() as $mapElement) {
         $mapElement->map($input, $output);
     }
     return $output;
 }
开发者ID:Viktechkso,项目名称:message-handler,代码行数:8,代码来源:DataMapper.php

示例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);
     }
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:8,代码来源:ChartBuilder.php

示例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);
}
开发者ID:andopor,项目名称:doma-project,代码行数:8,代码来源:ajax_server.php

示例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;
 }
开发者ID:saxulum,项目名称:saxulum-controller-provider,代码行数:13,代码来源:Controller.php

示例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;
 }
开发者ID:andopor,项目名称:doma-project,代码行数:58,代码来源:show_map.controller.php

示例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']));
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:14,代码来源:FromCenterPoint.php


注:本文中的Map类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。