-
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.
Utilise ST_ApproximateMedialAxis pour le calcul des linéaires Littera…
…lis (#942) * Utilise ST_ApproximateMedialAxis pour le calcul des linéaires Litteralis * Ajoute une migration * Ajoute un test
- Loading branch information
1 parent
b7c25ce
commit 4398158
Showing
5 changed files
with
100 additions
and
23 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
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
26 changes: 26 additions & 0 deletions
26
src/Infrastructure/Persistence/Doctrine/BdTopoMigrations/Version20240917103338.php
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Infrastructure\Persistence\Doctrine\BdTopoMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20240917103338 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Install postgis_sfcgal'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('CREATE EXTENSION IF NOT EXISTS postgis_sfcgal'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('DROP EXTENSION IF EXISTS postgis_sfcgal'); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Infrastructure/Persistence/Doctrine/PostGIS/Functions/ST_ApproximateMedialAxis.php
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Infrastructure\Persistence\Doctrine\PostGIS\Functions; | ||
|
||
use Doctrine\ORM\Query\AST\Functions\FunctionNode; | ||
use Doctrine\ORM\Query\AST\Node; | ||
use Doctrine\ORM\Query\Lexer; | ||
use Doctrine\ORM\Query\Parser; | ||
use Doctrine\ORM\Query\SqlWalker; | ||
|
||
class ST_ApproximateMedialAxis extends FunctionNode | ||
{ | ||
protected array $expressions = []; | ||
|
||
public function parse(Parser $parser): void | ||
{ | ||
// Signature: `geometry ST_ApproximateMedialAxis(geometry geom);` | ||
// https://postgis.net/docs/ST_ApproximateMedialAxis.html | ||
$parser->match(Lexer::T_IDENTIFIER); | ||
$parser->match(Lexer::T_OPEN_PARENTHESIS); | ||
$this->expressions[] = $parser->ArithmeticFactor(); | ||
$parser->match(Lexer::T_CLOSE_PARENTHESIS); | ||
} | ||
|
||
public function getSql(SqlWalker $sqlWalker): string | ||
{ | ||
$arguments = []; | ||
|
||
/** @var Node $expression */ | ||
foreach ($this->expressions as $expression) { | ||
$arguments[] = $expression->dispatch($sqlWalker); | ||
} | ||
|
||
return 'ST_ApproximateMedialAxis(' . implode(', ', $arguments) . ')'; | ||
} | ||
} |
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