Skip to content

Commit

Permalink
Merge pull request #112 from djlambert/dev
Browse files Browse the repository at this point in the history
Reorder statements and an additional test
  • Loading branch information
sadortun committed Nov 9, 2015
2 parents c575499 + a7af02f commit 2b64206
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
16 changes: 9 additions & 7 deletions lib/CrEOF/Spatial/DBAL/Types/StringParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,17 @@ protected function point()
protected function coordinate()
{
$this->match(($this->lexer->isNextToken(StringLexer::T_FLOAT) ? StringLexer::T_FLOAT : StringLexer::T_INTEGER));

if($this->lexer->isNextToken(StringLexer::T_E)){
$number = $this->lexer->token['value'];
$this->match(StringLexer::T_E);
$this->match(StringLexer::T_INTEGER);
return $number*pow(10,$this->lexer->token['value']);

if (! $this->lexer->isNextToken(StringLexer::T_E)) {
return $this->lexer->token['value'];
}

return $this->lexer->token['value'];
$number = $this->lexer->token['value'];

$this->match(StringLexer::T_E);
$this->match(StringLexer::T_INTEGER);

return $number * pow(10, $this->lexer->token['value']);
}

protected function lineString()
Expand Down
18 changes: 14 additions & 4 deletions tests/CrEOF/Spatial/Tests/DBAL/Types/StringLexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function testScannerRecognizesSrid()

public function testScannerTokenizesGeometryValueCorrectly()
{
$value = 'SRID=4326;LINESTRING(0 0.0, 10.1 -10.025, 20.5 25.9, 50 60)';
$value = 'SRID=4326;LINESTRING(0 0.0, 10.1 -10.025, 20.5 25.9, 53E-003 60)';
$tokens = array(
array(
'value' => 'SRID',
Expand Down Expand Up @@ -259,19 +259,29 @@ public function testScannerTokenizesGeometryValueCorrectly()
'position' => 51
),
array(
'value' => 50,
'value' => 53,
'type' => StringLexer::T_INTEGER,
'position' => 53
),
array(
'value' => 60,
'value' => 'E',
'type' => StringLexer::T_E,
'position' => 55
),
array(
'value' => -3,
'type' => StringLexer::T_INTEGER,
'position' => 56
),
array(
'value' => 60,
'type' => StringLexer::T_INTEGER,
'position' => 61
),
array(
'value' => ')',
'type' => StringLexer::T_CLOSE_PARENTHESIS,
'position' => 58
'position' => 63
)
);

Expand Down
4 changes: 2 additions & 2 deletions tests/CrEOF/Spatial/Tests/DBAL/Types/StringParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public function testParsingPointValueMissingCoordinate()

$parser->parse();
}
public function testParsingPointScientificValueWithSrid()

public function testParsingPointScientificValueWithSrid()
{
$value = 'SRID=4326;POINT(4.23e-005 -8E-003)';
$parser = new StringParser($value);
Expand Down

0 comments on commit 2b64206

Please sign in to comment.