Skip to content

Commit 2b64206

Browse files
committed
Merge pull request #112 from djlambert/dev
Reorder statements and an additional test
2 parents c575499 + a7af02f commit 2b64206

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

lib/CrEOF/Spatial/DBAL/Types/StringParser.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,17 @@ protected function point()
122122
protected function coordinate()
123123
{
124124
$this->match(($this->lexer->isNextToken(StringLexer::T_FLOAT) ? StringLexer::T_FLOAT : StringLexer::T_INTEGER));
125-
126-
if($this->lexer->isNextToken(StringLexer::T_E)){
127-
$number = $this->lexer->token['value'];
128-
$this->match(StringLexer::T_E);
129-
$this->match(StringLexer::T_INTEGER);
130-
return $number*pow(10,$this->lexer->token['value']);
125+
126+
if (! $this->lexer->isNextToken(StringLexer::T_E)) {
127+
return $this->lexer->token['value'];
131128
}
132129

133-
return $this->lexer->token['value'];
130+
$number = $this->lexer->token['value'];
131+
132+
$this->match(StringLexer::T_E);
133+
$this->match(StringLexer::T_INTEGER);
134+
135+
return $number * pow(10, $this->lexer->token['value']);
134136
}
135137

136138
protected function lineString()

tests/CrEOF/Spatial/Tests/DBAL/Types/StringLexerTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public function testScannerRecognizesSrid()
181181

182182
public function testScannerTokenizesGeometryValueCorrectly()
183183
{
184-
$value = 'SRID=4326;LINESTRING(0 0.0, 10.1 -10.025, 20.5 25.9, 50 60)';
184+
$value = 'SRID=4326;LINESTRING(0 0.0, 10.1 -10.025, 20.5 25.9, 53E-003 60)';
185185
$tokens = array(
186186
array(
187187
'value' => 'SRID',
@@ -259,19 +259,29 @@ public function testScannerTokenizesGeometryValueCorrectly()
259259
'position' => 51
260260
),
261261
array(
262-
'value' => 50,
262+
'value' => 53,
263263
'type' => StringLexer::T_INTEGER,
264264
'position' => 53
265265
),
266266
array(
267-
'value' => 60,
267+
'value' => 'E',
268+
'type' => StringLexer::T_E,
269+
'position' => 55
270+
),
271+
array(
272+
'value' => -3,
268273
'type' => StringLexer::T_INTEGER,
269274
'position' => 56
270275
),
276+
array(
277+
'value' => 60,
278+
'type' => StringLexer::T_INTEGER,
279+
'position' => 61
280+
),
271281
array(
272282
'value' => ')',
273283
'type' => StringLexer::T_CLOSE_PARENTHESIS,
274-
'position' => 58
284+
'position' => 63
275285
)
276286
);
277287

tests/CrEOF/Spatial/Tests/DBAL/Types/StringParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public function testParsingPointValueMissingCoordinate()
100100

101101
$parser->parse();
102102
}
103-
104-
public function testParsingPointScientificValueWithSrid()
103+
104+
public function testParsingPointScientificValueWithSrid()
105105
{
106106
$value = 'SRID=4326;POINT(4.23e-005 -8E-003)';
107107
$parser = new StringParser($value);

0 commit comments

Comments
 (0)