Skip to content

Commit

Permalink
Crée une vue sur les restrictions servie par pg_featureserv
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca committed Nov 7, 2024
1 parent 4c52c6b commit a40463e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,12 @@ services:
# Allow accessing host ports from this container via host.docker.internal on Linux
# https://stackoverflow.com/a/43541732
- host.docker.internal:host-gateway

pg_featureserv:
# https://github.com/crunchydata/pg_featureserv
image: pramsey/pg_featureserv:20240706
ports:
- 8889:8889
environment:
DATABASE_URL: "postgresql://dialog:dialog@database:5432/dialog_featureserver" # TODO: config
PGFS_SERVER_HTTPPORT: 8889
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace App\Infrastructure\Persistence\Doctrine\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20241107095421 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
$this->addSql('CREATE MATERIALIZED VIEW featureserver_restrictions AS
SELECT
loc.geometry::geometry(geometry, 4326) AS geometry,
m.type AS measure_type,
p.start_datetime,
p.end_datetime,
v.restricted_types,
v.other_restricted_type_text,
v.exempted_types,
v.other_exempted_type_text,
v.critair_types,
v.heavyweight_max_weight,
v.max_width,
v.max_length,
v.max_height,
loc.road_type AS location_type,
ns.city_code,
ns.city_label,
ns.road_name,
nr.road_number,
nr.administrator,
nr.from_point_number,
nr.from_side,
nr.from_abscissa,
nr.to_point_number,
nr.to_side,
nr.to_abscissa,
rg.label AS geojson_label
FROM period AS p
INNER JOIN measure AS m ON m.uuid = p.measure_uuid
INNER JOIN location AS loc ON loc.measure_uuid = m.uuid
LEFT OUTER JOIN vehicle_set AS v ON v.measure_uuid = m.uuid
LEFT OUTER JOIN named_street AS ns ON ns.location_uuid = loc.uuid
LEFT OUTER JOIN numbered_road AS nr ON nr.location_uuid = nr.uuid
LEFT OUTER JOIN raw_geojson AS rg ON rg.location_uuid = rg.uuid
WITH DATA
');
}

public function down(Schema $schema): void
{
$this->addSql('DROP MATERIALIZED VIEW featureserver_restrictions');
}
}

0 comments on commit a40463e

Please sign in to comment.