forked from venetoarpa/Arpav-PPCV-backend
-
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.
Merge pull request #130 from ricardogsilva/integrate-vector-tile-server
Integrate traefik, vector tile server and municipalities
- Loading branch information
Showing
14 changed files
with
280 additions
and
6 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
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
40 changes: 40 additions & 0 deletions
40
arpav_ppcv/migrations/versions/9b9809ef3088_added_municipalities_table.py
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,40 @@ | ||
"""added municipalities table | ||
Revision ID: 9b9809ef3088 | ||
Revises: 74ee5bc68b7e | ||
Create Date: 2024-06-10 18:36:54.099021 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
import sqlmodel | ||
from geoalchemy2 import Geometry | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '9b9809ef3088' | ||
down_revision: Union[str, None] = '74ee5bc68b7e' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_geospatial_table('municipality', | ||
sa.Column('id', sqlmodel.sql.sqltypes.GUID(), nullable=False), | ||
sa.Column('geom', Geometry(geometry_type='MULTIPOLYGON', srid=4326, spatial_index=False, from_text='ST_GeomFromEWKT', name='geometry'), nullable=True), | ||
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
sa.Column('province_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
sa.Column('region_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_geospatial_index('idx_municipality_geom', 'municipality', ['geom'], unique=False, postgresql_using='gist', postgresql_ops={}) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_geospatial_index('idx_municipality_geom', table_name='municipality', postgresql_using='gist', column_name='geom') | ||
op.drop_geospatial_table('municipality') | ||
# ### end Alembic commands ### |
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,34 @@ | ||
import uuid | ||
|
||
import geoalchemy2 | ||
import geojson_pydantic | ||
import pydantic | ||
import sqlalchemy | ||
import sqlmodel | ||
|
||
from . import fields | ||
|
||
|
||
class Municipality(sqlmodel.SQLModel, table=True): | ||
model_config = pydantic.ConfigDict(arbitrary_types_allowed=True) | ||
|
||
id: pydantic.UUID4 = sqlmodel.Field(default_factory=uuid.uuid4, primary_key=True) | ||
geom: fields.WkbElement = sqlmodel.Field( | ||
sa_column=sqlalchemy.Column( | ||
geoalchemy2.Geometry( | ||
srid=4326, | ||
geometry_type="MULTIPOLYGON", | ||
spatial_index=True, | ||
) | ||
) | ||
) | ||
name: str | ||
province_name: str | ||
region_name: str | ||
|
||
|
||
class MunicipalityCreate(sqlmodel.SQLModel): | ||
geom: geojson_pydantic.MultiPolygon | ||
name: str | ||
province_name: str | ||
region_name: str |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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,33 @@ | ||
listen_addresses: '0.0.0.0:3000' | ||
cache_size_mb: 512 | ||
postgres: | ||
connection_string: ${DATABASE_URL} | ||
auto_publish: false | ||
tables: | ||
|
||
stations: | ||
schema: public | ||
table: station | ||
srid: 4326 | ||
geometry_column: geom | ||
id_column: ~ | ||
geometry_type: POINT | ||
properties: | ||
name: varchar | ||
code: varchar | ||
id: uuid | ||
active_since: date | ||
active_until: date | ||
|
||
municipalities: | ||
schema: public | ||
table: municipality | ||
srid: 4326 | ||
geometry_column: geom | ||
id_column: ~ | ||
geometry_type: MULTIPOLYGON | ||
properties: | ||
id: uuid | ||
name: varchar | ||
province_name: varchar | ||
region_name: varchar |
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,24 @@ | ||
# Static configuration file for traefik | ||
# | ||
# In this file we mostly configure providers, entrypoints and security. | ||
# Routers, the other major part of a traefik configuration, form the | ||
# so-called 'dynamic configuration' and in this case are gotten from | ||
# the labels associated with the docker provider | ||
# | ||
# More info: | ||
# | ||
# https://doc.traefik.io/traefik/ | ||
|
||
[accessLog] | ||
|
||
[entryPoints] | ||
[entryPoints.web] | ||
address = ":80" | ||
|
||
[providers] | ||
|
||
[providers.docker] | ||
exposedByDefault = false | ||
|
||
[api] | ||
insecure = true |
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,34 @@ | ||
# Static configuration file for traefik | ||
# | ||
# In this file we mostly configure providers, entrypoints and security. | ||
# Routers, the other major part of a traefik configuration, form the | ||
# so-called 'dynamic configuration' and in this case are gotten from | ||
# the labels associated with the docker provider | ||
# | ||
# More info: | ||
# | ||
# https://doc.traefik.io/traefik/ | ||
|
||
[accessLog] | ||
|
||
[entryPoints] | ||
[entryPoints.webSecure] | ||
address = ":443" | ||
|
||
[entryPoints.webSecure.forwardedHeaders] | ||
insecure = true | ||
|
||
[providers] | ||
|
||
[providers.docker] | ||
exposedByDefault = false | ||
|
||
[certificatesResolvers.letsEncryptResolver.acme] | ||
email = "[email protected]" | ||
storage = "/opt/traefik/certs/acme.json" | ||
|
||
# Default: "https://acme-v02.api.letsencrypt.org/directory" | ||
# the default is the production lets encrypt server | ||
# caServer = "https://acme-staging-v02.api.letsencrypt.org/directory" | ||
|
||
[certificatesResolvers.letsEncryptResolver.acme.tlsChallenge] |