forked from mjaschen/phpgeo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Directions | ||
|
||
With the `Direction` class it's possible to determine if one point is north, east, south or west of another point. | ||
|
||
```php | ||
<?php | ||
|
||
use Location\Coordinate; | ||
|
||
$berlin = new Coordinate(52.5, 13.5); | ||
$rome = new Coordinate(42, 12.5); | ||
$helsinki = new Coordinate(60, 25); | ||
|
||
$direction = new Direction(); | ||
|
||
if ($direction->pointIsNorthOf(point: $helsinki, compareAgainst: $berlin)) { | ||
echo 'Helsinki is located north of Berlin.' . PHP_EOL; | ||
} else { | ||
echo 'Berlin is located north of Helsinki.' . PHP_EOL; | ||
} | ||
|
||
if ($direction->pointIsEastOf(point: $rome, compareAgainst: $berlin)) { | ||
echo 'Rome is located east of Berlin.' . PHP_EOL; | ||
} else { | ||
echo 'Berlin is located east of Rome.' . PHP_EOL; | ||
} | ||
``` | ||
|
||
The code above will produce the output below: | ||
|
||
``` plaintext | ||
Helsinki is located north of Berlin. | ||
Berlin is located east of Rome. | ||
``` |
File renamed without changes.