Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/5.x #105

Merged
merged 51 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
36569cd
make PHPUnit data provider methods static
mjaschen Dec 3, 2023
4ee795a
update Composer dependencies
mjaschen Dec 3, 2023
f271c0a
remove obsolete doc blocks
mjaschen Dec 3, 2023
353af22
use constructor property promotion; remove obsolete doc blocks; depre…
mjaschen Dec 3, 2023
5493e80
remove obsolete doc blocks
mjaschen Dec 3, 2023
ffa0a7d
mark constants as final; use arrow functions
mjaschen Dec 3, 2023
a500e7b
constructor property promotion
mjaschen Dec 3, 2023
d02fdd0
remove obsolete doc blocks
mjaschen Dec 3, 2023
4a3a5d9
remove obsolete doc blocks
mjaschen Dec 3, 2023
dc7f5a4
code style
mjaschen Dec 3, 2023
891aa29
remove obsolete doc blocks
mjaschen Dec 3, 2023
e774910
mark constants as final; remove obsolete doc blocks
mjaschen Dec 3, 2023
b48b989
mark constants as final; remove obsolete doc blocks
mjaschen Dec 3, 2023
f4d663c
remove obsolete doc blocks
mjaschen Dec 3, 2023
b0ccfc0
remove obsolete doc blocks; throw JsonException when encoding fails
mjaschen Dec 3, 2023
48d30f6
remove obsolete doc blocks; mark constants as final; constructor prop…
mjaschen Dec 3, 2023
133ec54
constructor property promotion; remove obsolete doc blocks
mjaschen Dec 3, 2023
d817a1d
constructor property promotion; remove obsolete doc blocks
mjaschen Dec 3, 2023
88bb768
use typed properties
mjaschen Dec 3, 2023
706a4ba
update return type
mjaschen Dec 3, 2023
5252083
use public properties instead of deprecated getters
mjaschen Dec 3, 2023
a7cb026
update doc blocks
mjaschen Dec 3, 2023
1fb63c0
code style
mjaschen Dec 3, 2023
d2ca562
update doc blocks
mjaschen Dec 5, 2023
9d8a4fe
update doc blocks
mjaschen Dec 5, 2023
8f13f8a
update doc blocks
mjaschen Dec 5, 2023
186685e
update doc blocks
mjaschen Dec 5, 2023
9bcc77c
update doc blocks; code style
mjaschen Dec 5, 2023
ac62a0d
add return type; update doc blocks
mjaschen Dec 5, 2023
ced1451
constructor property promotion; remove obsolete doc blocks
mjaschen Dec 5, 2023
ec430a0
update doc blocks; code style
mjaschen Dec 5, 2023
3f61f8d
update doc blocks; throw JsonException
mjaschen Dec 6, 2023
4923134
update doc blocks
mjaschen Dec 6, 2023
9fadc92
update doc blocks
mjaschen Dec 6, 2023
c900356
update doc blocks; add type hint to property
mjaschen Dec 6, 2023
bce5224
add public properties; deprecate getters; update doc blocks
mjaschen Dec 6, 2023
47769a7
update doc blocks; use public properties instead of deprecated getters
mjaschen Dec 6, 2023
5abf238
constructor property promotion
mjaschen Dec 6, 2023
0f7ab18
constructor property promotion
mjaschen Dec 6, 2023
74bf1ff
constructor property promotion; update doc blocks
mjaschen Dec 6, 2023
bf3c0f5
update doc blocks
mjaschen Dec 6, 2023
edfefbd
update doc blocks; constructor property promotion; remove deprecated …
mjaschen Dec 6, 2023
0d7a7a8
update doc blocks; improve array merge logic; add type hint to property
mjaschen Dec 6, 2023
94ee68b
add tests
mjaschen Dec 6, 2023
832ac70
update Psalm config
mjaschen Dec 6, 2023
376d2a1
update README + change log
mjaschen Dec 6, 2023
b086e84
update docs
mjaschen Dec 6, 2023
d16af65
update GitHub Actions version matrix
mjaschen Dec 6, 2023
d30c619
Merge branch 'master' into dev/5.x
mjaschen Dec 7, 2023
63f735c
Merge branch 'main' into dev/5.x
mjaschen Dec 7, 2023
1f05a78
update change log
mjaschen Dec 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ jobs:
strategy:
matrix:
php-versions:
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"

