本文整理汇总了PHP中Point类的典型用法代码示例。如果您正苦于以下问题:PHP Point类的具体用法?PHP Point怎么用?PHP Point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Point类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: parseCoordinates
/**
* Filling property 'coordinates'
* @global string $egMultiMaps_CoordinatesSeparator
* @param string $coordinates
* @param string $service Name of map service
* @return boolean
*/
protected function parseCoordinates($coordinates, $service = null)
{
global $egMultiMaps_CoordinatesSeparator;
$array = explode($egMultiMaps_CoordinatesSeparator, $coordinates);
if ($service == 'leaflet' && count($array) == 1) {
$value = $array[0];
$coord = Geocoders::getCoordinates($value, $service, array('polygon' => true));
if ($coord !== false && is_array($coord['polygon'])) {
$this->coordinates = $coord['polygon'];
} else {
$this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $value)->escaped();
return false;
}
} else {
foreach ($array as $value) {
$point = new Point();
if ($point->parse($value, $service)) {
$this->coordinates[] = $point;
} else {
$this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $value)->escaped();
return false;
}
}
}
return true;
}
开发者ID:MapsMD,项目名称:mediawikiMaps,代码行数:33,代码来源:Line.php
示例2: testInfinity
public function testInfinity()
{
$point = new Point(1, 2);
$this->assertFalse($point->isInfinity());
$point = new Point(PointInterface::INFINITY, PointInterface::INFINITY);
$this->assertTrue($point->isInfinity());
}
开发者ID:bitpay,项目名称:php-client,代码行数:7,代码来源:PointTest.php
示例3: 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
示例4: testShouldAssignXYCoordinates
/**
* @covers Imagine\Image\Point::getX
* @covers Imagine\Image\Point::getY
* @covers Imagine\Image\Point::in
*
* @dataProvider getCoordinates
*
* @param integer $x
* @param integer $y
* @param BoxInterface $box
* @param Boolean $expected
*/
public function testShouldAssignXYCoordinates($x, $y, BoxInterface $box, $expected)
{
$coordinate = new Point($x, $y);
$this->assertEquals($x, $coordinate->getX());
$this->assertEquals($y, $coordinate->getY());
$this->assertEquals($expected, $coordinate->in($box));
}
开发者ID:nicodmf,项目名称:Imagine,代码行数:19,代码来源:PointTest.php
示例5: contains
/**
* @param Point $point
* @return bool
*/
public function contains(Point $point)
{
$vertices = $this->points->getPoints();
// Check if the point is inside the polygon or on the boundary
$intersections = 0;
for ($i = 1; $i < $this->points->getPoints()->count(); $i++) {
$vertex1 = $vertices->offsetGet($i - 1);
$vertex2 = $vertices->offsetGet($i);
// Check if point is on an horizontal polygon boundary
if ($vertex1->getY() == $vertex2->getY() && $vertex1->getY() == $point->getY() && $point->getX() > min($vertex1->getX(), $vertex2->getX()) && $point->getX() < max($vertex1->getX(), $vertex2->getX())) {
return true;
}
if ($point->getY() > min($vertex1->getY(), $vertex2->getY()) && $point->getY() <= max($vertex1->getY(), $vertex2->getY()) && $point->getX() <= max($vertex1->getX(), $vertex2->getX()) and $vertex1->getY() != $vertex2->getY()) {
$xinters = ($point->getY() - $vertex1->getY()) * ($vertex2->getX() - $vertex1->getX()) / ($vertex2->getY() - $vertex1->getY()) + $vertex1->getX();
// Check if point is on the polygon boundary (other than horizontal)
if ($xinters == $point->getX()) {
return true;
}
if ($vertex1->getX() == $vertex2->getX() || $point->getX() <= $xinters) {
$intersections++;
}
}
}
// If the number of edges we passed through is odd, then it's in the polygon.
if ($intersections % 2 != 0) {
return true;
} else {
return false;
}
}
开发者ID:pepin82,项目名称:geometry,代码行数:34,代码来源:Polygon.php
示例6: testShouldMoveByGivenAmount
/**
* @covers Imagine\Image\Point::getX
* @covers Imagine\Image\Point::getY
* @covers Imagine\Image\Point::move
*
* @dataProvider getMoves
*
* @param integer $x
* @param integer $y
* @param integer $move
* @param integer $x1
* @param integer $y1
*/
public function testShouldMoveByGivenAmount($x, $y, $move, $x1, $y1)
{
$point = new Point($x, $y);
$shift = $point->move($move);
$this->assertEquals($x1, $shift->getX());
$this->assertEquals($y1, $shift->getY());
}
开发者ID:Laxman-SM,项目名称:iron_worker_examples,代码行数:20,代码来源:PointTest.php
示例7: createFromCenterAndDistance
/**
* @param Point $center
* @param Distance $distance
*
* @return BoundingBox
* @author Maximilian Ruta <[email protected]>
*/
public static function createFromCenterAndDistance(Point $center, Distance $distance)
{
$distanceInDegrees = $distance->getInGeographicDegrees() / 2;
$sw = new Point($center->getLatitude() - $distanceInDegrees, $center->getLongitude() - $distanceInDegrees);
$ne = new Point($center->getLatitude() + $distanceInDegrees, $center->getLongitude() + $distanceInDegrees);
return new BoundingBox($sw, $ne);
}
开发者ID:XTAIN,项目名称:geo,代码行数:14,代码来源:BoundingBox.php
示例8: testInvalidPointY
/**
* test using an invalid y
**/
public function testInvalidPointY()
{
$point = new Point($this->VALID_X, $this->INVALID_Y);
// simply use the $INVALID_IP and an exception will be thrown
$point->setX($this->VALID_X);
$point->setY($this->INVALID_Y);
}
开发者ID:jmsaul,项目名称:open-trails,代码行数:10,代码来源:point-test.php
示例9: distance
/**
* @param Point $place1
* @param Point $place2
*
* @return Distance
* @author Maximilian Ruta <[email protected]>
*/
public static function distance(Point $place1, Point $place2)
{
$theta = $place1->getLongitude() - $place2->getLongitude();
$dist = sin(deg2rad($place1->getLatitude())) * sin(deg2rad($place2->getLatitude())) + cos(deg2rad($place1->getLatitude())) * cos(deg2rad($place2->getLatitude())) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
return new Distance($dist);
}
开发者ID:XTAIN,项目名称:geo,代码行数:15,代码来源:Calculator.php
示例10: testSetGetPoint
public function testSetGetPoint()
{
$point = new Point();
$point->setLat("-23.529366");
$point->setLng("-47.467117");
$this->place->setPoint($point);
$this->assertEquals("-23.529366,-47.467117", (string) $this->place->getPoint());
}
开发者ID:eher,项目名称:chegamos-lib,代码行数:8,代码来源:PlaceTest.php
示例11: testSubstract_SubstractPointIsGreaterThanMyPoint
/**
* @test
*/
public function testSubstract_SubstractPointIsGreaterThanMyPoint()
{
$substractPoint = 11;
try {
$point = new Point(10);
$point->substract($substractPoint);
} catch (Exception $ex) {
return;
}
$this->fail('例外が発生しなかったよー');
}
开发者ID:ryshinoz,项目名称:xunit_sample,代码行数:14,代码来源:PointTest.php
示例12: __construct
/**
* Constructor.
*
* @param float[][]|Point[] $positions
* @param CoordinateResolutionSystem|BoundingBox $arg,...
*/
public function __construct(array $positions)
{
$this->coordinates = array_map(function ($point) {
if (!$point instanceof Point) {
$point = new Point($point);
}
return $point->getCoordinates();
}, $positions);
if (func_num_args() > 1) {
$this->setOptionalConstructorArgs(array_slice(func_get_args(), 1));
}
}
开发者ID:szymonskirgajllo,项目名称:geojson-1,代码行数:18,代码来源:MultiPoint.php
示例13: add
/**
* 添加一个楼盘到数据库
* @param $premises Array(name, type, description, project_id, state, area, structure, lng, lat, zoom)
* @return bool 是否成功
*/
public function add($premises)
{
$ret = false;
$point = new Point();
$point_id = (int) $point->add($premises['lng'], $premises['lat'], $premises['zoom']);
$mysql = new MysqlAccess();
if ($point_id > 0) {
$sql = "insert into premises(`name`, `description`, `point_id`, `project_id`) " . "values('{$premises['name']}', '{$premises['description']}', {$point_id}, " . "{$premises['project_id']})";
$mysql->runSql($sql);
$ret = true;
}
return $ret;
}
开发者ID:newmight2015,项目名称:housegis,代码行数:18,代码来源:premises.class.php
示例14: getCartographicDistance
/**
* @param Point $point
* @return float
*
* thanks to http://stackoverflow.com/questions/7672759/how-to-calculate-distance-from-lat-long-in-php
*/
public function getCartographicDistance(Point $point)
{
$earthRadius = 3958.75;
$dLat = deg2rad($point->getLatitude() - $this->latitude);
$dLng = deg2rad($point->getLongitude() - $this->longitude);
$a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($this->latitude)) * cos(deg2rad($point->getLatitude())) * sin($dLng / 2) * sin($dLng / 2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
$dist = $earthRadius * $c;
// from miles to km
$meterConversion = 1.609344;
$geopointDistance = $dist * $meterConversion;
return round($geopointDistance, 0);
}
开发者ID:CatalinaO,项目名称:trip-planner,代码行数:19,代码来源:Point.php
示例15: add
/**
* 添加person
*/
public function add($person)
{
$ret = false;
$point = new Point();
$now_id = (int) $point->add($person['now']['lng'], $person['now']['lat'], $person['now']['zoom']);
$want_id = (int) $point->add($person['want']['lng'], $person['want']['lat'], $person['want']['zoom']);
$mysql = new MysqlAccess();
if ($now_id > 0 && $want_id > 0) {
$sql = "insert into person(`name`, `now`, `want`, `state`, `description`) values " . "('{$person['name']}', {$now_id}, {$want_id}, '{$person['state']}', '{$person['description']}')";
$mysql->runSql($sql);
$ret = true;
}
return $ret;
}
开发者ID:newmight2015,项目名称:housegis,代码行数:17,代码来源:person.class.php
示例16: random_point_generation_disk
public function random_point_generation_disk($sizeX, $minDist, $maxDist)
{
$sizeY = $sizeX;
// Initial point generation
$this->add_point(new Point(round($sizeX / 2), round($sizeY / 2), '0'));
$initialPoint = reset($this->vertices);
for ($i = 65; $i < 91; $i++) {
$letters[] = chr($i);
}
for ($i = 97; $i < 123; $i++) {
$letters[] = chr($i);
}
$i = 0;
// Point creation procedure
$maxMissedPoints = 1000;
$missedPointCount = 0;
while ($missedPointCount < $maxMissedPoints) {
$x = rand(0, $sizeX - 1);
$y = rand(0, $sizeY - 1);
$point = new Point($x, $y, $letters[$i]);
$pointCreationFlag = false;
if (Point::distance($point, $initialPoint) <= $sizeX / 2) {
$pointCreationFlag = $this->add_point($point, $minDist, $maxDist);
}
if ($pointCreationFlag) {
$missedPointCount = 0;
$i++;
} else {
$missedPointCount++;
}
}
}
开发者ID:AlgorithmsNYC,项目名称:AlgorithmsNYC,代码行数:32,代码来源:graph.class.php
示例17: draw
/**
* draw point on map
*
* @param Map $map
*/
public function draw(Map $map)
{
parent::draw($map);
$point = $map->getPixelPointFromCoordinates($this->getLon(), $this->getLat());
$vertices = array($point['x'], $point['y'], $point['x'] - 10, $point['y'] - 20, $point['x'] + 10, $point['y'] - 20);
imagefilledpolygon($map->getImage(), $vertices, 3, imagecolorallocate($map->getImage(), 200, 0, 0));
}
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:12,代码来源:MarkPoint.php
示例18: actionUpdate
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model = $this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Net'])) {
$model->attributes = $_POST['Net'];
if ($model->save()) {
$pointsAttached = $_POST['Net']['pointsattached'];
$pointToNet = new PointToNet();
$pointToNet::model()->deleteAll('net_id = ' . $model->id);
foreach ($pointsAttached as $attached) {
$pointToNet->attributes = array('net_id' => $model->id, 'point_id' => $attached);
$pointToNet->save();
$PointModel = Point::model()->findByPk($attached);
$PointModel->CreateChannelsForWindows($model->screen_id, $attached);
unset($PointModel);
$pointToNet = new PointToNet();
}
$model->CreateChannelsForWindows($model->screen_id, $model->id);
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('update', array('model' => $model));
}
开发者ID:AlexanderKosianchuk,项目名称:rtvgroup,代码行数:30,代码来源:NetController.php
示例19: aireTriangle
static function aireTriangle($pointA, $pointB, $pointC)
{
$AB = Point::distance($pointA, $pointB);
$BC = Point::distance($pointB, $pointC);
$AC = Point::distance($pointC, $pointA);
return sqrt(($AB + $BC + $AC) * (-$AB + $BC + $AC) * ($AB - $BC + $AC) * ($AB + $BC - $AC)) / 4;
}
开发者ID:AlgorithmsNYC,项目名称:AlgorithmsNYC,代码行数:7,代码来源:point.class.php
示例20: init
public function init()
{
parent::init();
// Create new field in your users table for store dashboard preference
// Set table name, user ID field name, user preference field name
$this->setTableParams('dashboard_page', 'user_id', 'title');
// set array of portlets
$this->setPortlets(array(array('id' => 1, 'title' => 'Ultimos clientes', 'content' => Customer::model()->Top(4)), array('id' => 2, 'title' => 'Ultimas reservas', 'content' => Book::model()->Top(4)), array('id' => 3, 'title' => 'Puntos críticos', 'content' => Point::model()->Top(4)), array('id' => 4, 'title' => 'Ultimos boletines', 'content' => Mail::model()->Top(4)), array('id' => 5, 'title' => 'Informes', 'content' => Functions::lastReports()), array('id' => 6, 'title' => 'Ultimas facturas', 'content' => Invoice::model()->Top(4))));
//set content BEFORE dashboard
$this->setContentBefore();
// uncomment the following to apply jQuery UI theme
// from protected/components/assets/themes folder
$this->applyTheme('ui-lightness');
// uncomment the following to change columns count
//$this->setColumns(4);
// uncomment the following to enable autosave
$this->setAutosave(true);
// uncomment the following to disable dashboard header
$this->setShowHeaders(false);
// uncomment the following to enable context menu and add needed items
/*
$this->menu = array(
array('label' => 'Index', 'url' => array('index')),
);
*/
}
开发者ID:FranHurtado,项目名称:hotels,代码行数:26,代码来源:DashController.php
注:本文中的Point类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论