Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pakastin committed May 31, 2023
2 parents 897a6f9 + 0a899aa commit 38b2f96
Show file tree
Hide file tree
Showing 13 changed files with 311 additions and 22 deletions.
Expand Up @@ -36,6 +36,11 @@
import org.locationtech.jts.geom.Envelope;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sqlite.SQLiteConfig;
import org.sqlite.SQLiteConfig.JournalMode;
import org.sqlite.SQLiteConfig.LockingMode;
import org.sqlite.SQLiteConfig.SynchronousMode;
import org.sqlite.SQLiteConfig.TempStore;
import org.sqlite.SQLiteDataSource;

public record ExportVectorTiles(
Expand All @@ -49,8 +54,6 @@ public record ExportVectorTiles(

@Override
public void execute(WorkflowContext context) throws Exception {


var configReader = new ConfigReader();
var objectMapper = objectMapper();
var tileset = objectMapper.readValue(configReader.read(this.tileset), Tileset.class);
Expand Down Expand Up @@ -78,7 +81,15 @@ private TileStore sourceTileStore(Tileset tileset, DataSource datasource) {

private TileStore targetTileStore(Tileset source) throws TileStoreException, IOException {
if (mbtiles) {
var sqliteConfig = new SQLiteConfig();
sqliteConfig.setCacheSize(1000000);
sqliteConfig.setJournalMode(JournalMode.OFF);
sqliteConfig.setLockingMode(LockingMode.EXCLUSIVE);
sqliteConfig.setSynchronous(SynchronousMode.OFF);
sqliteConfig.setTempStore(TempStore.MEMORY);

var dataSource = new SQLiteDataSource();
dataSource.setConfig(sqliteConfig);
dataSource.setUrl("jdbc:sqlite:" + repository);

var tilesStore = new MBTiles(dataSource);
Expand Down
109 changes: 109 additions & 0 deletions basemap/layers/highway/construction_dash.js
@@ -0,0 +1,109 @@
/**
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing permissions and limitations under
the License.
**/
import {asLayerObject, withSortKeys} from "../../utils/utils.js";

let directives =[
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'motorway'],
],
'line-color': 'rgb(254, 254, 254)',
'road-width': 16,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'trunk'],
],
'line-color': 'rgb(254, 254, 254)',
'road-width': 12,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'primary'],
],
'line-color': 'rgb(254, 254, 254)',
'road-width': 14,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'secondary'],
],
'line-color': 'rgb(254, 254, 254)',
'road-width': 12,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'tertiary'],
],
'line-color': 'rgb(254, 254, 254)',
'road-width': 12,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'unclassified'],
],
'line-color': 'rgb(254, 254, 254)',
'road-width': 8,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'residential'],
],
'line-color': 'rgb(254, 254, 254)',
'road-width': 8,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'living_street'],
],
'line-color': 'rgb(254, 254, 254)',
'road-width': 8,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'service'],
],
'line-color': 'rgb(254, 254, 254)',
'road-width': 8,
},
]

export default asLayerObject(withSortKeys(directives), {
id: 'highway_construction_outline',
source: 'baremaps',
'source-layer': 'highway',
type: 'line',
layout: {
visibility: 'visible',
'line-cap': 'round',
'line-join': 'round',
},
});

136 changes: 136 additions & 0 deletions basemap/layers/highway/construction_line.js
@@ -0,0 +1,136 @@
/**
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing permissions and limitations under
the License.
**/
import {asLayerObject, withSortKeys} from "../../utils/utils.js";

let directives =[
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['any',
['==', ['get', 'construction'], 'motorway'],
['==', ['get', 'construction'], 'motorway_link'],
]
],
'line-color': 'rgb(233, 144, 161)',
'road-width': 16,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['any',
['==', ['get', 'construction'], 'trunk'],
['==', ['get', 'construction'], 'trunk_link'],
]
],
'line-color': 'rgb(250, 193, 172)',
'road-width': 12,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['any',
['==', ['get', 'construction'], 'primary'],
['==', ['get', 'construction'], 'primary_link'],
]
],
'line-color': 'rgb(253, 221, 179)',
'road-width': 14,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['any',
['==', ['get', 'construction'], 'secondary'],
['==', ['get', 'construction'], 'secondary_link'],
]
],
'line-color': 'rgb(248, 250, 202)',
'road-width': 12,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['any',
['==', ['get', 'construction'], 'tertiary'],
['==', ['get', 'construction'], 'tertiary_link'],
]
],
'line-color': 'rgb(190, 189, 188)',
'road-width': 12,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'unclassified'],
],
'line-color': 'rgb(211, 207, 206)',
'road-width': 8,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'residential'],
],
'line-color': 'rgb(211, 207, 206)',
'road-width': 8,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'living_street'],
],
'line-color': 'rgb(207, 207, 207)',
'road-width': 8,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'service'],
],
'line-color': 'rgb(213, 211, 211)',
'road-width': 8,
},
{
filter: [
'all',
['==', ['get', 'highway'], 'construction'],
['==', ['get', 'construction'], 'raceway'],
],
'line-color': 'rgb(213, 211, 211)',
'road-width': 8,
},
]

