File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1- 0.1.19
1+ 0.1.20
Original file line number Diff line number Diff line change 2929 */
3030abstract 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 ]) =>
Original file line number Diff line number Diff line change 1515
1616use DateTimeZone ;
1717use Exception ;
18- use Ixnode \PhpException \ArrayType \ArrayKeyNotFoundException ;
1918use 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 }
Original file line number Diff line number Diff 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 *
You can’t perform that action at this time.
0 commit comments