Skip to content

Commit

Permalink
Release 2024-12-16 (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
tordans authored Dec 16, 2024
2 parents 7e0e5c0 + f6d4348 commit 772a070
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 115 deletions.
5 changes: 3 additions & 2 deletions app.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM node:18-bullseye-slim AS base

WORKDIR /app

COPY /app/package*.json /app/
COPY /app/patches /app/patches

RUN npm install-clean --legacy-peer-deps
RUN npm run postinstall

Expand All @@ -13,12 +15,11 @@ EXPOSE 4000
ENV NEXT_TELEMETRY_DISABLED=1
ENV TZ=Europe/Berlin

RUN npx blitz@2.1.0 prisma generate

ARG NEXT_PUBLIC_APP_ORIGIN
ARG NEXT_PUBLIC_APP_ENV
ARG NEXT_PUBLIC_OSM_API_URL

RUN npx blitz@2.1.0 prisma generate
RUN npx blitz@2.1.0 build

CMD npx blitz@2.1.0 prisma migrate deploy && npx blitz@2.1.0 start -p 4000

Check warning on line 25 in app.Dockerfile

View workflow job for this annotation

GitHub Actions / deploy_app / build_app

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
Expand Down
78 changes: 37 additions & 41 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"blitz": "2.1.3",
"date-fns": "4.1.0",
"dompurify": "^3.1.7",
"eslint-plugin-react-compiler": "0.0.0-experimental-fa06e2c-20241016",
"geojson": "0.5.0",
"immer": "10.1.1",
"js-cookie": "3.0.5",
Expand All @@ -98,7 +97,6 @@
"react-hook-form": "7.53.1",
"react-intl": "^6.8.1",
"react-map-gl": "7.1.7",
"react-popper": "^2.3.0",
"react-remark": "^2.1.0",
"secure-password": "4.0.0",
"server-only": "0.0.1",
Expand Down Expand Up @@ -142,6 +140,7 @@
"eslint": "8.57.1",
"eslint-config-next": "14.2.16",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
"husky": "9.1.6",
"jsdom": "25.0.1",
"minimatch": "9.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ export const staticDatasetCategories = {
title: 'Netze',
subtitle: 'Statische Geodaten zum Straßennetz und Radinfrastruktur.',
},
'berlin/cc': {
order: 1,
title: 'Changing Cities Monitoring',
subtitle: 'Statische Geodaten zum Monitoring des Radnetzes von Changing Cities.',
},
} as const
57 changes: 32 additions & 25 deletions app/src/registerSQLFunctions/registerExportFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,39 @@ export async function registerExportFunctions(tables: typeof exportApiIdentifier
const tagKeys = tagKeyQuery.map(({ key }) => `tags->>'${key}' as "${key}"`).join(',')
const metaKeys = metaKeyQuery.map(({ key }) => `meta->>'${key}' as "${key}"`).join(',')

if (!tagKeys || !metaKeys) {
console.error(
'Failed to `registerExportFunctions` because required tagKeys and metaKeys are empty',
{ functionName, tagKeyQuery, metaKeyQuery },
)
}

return geoDataClient.$transaction([
geoDataClient.$executeRawUnsafe(
`DROP FUNCTION IF EXISTS public."${functionName}"(region Geometry(Polygon));`,
),
geoDataClient.$executeRawUnsafe(
`CREATE FUNCTION public."${functionName}"(region Geometry(Polygon))
RETURNS BYTEA
LANGUAGE plpgsql
AS $$
DECLARE
fgb BYTEA;
BEGIN
SELECT ST_AsFlatGeobuf(q, false, 'geom') INTO fgb FROM (
SELECT st_transform(geom, 4326) AS geom,
id,
osm_id,
osm_type::text,
${tagKeys},
${metaKeys}
FROM "${tableName}"
WHERE geom && ST_Transform(region, 3857) AND minzoom > -1
) q;
RETURN fgb;
END;
$$;`,
),
geoDataClient.$executeRawUnsafe(`
DROP FUNCTION IF EXISTS public."${functionName}"(region Geometry(Polygon));
`),
geoDataClient.$executeRawUnsafe(`
CREATE FUNCTION public."${functionName}"(region Geometry(Polygon))
RETURNS BYTEA
LANGUAGE plpgsql
AS $$
DECLARE
fgb BYTEA;
BEGIN
SELECT ST_AsFlatGeobuf(q, false, 'geom') INTO fgb FROM (
SELECT st_transform(geom, 4326) AS geom,
id,
osm_id,
osm_type::text,
${tagKeys},
${metaKeys}
FROM "${tableName}"
WHERE geom && ST_Transform(region, 3857) AND minzoom > -1
) q;
RETURN fgb;
END;
$$;
`),
])
}),
)
Expand Down
70 changes: 35 additions & 35 deletions app/src/registerSQLFunctions/registerGeneralizationFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,41 +68,41 @@ export async function registerGeneralizationFunctions() {
const tileSpecification = await createTileSpecification(tableName as TableId)

return geoDataClient.$transaction([
geoDataClient.$executeRawUnsafe(
`CREATE OR REPLACE
FUNCTION public."${functionName}"(z integer, x integer, y integer)
RETURNS bytea AS $$
DECLARE
mvt bytea;
tolerance float;
BEGIN
IF z BETWEEN ${SIMPLIFY_MIN_ZOOM} AND ${SIMPLIFY_MAX_ZOOM - 1} THEN
tolerance = 10 * POWER(2, ${SIMPLIFY_MAX_ZOOM - 1}-z);
ELSE
tolerance = 0;
END IF;
SELECT INTO mvt ST_AsMVT(tile, '${tableName}', 4096, 'geom') FROM (
SELECT
id,
ST_AsMVTGeom(
ST_CurveToLine(
ST_Simplify(geom, tolerance, true)
),
ST_TileEnvelope(z, x, y), 4096, 64, true) AS geom,
CASE WHEN z >= ${fullTagsMinZoom} THEN tags ELSE atlas_jsonb_select(tags, ${toSqlArray(
stylingKeys,
)}) END as tags,
CASE WHEN z >= ${fullTagsMinZoom} THEN meta ELSE NULL END as meta
FROM "${tableName}"
WHERE (geom && ST_TileEnvelope(z, x, y)) AND z >= minzoom
) AS tile;
RETURN mvt;
END
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE;`,
),
geoDataClient.$executeRawUnsafe(
`COMMENT ON FUNCTION ${functionName} IS '${JSON.stringify(tileSpecification)}';`,
),
geoDataClient.$executeRawUnsafe(`
CREATE OR REPLACE
FUNCTION public."${functionName}"(z integer, x integer, y integer)
RETURNS bytea AS $$
DECLARE
mvt bytea;
tolerance float;
BEGIN
IF z BETWEEN ${SIMPLIFY_MIN_ZOOM} AND ${SIMPLIFY_MAX_ZOOM - 1} THEN
tolerance = 10 * POWER(2, ${SIMPLIFY_MAX_ZOOM - 1}-z);
ELSE
tolerance = 0;
END IF;
SELECT INTO mvt ST_AsMVT(tile, '${tableName}', 4096, 'geom') FROM (
SELECT
id,
ST_AsMVTGeom(
ST_CurveToLine(
ST_Simplify(geom, tolerance, true)
),
ST_TileEnvelope(z, x, y), 4096, 64, true) AS geom,
CASE WHEN z >= ${fullTagsMinZoom} THEN tags ELSE atlas_jsonb_select(tags, ${toSqlArray(
stylingKeys,
)}) END as tags,
CASE WHEN z >= ${fullTagsMinZoom} THEN meta ELSE NULL END as meta
FROM "${tableName}"
WHERE (geom && ST_TileEnvelope(z, x, y)) AND z >= minzoom
) AS tile;
RETURN mvt;
END
$$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE;
`),
geoDataClient.$executeRawUnsafe(`
COMMENT ON FUNCTION ${functionName} IS '${JSON.stringify(tileSpecification)}';
`),
])
},
),
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ services:
NEXT_PUBLIC_APP_ENV:
NEXT_PUBLIC_OSM_API_URL:
NEXT_PUBLIC_APP_ORIGIN:
SESSIONS_SECRET_KEY:
SESSION_SECRET_KEY:
OSM_CLIENT_ID:
OSM_CLIENT_SECRET:
Expand Down
Loading

0 comments on commit 772a070

Please sign in to comment.