name: "phpgeo CI run - PHP ${{ matrix.php-versions }}"

Expand Down
25 changes: 17 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@
All notable changes to `mjaschen/phpgeo` will be documented in this file.
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## Unreleased/Upcoming
## [5.0.0]

### Added

- `GeometryInterface` provides two new methods: `getBounds()` and `getSegments()`
**Warning: Backwards-compatibility-breaking changes**

### Removed

- Support for PHP 7.3
- `setPoint1()` and `setPoint2()` methods from `Line`
- `setSeparator()`, `useCardinalLetters()` and `setUnits()` methods from `DMS`
- Support for PHP 7.3, 7.4 and 8.0
- deprecated methods `setPoint1()` and `setPoint2()` from `Line`

### Changed

- `master` is now renamed to `main`
- `GeometryFactoryInterface::fromString()` now has `GeometryInterface` as return type

### Deprecated

- deprecated methods `getDestination()` and `getBearingFinal()` from `DirectVincentyBearing`
- deprecated methods `getDistance()`, `getBearingInitial()` and `getBearingFinal()` from `InverseVincentyBearing`
- deprecated methods `getX()`, `getY()` and `getZ()` from `Cartesian`
- deprecated methods `getPoint1()` and `getPoint2()` from `Line`

## [4.2.1] - 2023-12-03

### Changed

- use proper variable as index for array access
- use proper variable as index for array access

## [4.2.0] - 2022-07-25

Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ Update the version constraint in the project's `composer.json` and
run `composer update` or require the new version by running:

```shell
composer require mjaschen/phpgeo:^4.0
composer require mjaschen/phpgeo:^5.0
```

### Upgrading to 5.x

*phpgeo* has some breaking changes in the 5.x release line. Please refer to the following list to see what has changed and what you need to do to upgrade your code.

| Change | Description | Action |
| --- | --- |---------------------------------------------------------|
| `setPoint1()` and `setPoint2()` methods removed from `Line` | The `Line` class now is immutable. | Use the constructor to create a new instance of `Line`. |
| removed support for PHP 7.3, 7.4 and 8.0 | Older PHP versions are no longer supported. | Upgrade to at least PHP 8.1. |

## License