export default asLayerObject(withSortKeys(directives), {
id: 'highway_construction_line',
source: 'baremaps',
'source-layer': 'highway',
type: 'line',
layout: {
visibility: 'visible',
'line-cap': 'butt',
'line-join': 'round',
},
paint: {
'line-dasharray': [1, 1],
},
});

15 changes: 0 additions & 15 deletions basemap/layers/highway/highway_construction.js

This file was deleted.

5 changes: 5 additions & 0 deletions basemap/layers/highway/highway_dash.js
Expand Up @@ -17,6 +17,11 @@ let directives = [
'line-color': 'rgb(68, 159, 66)',
'road-width': 1,
},
{
filter: ['==', ['get', 'highway'], 'busway'],
'line-color': 'rgb(0, 146, 219)',
'road-width': 1,
},
{
filter: [
'any',
Expand Down
5 changes: 5 additions & 0 deletions basemap/layers/highway/highway_line.js
Expand Up @@ -57,6 +57,11 @@ let directives = [
'line-color': 'rgb(254, 254, 254)',
'road-width': 8,
},
{
filter: ['==', ['get', 'highway'], 'busway'],
'line-color': 'rgb(254, 254, 254)',
'road-width': 8,
},
{
filter: ['==', ['get', 'highway'], 'unclassified'],
'line-color': 'rgb(254, 254, 254)',
Expand Down
6 changes: 6 additions & 0 deletions basemap/layers/highway/highway_outline.js
Expand Up @@ -62,6 +62,12 @@ let directives =[
'road-gap-width': 8,
'road-width': 2,
},
{
filter: ['==', ['get', 'highway'], 'busway'],
'line-color': 'rgb(190, 189, 188)',
'road-gap-width': 8,
'road-width': 2,
},
{
filter: ['==', ['get', 'highway'], 'unclassified'],
'line-color': 'rgb(211, 207, 206)',
Expand Down
10 changes: 7 additions & 3 deletions basemap/layers/highway/prepare.sql
Expand Up @@ -15,14 +15,16 @@ WITH
filtered AS (
SELECT
tags -> 'highway' AS highway,
tags -> 'construction' AS construction,
geom AS geom
FROM osm_linestring
WHERE tags ->> 'highway' IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 'tertiary', 'tertiary_link', 'unclassified', 'residential')
WHERE tags ->> 'highway' IN ('motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 'tertiary', 'tertiary_link', 'unclassified', 'residential', 'construction')
),
-- Cluster the linestrings by highway type
clustered AS (
SELECT
highway AS highway,
construction AS construction,
geom as geom,
ST_ClusterDBSCAN(geom, 0, 1) OVER (PARTITION BY highway) AS cluster
FROM
Expand All @@ -32,23 +34,25 @@ WITH
merged AS (
SELECT
highway AS highway,
construction AS construction,
ST_LineMerge(ST_Collect(geom)) AS geom
FROM
clustered
GROUP BY
highway, cluster
highway, construction, cluster
),
-- Explode the merged linestrings into individual linestrings
exploded AS (
SELECT
highway AS highway,
construction AS construction,
(ST_Dump(geom)).geom AS geom
FROM
merged
)
SELECT
row_number() OVER () AS id,
jsonb_build_object('highway', highway) AS tags,
jsonb_build_object('highway', highway, 'construction', construction) AS tags,
geom AS geom
FROM exploded;

Expand Down
2 changes: 1 addition & 1 deletion basemap/layers/highway/simplify.sql
Expand Up @@ -36,7 +36,7 @@ CREATE MATERIALIZED VIEW osm_highway_z12 AS
SELECT id, tags, geom
FROM (SELECT id, tags, st_simplifypreservetopology(geom, 78270 / power(2, 12)) AS geom FROM osm_highway) AS osm_highway
WHERE geom IS NOT NULL AND (st_area(st_envelope(geom)) > power((78270 / power(2, 12)), 2))
AND tags ->> 'highway' IN ( 'motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 'tertiary', 'tertiary_link', 'unclassified', 'residential');
AND tags ->> 'highway' IN ( 'motorway', 'motorway_link', 'trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', 'tertiary', 'tertiary_link', 'unclassified', 'residential', 'construction');

CREATE MATERIALIZED VIEW osm_highway_z11 AS
SELECT id, tags, geom
Expand Down

0 comments on commit 38b2f96

Please sign in to comment.