Skip to content

Commit d4c4654

Browse files
committed
Add version 0.1.20
1 parent 3f8112e commit d4c4654

5 files changed

Lines changed: 22 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## Releases
99

10+
### [0.1.20] - 2023-08-28
11+
12+
* Add getRaw method to Coordinate class
13+
1014
### [0.1.19] - 2023-08-16
1115

1216
* Fix -0 detection

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.19
1+
0.1.20

src/Base/BaseCoordinate.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
abstract class BaseCoordinate
3131
{
32+
protected string $raw;
33+
3234
protected CoordinateValueLatitude $latitude;
3335

3436
protected CoordinateValueLongitude $longitude;
@@ -53,6 +55,8 @@ public function __construct()
5355
throw new CaseUnsupportedException('No coordinates are given.');
5456
}
5557

58+
$this->raw = implode(' ', $arguments);
59+
5660
$result = match (true) {
5761
/* 1 argument as string given. */
5862
count($arguments) === self::ARGUMENTS_1 && is_string($arguments[0]) =>

src/Base/BaseCoordinateParser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use DateTimeZone;
1717
use Exception;
18-
use Ixnode\PhpException\ArrayType\ArrayKeyNotFoundException;
1918
use Ixnode\PhpException\Case\CaseUnsupportedException;
2019

2120
/**
@@ -93,6 +92,8 @@ abstract class BaseCoordinateParser
9392

9493
protected const VERSION_V2 = 'v2';
9594

95+
protected const VALUE_ZERO_NEGATIVE = '-0';
96+
9697
protected string $coordinate;
9798

9899
private ?string $error = null;
@@ -213,7 +214,7 @@ protected function getFloatValueFromSimple(array $matches): float
213214
$integerConverted = (float) $matches[1];
214215
$decimalsConverted = floatval(intval($matches[2]) * 10 ** (-strlen($matches[2])));
215216

216-
$isNegative = $integerConverted < 0 || $matches[1] === '-0';
217+
$isNegative = $integerConverted < 0 || $matches[1] === self::VALUE_ZERO_NEGATIVE;
217218

218219
return $integerConverted + ($isNegative ? -1 : 1) * $decimalsConverted;
219220
}

src/Coordinate.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ public function getLongitudeDMS(string $format = BaseCoordinateValue::FORMAT_DMS
121121
return $this->longitude->getDms($format);
122122
}
123123

124+
/**
125+
* Returns the given raw string.
126+
*
127+
* @return string
128+
*/
129+
public function getRaw(): string
130+
{
131+
return $this->raw;
132+
}
133+
124134
/**
125135
* Returns the string representation of the coordinate.
126136
*

0 commit comments

Comments
 (0)