Skip to content

Commit

Permalink
Removed the vendor directory
Browse files Browse the repository at this point in the history
  • Loading branch information
frostybee committed Mar 25, 2023
1 parent 360aecc commit a733986
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 1,156 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
composer.phar
vendor
.idea/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ $distance = $calculator->to('mi', 3, false);
$results = $calculator->toMany(['km', 'mi'], 3, true);
```

The above call returns an associative structured as follows:
The above call returns an associative array structured as follows:

```php
array(2) {
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "frostybee/geobee",
"description": "A simple, stand-alone PHP library for calculating the distance between geographical coordinates.",
"version": "1.0.1",
"version": "1.0.2",
"keywords": ["Vincenty formulae", "haversine", "geodesic distance"],
"homepage": "https://github.com/frostybee/geobee",
"type": "library",
"license": "MIT",
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"Frostybee\\Geobee\\": "src/"
Expand All @@ -17,4 +18,4 @@
"require": {
"php": ">=8"
}
}
}
48 changes: 37 additions & 11 deletions examples.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* To: Laval (postal code area: H7T)
* Latitude/Longitude: 45.55690, -73.7480
*/

$from_latitude = 45.4987;
$from_longitude = -73.5703;
$to_latitude = 45.55690;
Expand All @@ -25,35 +26,60 @@
)->to('km');

echo '<pre>';
echo '---------- <br>';
echo sprintf(
"The distance between point(%f, %f) and point(%f, %f) is %f km",
$from_latitude,
$from_longitude,
$to_latitude,
$to_longitude,
$distance
);
echo '<br>';
echo $distance;
echo '<br>';

// Distance in meters.
$distance = $calculator->calculate(
$from_latitude,
$from_longitude,
$to_latitude,
$to_longitude
)->getDistance();
echo '<br>';
// Distance in meters.
echo $distance;
echo '---------- <br>';
echo sprintf(
"The distance between point(%f, %f) and point(%f, %f) is %f m",
$from_latitude,
$from_longitude,
$to_latitude,
$to_longitude,
$distance
);
echo '<br>';
// Examples of single conversions:
echo $calculator->to('mi', 3, false); // False to round UP, true, round down.
$distance = $calculator->to('mi', 3, false); // False to round UP, true, round down.
echo '---------- <br>';
echo sprintf(
"The distance between point(%f, %f) and point(%f, %f) is %f mi",
$from_latitude,
$from_longitude,
$to_latitude,
$to_longitude,
$distance
);
echo '<br>';
echo 'Rounded: ';
echo '---------- <br>';
echo 'Rounded distance: ';
echo $calculator->to('km', 2, false); // False to round UP, true, round down.

echo '<br>';
echo '---------- <br>';
// Convert to all supported length units.
echo 'Distance converted to all units of lengths<br>';
$results = $calculator->toAll(2, true);
//echo $calculator->to('nm', 5, false);
var_dump($results);
// Convert to multiple (one or more).
$results = $calculator->toMany(['km', 'mi'], 3, true);
echo '---------- <br>';
echo 'Distance converted to all units of lengths<br>';
var_dump($results);

// Test validation method.
$is_valid = $calculator->is_coordinate($from_latitude, $from_longitude);
var_dump($is_valid);
var_dump($is_valid);
5 changes: 3 additions & 2 deletions src/Calculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ public function to(string $unit, ?int $decimals = null, bool $round = true)
return 0;
}
if (!$this->unitExists($unit)) {
throw new Exception("The requested conversion to unit u=$unit wasn't possible: the supplied unit either invalid or unsupported.");
throw new Exception("The requested conversion to unit u=$unit wasn't possible: the supplied unit is either invalid or unsupported.");
}
$conversion = $this->getConversion($unit);

$conversion = $this->getConversion(strtolower($unit));
if (is_numeric($conversion)) {
$result = $this->distance / $conversion;
if ($this->isPrecisionValid($decimals)) {
Expand Down
25 changes: 0 additions & 25 deletions vendor/autoload.php

This file was deleted.

Loading

0 comments on commit a733986

Please sign in to comment.