Starting with version 2.0.0 phpgeo is licensed under the MIT license. Older versions were GPL-licensed.
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@
"email" : "[email protected]"
},
"require": {
"php": "^7.3 || ^8.0"
"php": "^8.1"
},
"autoload": {
"psr-4": {
"Location\\": "src/"
}
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.13",
"squizlabs/php_codesniffer": "^3.6"
"phpunit/phpunit": "^10.0",
"vimeo/psalm": "^5.0",
"squizlabs/php_codesniffer": "^3.7"
},
"scripts": {
"ci:composer-validate": "composer validate --no-check-all --no-check-lock --strict",
Expand Down
8 changes: 4 additions & 4 deletions docs/000_Introduction.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# What is *phpgeo?*

_phpgeo_ is a small PHP library which provides abstractions to geographical
*phpgeo* is a small PHP library which provides abstractions to geographical
coordinates (including support for different ellipsoids), polylines
("GPS Tracks"), polygons, bounds, and more. _phpgeo_ allows you to perform
("GPS Tracks"), polygons, bounds, and more. *phpgeo* allows you to perform
different calculations with these abstractions, as distances, track
lengths, etc.

_phpgeo_ is developed by [Marcus Jaschen](https://www.marcusjaschen.de/) and all
*phpgeo* is developed by [Marcus Jaschen](https://www.marcusjaschen.de/) and all
[contributors](https://github.com/mjaschen/phpgeo/graphs/contributors).

_phpgeo_ is licensed under the [MIT License](https://opensource.org/licenses/MIT).
*phpgeo* is licensed under the [MIT License](https://opensource.org/licenses/MIT).

The project is hosted on GitHub:

Expand Down
12 changes: 7 additions & 5 deletions docs/010_Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@

## Requirements

_phpgeo_ requires at least PHP 7.3. _phpgeo_ fully supports PHP 8.
*phpgeo* requires at least PHP 8.1.

The 3.x releases require PHP >= 7.2 but don't get feature updates any longer. Bugfixes will be backported.
The 4.x releases require PHP >= 7.3 but don't get feature updates any longer. Bugfixes will be backported.

The 3.x releases require PHP >= 7.2 but don't get feature updates any longer. Bugfixes won't be backported.

The 2.x releases require PHP >= 7.0 but don't get feature updates any longer. Bugfixes won't be backported.

The 1.x release line has support for PHP >= 5.4. Bugfixes won't be backported.

## Installation

_phpgeo_ is best be installed using Composer. Please visit the
*phpgeo* is best be installed using Composer. Please visit the
[Composer website](https://getcomposer.org/) for more information.

To install _phpgeo,_ simply “require” it using Composer:
To install *phpgeo,* simply “require” it using Composer:

``` shell
composer require mjaschen/phpgeo
```

_phpgeo_ is now ready to be used in your project!
*phpgeo* is now ready to be used in your project!
21 changes: 19 additions & 2 deletions docs/015_Upgrading.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
# Upgrading phpgeo

## Update from phpgeo 4.x to phpgeo 5.x

### Requirements

- *phpgeo* 5.x requires at least PHP 8.1.

### Update phpgeo

- run `composer require mjaschen/phpgeo:^5.0` or
- update the version constraint in your `composer.json` to `^5.0` and run `composer update`

### Update Your Code

`setPoint1()` and `setPoint2()` methods were removed from `Line` – the `Line` class now is immutable. Use the constructor to create a new instance of `Line`.

There are some new deprecations introduced in 5.0, please see the change log for a detailed list and update your code accordingly to be prepared for 6.0.

## Update from phpgeo 3.x to phpgeo 4.x

### Requirements

- _phpgeo_ 4.x requires at least PHP 7.3 and fully supports PHP 8
- *phpgeo* 4.x requires at least PHP 7.3 and fully supports PHP 8

### Update phpgeo

Expand All @@ -22,7 +39,7 @@ No breaking changes were introduced with *phpgeo* 3.0.

### Requirements

- _phpgeo_ 3.x requires at least PHP 7.2
- *phpgeo* 3.x requires at least PHP 7.2

### Update phpgeo

Expand Down
35 changes: 4 additions & 31 deletions docs/020_Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Run Tests

_phpgeo_ provides unit tests with a quite good coverage. For an easy usage,
*phpgeo* provides unit tests with a quite good coverage. For an easy usage,
the test command is wrapped as a Composer script:

``` shell
Expand All @@ -16,39 +16,12 @@ Of course, it's possible to run PHPUnit directly:
```

To test against another PHP version you can use Docker. The following command runs
the tests using PHP 7.3:
the tests using PHP 8.3:

``` shell
docker run -it --rm --name phpgeo-phpunit \
-v "$PWD":/usr/src/phpgeo \
-w /usr/src/phpgeo php:7.3-cli \
php vendor/bin/phpunit
```

Or PHP 7.4:

``` shell
docker run -it --rm --name phpgeo-phpunit \
-v "$PWD":/usr/src/phpgeo \
-w /usr/src/phpgeo php:7.4-cli \
php vendor/bin/phpunit
```

PHP 8.0:

``` shell
docker run -it --rm --name phpgeo-phpunit \
-v "$PWD":/usr/src/phpgeo \
-w /usr/src/phpgeo php:8.0-cli \
php vendor/bin/phpunit
```

PHP 8.1:

``` shell
docker run -it --rm --name phpgeo-phpunit \
-v "$PWD":/usr/src/phpgeo \
-w /usr/src/phpgeo php:8.1-cli \
-w /usr/src/phpgeo php:8.3-cli \
php vendor/bin/phpunit
```

Expand All @@ -74,7 +47,7 @@ composer ci
… or run all CI tasks with different PHP versions one after another:

```shell
for PHP_VERSION in 7.3 7.4 8.0 8.1 ; do \
for PHP_VERSION in 8.1 8.2 8.3 ; do \
docker run -it --rm -v "$PWD":/phpgeo -w /phpgeo \
ghcr.io/mjaschen/php:${PHP_VERSION}-cli-mj composer ci || break ; \
done
Expand Down
13 changes: 7 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<coverage/>
<testsuites>
<testsuite name="Location Test Suite">
<directory>tests/Location/</directory>
<directory>tests/Regression/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0"?>
<psalm
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
38 changes: 6 additions & 32 deletions src/Bearing/BearingEllipsoidal.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* has done. For more information visit the following URL.
*
* @see http://www.movable-type.co.uk/scripts/latlong-vincenty.html
*
* @author Marcus Jaschen <[email protected]>
*/
class BearingEllipsoidal implements BearingInterface
{
Expand All @@ -28,9 +26,6 @@ class BearingEllipsoidal implements BearingInterface
* If the two points share the same location, the bearing
* value will be 0.0.
*
* @param Coordinate $point1
* @param Coordinate $point2
*
* @return float Bearing Angle
*/
public function calculateBearing(Coordinate $point1, Coordinate $point2): float
Expand All @@ -39,62 +34,46 @@ public function calculateBearing(Coordinate $point1, Coordinate $point2): float
return 0.0;
}

return $this->inverseVincenty($point1, $point2)->getBearingInitial();
return $this->inverseVincenty($point1, $point2)->bearingInitial;
}

/**
* Calculates the final bearing between the two points.
*
* @param Coordinate $point1
* @param Coordinate $point2
*
* @return float
* @return float Bearing Angle
*/
public function calculateFinalBearing(Coordinate $point1, Coordinate $point2): float
{
return $this->inverseVincenty($point1, $point2)->getBearingFinal();
return $this->inverseVincenty($point1, $point2)->bearingFinal;
}

/**
* Calculates a destination point for the given point, bearing angle,
* and distance.
*
* @param Coordinate $point
* @param float $bearing the bearing angle between 0 and 360 degrees
* @param float $distance the distance to the destination point in meters
*
* @return Coordinate
*/
public function calculateDestination(Coordinate $point, float $bearing, float $distance): Coordinate
{
return $this->directVincenty($point, $bearing, $distance)->getDestination();
return $this->directVincenty($point, $bearing, $distance)->destination;
}

/**
* Calculates the final bearing angle for a destination point.
* The method expects a starting point point, the bearing angle,
* and the distance to destination.
*
* @param Coordinate $point
* @param float $bearing
* @param float $distance
*
* @return float
* @return float Bearing Angle
*
* @throws NotConvergingException
*/
public function calculateDestinationFinalBearing(Coordinate $point, float $bearing, float $distance): float
{
return $this->directVincenty($point, $bearing, $distance)->getBearingFinal();
return $this->directVincenty($point, $bearing, $distance)->bearingFinal;
}

/**
* @param Coordinate $point
* @param float $bearing
* @param float $distance
*
* @return DirectVincentyBearing
*
* @throws NotConvergingException
*/
private function directVincenty(Coordinate $point, float $bearing, float $distance): DirectVincentyBearing
Expand Down Expand Up @@ -167,11 +146,6 @@ private function directVincenty(Coordinate $point, float $bearing, float $distan
}

/**
* @param Coordinate $point1
* @param Coordinate $point2
*
* @return InverseVincentyBearing
*
* @throws NotConvergingException
*/
private function inverseVincenty(Coordinate $point1, Coordinate $point2): InverseVincentyBearing
Expand Down
Loading