-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
217e6f5
commit 03d2e30
Showing
6 changed files
with
188 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Active Collab DatabaseConnection project. | ||
* | ||
* (c) A51 doo <[email protected]>. All rights reserved. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ActiveCollab\DatabaseConnection\Spatial\MultiLineString; | ||
|
||
use ActiveCollab\DatabaseConnection\Spatial\LineString\LineStringInterface; | ||
|
||
class MultiLineString implements MultiLineStringInterface | ||
{ | ||
/** | ||
* @var LineStringInterface[] | ||
*/ | ||
private array $lines; | ||
|
||
public function __construct(LineStringInterface ...$lines) | ||
{ | ||
$this->lines = $lines; | ||
} | ||
|
||
public function getLines(): array | ||
{ | ||
return $this->lines; | ||
} | ||
|
||
public function toWkt(): string | ||
{ | ||
return sprintf('MULTILINESTRING(%s)', $this); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return implode( | ||
',', | ||
array_map( | ||
function (LineStringInterface $line_string) { | ||
return sprintf('(%s)', $line_string); | ||
}, | ||
$this->getLines() | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Active Collab DatabaseConnection project. | ||
* | ||
* (c) A51 doo <[email protected]>. All rights reserved. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ActiveCollab\DatabaseConnection\Spatial\MultiLineString; | ||
|
||
use ActiveCollab\DatabaseConnection\Spatial\GeometricObjectInterface; | ||
|
||
interface MultiLineStringInterface extends GeometricObjectInterface | ||
{ | ||
public function getLines(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Active Collab DatabaseStructure project. | ||
* | ||
* (c) A51 doo <[email protected]>. All rights reserved. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ActiveCollab\DatabaseConnection\Test\Spatial; | ||
|
||
use ActiveCollab\DatabaseConnection\Spatial\Coordinate\Coordinate; | ||
use ActiveCollab\DatabaseConnection\Spatial\LineString\LineString; | ||
use ActiveCollab\DatabaseConnection\Spatial\MultiLineString\MultiLineString; | ||
use ActiveCollab\DatabaseConnection\Spatial\Point\Point; | ||
use ActiveCollab\DatabaseConnection\Test\Base\TestCase; | ||
|
||
class MultiLineStringTest extends TestCase | ||
{ | ||
public function testWillRenderWtk(): void | ||
{ | ||
$this->assertSame( | ||
'MULTILINESTRING((45.60317644 19.27315063,45.60312479 19.27319189,45.60473116 19.27750116,45.60478264 19.27745963),(45.60449426 19.27769178,45.60431683 19.27783455,45.60270942 19.27352285,45.60288728 19.27338113))', | ||
(new MultiLineString( | ||
new LineString( | ||
new Point(new Coordinate(45.60317644), new Coordinate(19.27315063)), | ||
new Point(new Coordinate(45.60312479), new Coordinate(19.27319189)), | ||
new Point(new Coordinate(45.60473116), new Coordinate(19.27750116)), | ||
new Point(new Coordinate(45.60478264), new Coordinate(19.27745963)), | ||
), | ||
|
||
new LineString( | ||
new Point(new Coordinate(45.60449426), new Coordinate(19.27769178)), | ||
new Point(new Coordinate(45.60431683), new Coordinate(19.27783455)), | ||
new Point(new Coordinate(45.60270942), new Coordinate(19.27352285)), | ||
new Point(new Coordinate(45.60288728), new Coordinate(19.27338113)), | ||
), | ||
))->toWkt() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters