Wykres commitów

1239 Commity (81d29fff2b325859b34b4a1d2f50bbf4a047b2d4)

Autor SHA1 Wiadomość Data
Brian Sperlongano 91c6d3bbd1
Update ETL docs on landcover layer (#1258)
While reviewing #1255, it became apparent that the ETL documentation for the landcover layer was incomplete.  This PR updates the ETL documentation in `generalized.sql` so that each table has a node in the ETL diagram.
2021-10-07 15:54:13 -04:00
zstadler 8ec986e01d
Expose `make all` errors (#1254)
Avoid redirection of error messages to output files
- build/openmaptiles.tm2source/data.yml
- build/mapping.yaml

Currently, if an error occurs when `make all` creates any of these files, the error message is not printed to the console.
```
docker-compose run --rm --user=1000:1000 openmaptiles-tools generate-tm2source openmaptiles.yaml --host="postgres" --port=5432 --database="openmaptiles" --user="openmaptiles" --password="openmaptiles" > build/openmaptiles.tm2source/data.yml
Creating openmaptiles_openmaptiles-tools_run ... done
ERROR: 1
make: *** [Makefile:257: build/openmaptiles.tm2source/data.yml] Error 1
```

An inexperienced user would not know where to look for the details.

With this PR, the error is sent to the console:
```
docker-compose run --rm --user=1000:1000 openmaptiles-tools bash -c \
        'generate-tm2source openmaptiles.yaml --host="postgres" --port=5432 --database="openmaptiles" --user="openmaptiles" --password="openmaptiles" > build/openmaptiles.tm2source/data.yml'
Creating openmaptiles_openmaptiles-tools_run ... done
Could not parse /tileset/layers/aeroway/mapping.yaml
found undefined alias 'refkjbkjkhh'
  in "/tileset/layers/aeroway/mapping.yaml", line 94, column 7
ERROR: 1
make: *** [Makefile:257: build/openmaptiles.tm2source/data.yml] Error 1
```

Redirection of stdout is now done in the container, leaving stderr to go to the host.
2021-10-06 18:02:52 +02:00
zstadler 596f44aa26
Integrity check for DIFF mode (#1245)
This test applies 2-3 months of weekly updates on the `europe/monaco` extract from [Geofabrik](http://download.geofabrik.de/europe/).

It is worth noting that the contents of the updates may vary, and some SQL update flows may not be tested if the relevant changes did not occur during that period.

Resolves #1226
2021-09-29 15:55:19 +02:00
zstadler ed65036766
Restore `make psql` acceptance of SQL from stdin (#1250)
Following https://osmus.slack.com/archives/CH6GFAFRC/p1632824401121100?thread_ts=1632711389.118900&cid=CH6GFAFRC
2021-09-29 14:51:00 +02:00
Brian Sperlongano 718e79a704
Fix park polygon update SQL (#1248)
This PR fixes a bug in the park polygon update code introduced in #1160.  Because park polygons at zoom 4 are dissolved, the centroid is not present in the table at that layer.  Thus, a separate update trigger is needed to avoid errors.  This PR adds the separate trigger for the zoom 4 park layer.

This PR likely resolves an unidentified blocker for #1245
2021-09-29 13:40:16 +02:00
Brian Sperlongano b4b897999d
Replace osmborder with imposm/SQL (#1213)
Fixes #1156
Fixes #810
Fixes #1228

This PR replaces `osmborder`, which is no longer maintained, with `imposm` mappings and SQL code to generate borders.  Key features that were moved into the imposm/SQL layer:
1. Grouping by `osm_id` and aggregating by lowest `admin_level` value so that there's only one copy of ways that are members of multiple relations.
2. Filtering out of point features in boundary relations (typically `admin_centre` and `label` roles).
3. Move disputed boundary detection logic into SQL.

This will increase the database size slightly because of the limits of what imposm can do, as some of the filtering is done in the SQL layer after importing, rather than being done in `osmborder`.
2021-09-29 11:08:55 +02:00
Brian Sperlongano bfdbd829dc
Fix typo in transportation update (#1247)
This PR fixes a copy/paste error (identified by @zstadler's ongoing excellent work for update unit tests) in the `transportation_name` update code.
2021-09-24 16:16:31 +02:00
Brian Sperlongano 88389f2a2c
BUGFIX: Route concurrency data is wiped after route member updates (#1239)
This PR is a bugfix for the `transportation_name` layer.  Currently, the updates process does not work, as noted by @zstadler in #1230.  The issue is that the computed `concurrency_index` column in `osm_route_member` is never updated after the initial updates.  Therefore, whenever route member ways are updated, they will lose their route concurrency index, and hence route concurrencies will be lost in the `transportation_name` tiles.  This PR adds the missing concurrency index update code to the transportation/network update triggers.

This PR as written also incorporates the fixes in #1230 and #1233.

The following SQL is a unit test to demonstrate that these triggers work correctly:

```
select count(*) from osm_route_member where concurrency_index > 5;
select count(*) from osm_transportation_name_network where route_6 is not null;

update osm_route_member set concurrency_index=NULL where concurrency_index > 5;

select count(*) from osm_route_member where concurrency_index > 5;
select count(*) from osm_transportation_name_network where route_6 is not null;
```

If working correctly, both pairs of `count(*)` values should return the same pair of numbers.
2021-09-21 12:56:25 +02:00
Falke Design 6f0ab57547
Print error of `import-sql` at the end of the output (#1237)
Because of the parallel processing of `import-sql` the error message is printed in the middle of the output. With this PR the error is displayed again at the end:
![grafik](https://user-images.githubusercontent.com/19800037/133897373-656ed3d0-e580-4f67-9290-0e83949d63d7.png)

Issue: https://github.com/openmaptiles/openmaptiles-tools/pull/370

```
awk '1{print; fflush()} $$0~".*ERROR" {txt=$$0} END{ if(txt){print "\n*** ERROR detected, aborting:"; print txt; exit(1)} }'
```
Explanation:
- `1{print; fflush()}` means if true then print output -> `1{}` same as `if(true){}`
- `$$0~".*ERROR" {txt=$$0}` get first argument `$$0` (line of output) and check if it contains (regex string) `ERROR`. If true save line to var `txt`: `{txt=$$0}`
- `END{ ... }` if last line of output is reached
- `if(txt){print "\n*** ERROR detected, aborting:"; print txt; exit(1)}` if error was found in a line / var `txt` is existing print it out
2021-09-21 10:42:50 +02:00
Brian Sperlongano 8b6e69e440
BUGFIX: Ignore duplicate route concurrencies (#1233)
While troubleshooting #1230, I discovered that there were cases where a way was a member of the same route relation more than once, such as: https://www.openstreetmap.org/way/17439235

<img src="https://user-images.githubusercontent.com/3254090/133726616-acd01332-343e-4930-ad3d-1fb3c3190a4c.png" width=280/>

This segment would end up showing duplicate highway shields in a rendered style, which is not desirable.  While I personally think this style of tagging is wrong, it's a relatively easy fix to remove those duplicates.  This PR replaces `ROW_NUMBER()` with `DENSE_RANK()` in the concurrency index generation code and adds a `DISTINCT` constraint on the concurrency join to handle multiple member rows with the same concurrency index.

Since I was in this file, I also fixed the copy/paste error in generating the route names.

Screenshot from database showing correct mapping:
![image](https://user-images.githubusercontent.com/3254090/133725554-1aa5dbbc-59a8-4674-a446-b92adb96c2a1.png)
2021-09-20 18:40:36 +02:00
zstadler 5b0c28929f
Integrity check to generate zoom 14 tiles (#1231)
Setting the MIN/MAX zoom levels in the `env` section had no effect since the values in the `.env` file have higher precedence.

See the currently effective `maxzoom = 7` value in [a typical integrity check log]( https://github.com/openmaptiles/openmaptiles/pull/1223/checks#step:3:3546).
2021-09-20 17:09:18 +02:00
Jaroslav Hanslík d49f524edd
Removed useless NULLIF calls (#1214)
`NULLIF(wikipedia, '') IS NOT NULL` replaced by `wikipedia <> ''`
https://stackoverflow.com/questions/23766084/best-way-to-check-for-empty-or-null-value
2021-09-20 11:19:24 +02:00
Brian Sperlongano e8a3bc18c5
Remove landuse=park from landcover (#1208)
The tag `landuse=park` is a rare tagging mistake of `leisure=park`.  The OSM wiki [lists this tag as a mistake](https://wiki.openstreetmap.org/wiki/Tag:leisure%3Dpark).  It is included in the landcover layer with a note that there were (at the time) 600 parks tagged in this way.  There are currently a bit over 100 objects tagged with this mistake.  Based on the wiki documentation and obvious decline of this tag, we should remove it so that we're not introducing mapping mistakes into the database and not inadvertently providing mapper feedback that encourages the use of mistake tagging.
2021-09-20 10:23:26 +02:00
Brian Sperlongano 849aca8da7
Refactor z12-14 transportation filter logic (#1207)
This PR is a refactor.  The purpose of this PR is to refactor the logic in the z12-z14 transportation layer to increase readability and reduce code complexity.

In addition, this fixes bugs in the original filter code:
* Create filter parity between `service` and `service_construction` highway classes.
* Removal of unintended `class` values `minor_construction`, `path_construction`, `service_construction`, and `track_construction` from zoom 12 filter by explicitly listing the highway classes that are included.
2021-09-20 08:07:38 +02:00
Falke Design d19aa5bf24
Makefile: Replace static DB properties with the variables (#1222)
* Replace static DB properties with the variables
2021-09-17 12:04:40 -04:00
Brian Sperlongano 5e37a811fb
Update devdocs (#1223) 2021-09-11 15:56:10 -04:00
Falke Design bf68366ed5
Add workflow to readme (#1203)
Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
2021-09-08 13:43:10 -04:00
Falke Design 87a37da243
Fix #1151 check if bc command is available (#1201)
On some systems the `bc` command is not installed, so I added a check if the command can be used.

It is a simply calculation from KB to GB.  If `bc` is missing, then it is displayed in KB.

fix: #1151
2021-09-01 15:13:35 +02:00
Yuri Astrakhan d205f4a433
Fix Ctrl+C when generating tiles (#1205)
Adding -T fixes the issue when users are unable to stop tile genartion with ctrl+c

For some reason it doesn't work without it, even though the process of building
and running both docker images is the same.
2021-09-01 14:18:06 +02:00
Brian Sperlongano f947cbffc3
Add enhanced mountain features (#1202)
This PR adds support for several features in the `natural` key, including `saddle`, `ridge`, `arete`, and `cliff`.  These features all currently render in openstreetmap-carto, so adding these features would advance OpenMapTiles towards its goal of parity with the standard renderer, as indicated in https://github.com/openstreetmap/operations/issues/565#issuecomment-907303115.

This PR also adds the features requested in #274, with the exception of valleys, which I've left out of this PR because there are different complexities to mapping valleys that should be addressed as a separate (future) PR.

### Examples of mountain features in paper maps
These features are regularly found in American-style maps and thus is of interest to the openstreetmap-americana map style.  Below are examples of these mountain-related features found in general purpose maps:

<img src="https://user-images.githubusercontent.com/3254090/131270340-af80c7bf-9416-40a3-9b64-56418abb2aef.png" width=400/>
<img src="https://user-images.githubusercontent.com/3254090/131270375-b9eb2095-7708-443d-b7bc-22bf8adab721.png" width=400/>
<img src="https://user-images.githubusercontent.com/3254090/131270423-64447ad3-d90a-4615-82e1-91175a8f8a6b.png" width=400/>
<img src="https://user-images.githubusercontent.com/3254090/131270506-2248db9f-ded5-443f-82ed-b0e8d4d12a70.png" width=400/>

### Approach
This PR extends the existing `mountain_peak` layer by adding other mountain features.  We may want to consider renaming this layer in version 4.0 to be more inclusive of other mountain features including the potential future addition of valleys.  However, the features added in this PR are associated with mountains and so their inclusion in this layer is the most appropriate location.

A new `osm_mountain_linestring` mapping maps the new linear mountain features, with similar ranking logic as is used for the existing `peak`/`volcano` features.  Additionally, `natural=saddle` is added to the `osm_peak_point` mapping and ranked using the formula for peaks.  Since saddles will have lower elevations than peaks, important saddles will be preempted by important peaks.

The new linestring features are rendered only at zoom 13-14, in order to match the zoom at which they appear in openstreetmap-carto.  However, it may be appropriate in a future PR to extend the rendering of these features as generalized linestrings at lower zooms.

### Test Renderings
Below is a test rendering showing aretes and peaks in Austria, just north of the Swiss border, followed by a screen shot of the [same location](https://www.openstreetmap.org/#map=14/46.8682/10.0863) in openstreetmap-carto:

**OpenMapTiles, zoom 14**
<img src="https://user-images.githubusercontent.com/3254090/131271258-5cd90bdb-cac2-41d8-887f-b4bf6be83673.png" width=400/>
**openstreetmap-carto, zoom r14/v13:**
<img src="https://user-images.githubusercontent.com/3254090/131271332-32d5bcfc-41c6-4625-829c-df063b7af523.png" width=400/>
2021-09-01 12:21:18 +02:00
Falke Design 910db7f60c
Remove area checks in Makefile for `import-borders` & `generate-tiles-pg` (#1200)
While importing multiple .pbf files into postgres I was confronted with some unnecessary problems:

1. I wanted to use the borders of the planet which I had already generated. But `make import-borders` needs a .pbf file which is not necessary if the line.csv file is already existing -> So I added a check if the line.csv is **not** existing it checks for the `area parameter` / .pbf file
2. `make generate-tiles-pg` is only possible with a specified `area parameter` BUT the area is not used / needed for generation -> So I removed the area check
2021-09-01 10:10:29 +02:00
Brian Sperlongano 3818979143
Suppress service roads at certain zooms (#1192)
Fixes #1191

This PR suppresses `highway=service` at zoom 12, where it is not a useful level of detail.  This makes OpenMapTiles consistent with openstreetmap-carto, which does not begin showing `highway=service` until raster zoom 14 / vector zoom 13.

Additionally, this PR suppresses `highway=service` + `service=parking_aisle` / `service=driveway` from zooms 12-13, as this detail is excessive below zoom 14.  As a point of comparison, openstreetmap-carto does not begin showing `service=parking_aisle` / `service=driveway` until raster zoom 16 (vector zoom 15).
2021-09-01 09:18:45 +02:00
Brian Sperlongano d427d58e36
Water layer river mapping bug fixes (#1182)
This PR is a bugfix for the `water` layer.

* `waterway=stream`, `waterway=river`, `waterway=canal`, `waterway=ditch`, and `waterway=drain` are all linear features, not area features.  Thus, these objects are being unnecessarily mapped into the `osm_water_polygon` polygon table, and this PR removes these unneeded mappings.
* The combination `natural=water` + `water=river` is the most popular tagging for river areas.  However, the current mapping causes rivers tagged in this way to be rendered in the vector tiles as a `lake`.  This PR adds a check for the `water=river` tag and tags both variants of river areas as `class=river`.

`natural=water` + `water=river` river mapping:
![image](https://user-images.githubusercontent.com/3254090/129825551-388491de-549e-4843-80cc-01dba358c360.png)

`waterway=riverbank` river mapping:
![image](https://user-images.githubusercontent.com/3254090/129825618-4239eae7-a2bc-4a82-9931-fda2c02c2b40.png)


Lake mapping for a `natural=water` (with no other tagging):
![image](https://user-images.githubusercontent.com/3254090/129825554-9394b3d3-988a-4e92-a9f8-b198c695ec37.png)
2021-09-01 08:24:01 +02:00
Brian Sperlongano 0e17d53f42
Implement park rendering at z4-5 (#1160)
Unblocks ZeLonewolf/openstreetmap-americana#51

Currently, OpenMapTiles renders protected areas at zoom 6 and higher.  However, the western United States has protected areas that are so vast that it makes sense to render these areas as low as zoom 4, as noted in ZeLonewolf/openstreetmap-americana#51

This PR extends the generalization of park features from its current termination at zoom 6 to zoom 4.

Here is an example from the Americana style of rendering protected areas at zoom 6, which is currently the lowest supported zoom:
https://zelonewolf.github.io/openstreetmap-americana/#6/45.313/-111.721

We would like to provide rendering at zoom 4 (no labels) and zoom 5 (with labels) in the Americana style.  Below are samples generated from this PR for Idaho, USA:

Zoom 4:
![image](https://user-images.githubusercontent.com/3254090/126924222-e21865e9-b184-479a-abd5-46238bd106f8.png)

Zoom 5:
![image](https://user-images.githubusercontent.com/3254090/126924230-01853e8c-d3e0-41e8-b10f-06415da529d8.png)
2021-09-01 07:20:52 +02:00
Yuri Astrakhan f15ecbf07e
Update README.md tilegen target (#1199) 2021-08-27 22:34:00 -04:00
Brian Sperlongano 1fb7841a6e
Fix name of PR comment donor (#1196) 2021-08-27 09:56:02 -04:00
Brian Sperlongano 4525ce6a84
Convert CI to use workflow triggers (#1189)
Fixes #948 

This PR does the following:
1. Changes the trigger for the PR comment updater from the cron method to workflow_run, triggered on completion of the test cases.  This should remove the delay between the completion of the performance tests and the updating of the corresponding comment in the PR.
2. Separates the integrity check and performance check into separate workflows and allows them to run in parallel.  This will allow the project to take advantage of multiple CI runners if they're available (which appears to be the case).

In addition, this fixes an issue with post-merge undeleted/updated branches on PRs.  The current "cron" method causes the CI to run the pr-update job over and over forever, unnecessarily.

As described in github/docs#799, and the [github docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_run), a `workflow_run` trigger will only fire when the workflow file is on the main branch.  Thus, this change will not fire the PR updater on this PR.  Thus there's no way to test this working properly without merging onto master and then testing on one of the other PRs.
2021-08-27 14:16:48 +02:00
Yuri Astrakhan 1cea73cb7c
Use st-asmvt pg tilegen in quickstart (#1193)
* Use generate-tiles-pg target in quickstart
* update makefile documentation
2021-08-25 21:35:06 -04:00
Brian Sperlongano b88bd6abb5
Add locksmith shop (#1188)
Fixes #566

This PR adds support for `shop=locksmith`.

Example OSM object: https://www.openstreetmap.org/way/874850561

Rendered tile:
![image](https://user-images.githubusercontent.com/3254090/130335938-e76cf3d2-dfe7-4398-a647-463fc216d674.png)
2021-08-23 18:31:25 +02:00
Brian Sperlongano 7e9a6812d7
Add international airports at z8-9 (#1187)
Closes #1082

This PR moves the aerodrome/aerodrome_type consolidation (via template) into the lower-level `osm_aerodrome_label_point` table, and creates a partial index on class `international` for airports with an `iata` code.  The presence of an `iata` code is more significant than an `icao` code which exists at many smaller, general aviation airport.  Therefore, `international` + `iata` should be a sufficient filter.

Zoom 8 international airports in the NYC area (blue dots):
![image](https://user-images.githubusercontent.com/3254090/130335311-10b7aa35-d2f9-42cc-a054-878048012040.png)

Zoom 10 in the same area:
![image](https://user-images.githubusercontent.com/3254090/130335327-3989cfba-80ca-46dd-a157-45b375f84a8d.png)
2021-08-23 14:14:50 +02:00
Brian Sperlongano aee838e29f
Change zoom level for NE states/provinces (#1184)
Fixes #1055 

This PR moves Natural Earth zoom 7.7 boundary lines into zoom 4.

> Hi, thank you for PR. In github-actions statistics there is a pretty high size increase in zooms 3, 2, 1, which are using data from zoom 4. Maybe keep your change to move `min_zoom <= 7.7` just for zoom 4, but for zoom 3 add a condition `min_zoom <= 7` (that subsequently the condition bubbles into zoom 2 and 1). What do you think?

I agree that this makes sense, and thank you for pointing it out.  It didn't occur to me that the zoom 1-3 tables were unbounded.  I made the change to pull the `min_zoom` column into the zoom 4 generalized table and filter for `min_zoom< 7`.

With this change, here is Algeria, zoom 3:
![image](https://user-images.githubusercontent.com/3254090/130368190-616891f4-4a53-4780-926b-561007291f33.png)

Algeria, zoom 4:
![image](https://user-images.githubusercontent.com/3254090/130368194-d4e722bb-559b-4e2a-bb82-a5d1bd95985c.png)
2021-08-23 11:49:19 +02:00
Brian Sperlongano a93b708327
Implement shipway labels (#1179)
Fixes #403 

This PR adds labels to shipway linestrings in the `transportation_name` level, up through zoom 12.

![image](https://user-images.githubusercontent.com/3254090/129659827-662ee13c-27f3-4e62-a7f4-45dbd535b770.png)
2021-08-23 10:52:15 +02:00
Brian Sperlongano 6ef138635d
Fix negative feature IDs (#1185)
This PR removes the possibility of negative feature IDs for the `aerodrome_label` layer by defining the feature as the absolute value of the OSM id (imposm maps relations with negative numbers).  There is a very unlikely  scenario in which a relation and a way have the same ID (and are also in the same tile), however, unique IDs are not a strict requirement of MVT.

Noted in:
https://github.com/openmaptiles/openmaptiles/pull/1176#issuecomment-902503655

Positive feature ID for Quonset State Airport, which is mapped as a relation:
![image](https://user-images.githubusercontent.com/3254090/130232322-c797d491-ece9-4889-9695-ffb6f3ac011f.png)
2021-08-20 16:40:02 +02:00
Brian Sperlongano 36bd917e05
Implement feature IDs in aerodrome_label and mountain_peak (#1176) 2021-08-19 21:03:40 +02:00
Brian Sperlongano 7ca751ec7a
Add toll tagging (#1177)
Fixes #366

This PR sets `toll=1` in the `transportation` layer when a road is tagged as a toll road in OSM (with the tag `toll=yes`).  If a road is tagged with any other value of `tag=*`, the value is suppressed in the tile, since non-toll roads can be presumed as the default and therefore this PR should have only negligible impact in the tiles.

Support for toll road tagging is of interest in the American mapping community, because toll roads have historically been styled differently on American-style maps, for example:
![image](https://user-images.githubusercontent.com/3254090/129505967-5916eace-596a-4c89-ac5d-0aab3e641ed7.png)


Screen shot of a toll road being generated in the `transportation` layer tiles:
![image](https://user-images.githubusercontent.com/3254090/129505683-eb315643-95ff-455b-a606-f379f776f92d.png)
2021-08-19 07:12:10 +02:00
zstadler e37076c133
Add spring water bodies (#1167)
The [OSM wiki](https://wiki.openstreetmap.org/wiki/Tag:natural%3Dspring) says `natural=spring` may be used on areas.
2021-08-18 17:46:15 +02:00
Brian Sperlongano d186856ac5
Add support for cemetery tagged as grave_yard (#1175)
Fixes #1057

This PR adds `amenity=grave_yard` to the `landuse` layer.  A unification function was implemented which encodes all `class=grave_yard` as `class=cemetery` in the tiles, which adds these features for existing users of `class=cemetery` with no change.  The unification function can serve as a basis for any other tags that we might want to unify in the `landuse` layer.

Tile rendering for an `amenity=grave_yard`.  ([Location](https://www.openstreetmap.org/way/857383420))
![image](https://user-images.githubusercontent.com/3254090/129456504-187d307a-2a20-4b13-af0a-a2850503bb4f.png)

Tile rendering for a `landuse=cemetery`.  ([Location](https://www.openstreetmap.org/way/385779531))
![image](https://user-images.githubusercontent.com/3254090/129456654-494c0eb4-9785-467c-b1a0-44abb7f9d5e9.png)
2021-08-18 09:09:51 +02:00
Brian Sperlongano 45d825e212
Implement private road tagging (#1174)
Fixes #1066 

This PR adds a new field `access` in the transportation layer, which will be set to `no` if the `access` tag is either `no` or `private`.  While `private` is the more popular value by a 17:1 ratio, I went with `no` because it's smaller in the tiles.  In addition, the text `no` opens up the future possibility of other text-based access values such as `destination`, `customers`, or `permit`.

The screenshot below shows an example of access tagging for a road on a military base:

![image](https://user-images.githubusercontent.com/3254090/129431491-9acbaeca-bf18-4384-8177-2c198834865c.png)
2021-08-14 07:04:17 +02:00
Brian Sperlongano fdb9ae58cd
Transportation generalization table optimization and cleanup (#1172)
This PR updates the `transportation` layer creation scripts to simplify the SQL and remove unneeded sub-selects, checks and conditionals, fix indexes, and improve inline documentation. 

Currently, there are two sequences of materialized view creations.  There is one from zoom 11 through 9, and a second one for zoom 8 through 4.  This PR removes that break in the sequence of transportation table materialized view creations, in favor of one in which high-zoom views are created first, and then each lower zoom is created from the zoom above.

Instead, the current generalized zoom 8 transportation table is built directly from `osm_transportation_linestring` rather than being built from the zoom 9 transportation table.  This means that when building the zoom 8 table, it must scan the entire transportation network rather than just selecting from the pre-filtered zoom 9 table.

This PR removes an unneeded sub-select in the build of the zoom 8 table, which appears to be a leftover from an old version of the SQL that did some sort of merge.  Once this PR is implemented all zooms from 11 through 4 will be linked via a progressive series of materialized views.

Lastly, this adds in missing materialized view refreshes for zooms 9-11, which appear to have been entirely missing, and as far as I can tell aren't getting updated in the current version of this code.

In addition, the following optimizations were added as part of this commit:

1. Updates the `osm_highway_linestring_highway_partial_idx` partial index to match the `SELECT..WHERE` clause actually present in `transportation/update_route_member.sql`, which is where it appears to be actually used, and update inline documentation to reflect this.

2. Collapses unnecessary sub-select block in `osm_transportation_merge_linestring_gen_z11`, and removes unnecessary ST_IsValid() call, which already provided in `mapping.yaml`, and update inline documentation to reflect these assumptions.

3. Updates `WHERE` blocks to remove unnecesary checks and further document assumptions.  The `highway=construction` check is unnecessary in all cases, because it is sufficient to check the `construction` key alone.  If `construction=*` is set, then `highway=construction` is implied.

4. Two indexes were added to `layers/transportation/update_route_member.sql` to improve route population performance.

In testing locally, I'm seeing performance improvements around 10% in the generation of the `transportation` layer, based on modifying `openmaptiles.yaml` to generate only the transportation layer and then repeatedly running `time make import-sql`, however, this timing might be impacted by docker, so I would ask for confirmation of acceptable performance.

In addition, this PR shortens the length of the transportation update SQL file by 30 lines, which makes it easier for contributors to work with.
2021-08-13 18:00:33 +02:00
Brian Sperlongano f78d42ec84
Remove unused osm_transportation_merge_linestring table (#1171)
PR #1168 removed several `WHERE` clauses in the `transportation_merge_*` table series.  With those removed, it appears that `osm_transportation_merge_linestring_gen_z8` and `osm_transportation_merge_linestring` are nearly identical, with the former simply adding an `ST_Simplify()` operation.

A grep of the codebase indicates that the _only_ use for `osm_transportation_merge_linestring` is to hold the intermediate result of an `ST_Dump(geometry))` before it is fed into `ST_Simplify()`.  Therefore, it appears that we're holding an entire zoom 8 copy of the transportation layer (all motorway/trunk/primary roads) in a materialized view for absolutely no reason at all.

This PR removes the `osm_transportation_merge_linestring` intermediate table and changes the definition of `osm_transportation_merge_linestring_gen_z8` to perform the `ST_Dump()` and `ST_Simplify()` transformations directly from the `osm_highway_linestring` table in a single operation.
2021-08-11 10:46:17 +02:00
Brian Sperlongano 09078f6d7d
Remove useless WHERE clauses from the transportation layer (#1168)
This PR removes several redundant/unnecessary WHERE clauses from the transportation layer.  Specifically:

The table `osm_transportation_merge_linestring` is a view of `osm_highway_linestring` which exposes only motorway/trunk/primary roads:
9e4be3e3b0/layers/transportation/update_transportation_merge.sql (L122-L123)

However, the create statement for the table `osm_transportation_merge_linestring_gen_z8`, which is a view of `osm_transportation_merge_linestring`, also contains  a `WHERE` clause which selects down to motorway/trunk/primary roads.  This `WHERE` is unnecessary:
9e4be3e3b0/layers/transportation/update_transportation_merge.sql (L144-L145)

This unneeded `WHERE` clause is similarly present in the create statement for `osm_transportation_merge_linestring_gen_z7`, which is a view of `osm_transportation_merge_linestring_gen_z8`:
9e4be3e3b0/layers/transportation/update_transportation_merge.sql (L163-L164)

Likewise, there is a similar redundant `WHERE` clause in the `osm_transportation_merge_linestring_gen_z5` and `osm_transportation_merge_linestring_gen_z6` tables, both of which select down to `motorway` and `trunk`.  This `WHERE` clause is only needed on the z6 table, and is redundant on the z5 table.

I am not sure what the performance penalty is for these redundant `WHERE` clauses, but there does not appear to be any reason to keep them, and they may incur a performance cost.
2021-08-10 17:55:16 +02:00
zstadler 893d1df4c5
Update descritopn of the water layer's class (#1166)
Clarify that OSM water bodies that do not have a `waterway` tag are classified as `lake`.

This refers to the following tags:
9e4be3e3b0/layers/water/mapping.yaml (L86-L95)
2021-08-10 16:16:40 +02:00
Brian Sperlongano 08bb2a06c0
Add network to transport layer (#1158)
Closes #1153 

This PR populates the existing `network_type` field in the route table with highway route network information, using the most important value in cases of concurrencies.  In order to expose this value, two files `network_type.sql` and `update_route_member.sql` were moved from the `transportation_name` layer to the `transportation` layer.

Below is a representative zoom level 6 with motorways only shown for `us-interstate` network types.  This sample was generated from this PR using a [custom branch](https://github.com/ZeLonewolf/openstreetmap-americana/tree/selective-highway-zoom) of openstreetmap-americana.  This provides a simplified rendering of the highway network which excludes many minor motorway roads and sections.
![image](https://user-images.githubusercontent.com/3254090/126420985-c380b54b-a991-4a7c-a4c1-40a5cf5ec6b0.png)

Below is zoom level 6 on the current [openstreetmap-americana](https://zelonewolf.github.io/openstreetmap-americana/#6/42.148/-73.712).  Notice the many additional stubs, motorway islands, and minor routes which are present.  Instead of rendering `highway=trunk` to make this network look nice, we can instead suppress non-interstate roads and withhold motorway+trunk rendering to a closer zoom:
![image](https://user-images.githubusercontent.com/3254090/126421148-71e780ec-991d-4e38-a82a-85015b349e97.png)
2021-08-04 10:10:16 +02:00
Brian Sperlongano 9e4be3e3b0
Remove unused network type params (#1155)
Changes in #1143 removed the need for `name` and `ref` parameters in the network-to-network_type conversion function.  This PR removes this dead code.

Verified by running ./quickstart rhode-island which completed successfully.
2021-07-26 16:37:12 +02:00
Brian Sperlongano 951aa907b2
Fix SQL failures in transportation_name update code (#1154)
This PR fixed bugs introduced in #1147 and #1119 which broke the update triggers in `transportation_name_update`.  I noticed this issue while I was working a different PR and tried to update a table in the `transportation` layer.

**Test**

The following code currently fails because of cascading update failures, but will complete successfully after this PR is merged.
```
UPDATE osm_highway_linestring hl
    SET network = rm.network_type
    FROM osm_route_member rm
    WHERE hl.osm_id=rm.member;
```
2021-07-26 15:22:36 +02:00
Brian Sperlongano b011b27e52
Implement concurrent highway routes (#1152)
Fixes #1128

This PR adds 6 new columns to the `transportation_name` column, named `route_1` through `route_6`.  These columns contain route information for a section of roadway.  The value is stored in the form **network=ref**.  For example, Interstate 95 in the United States would be `US:I=95`.  Thus, each `route_N` value contains enough information to render a highway shield.  Since a section of road can be a part of more than one route, the `route_2`, `route_3`, etc, will contain the 2nd, 3rd, etc., concurrent routes.

The technical approach was to extend the change in #1135, which added ordered concurrency indexes to the `osm_route_member` table by joining up to the the first six entries to the `osm_transportation_name_network` table.  In addition, that PR provided a ranking system for concurrent highways, ordering first by `network_type` (for example, `us-interstate`, `us-state`, etc), then alphabetically by network name, and then by ref in ascending order.  This ordering of concurrent route memberships is now exposed in this PR in the sequential `route_N` values, meaning that rendered concurrent highway shields will be reasonably sorted.

The renderings below were generated using this branch of OpenMapTiles, as well as a separate branch of openstreetmap-americana:
https://github.com/ZeLonewolf/openstreetmap-americana/tree/openmaptilers-new-features-test

The rendering approach is to use the [formatted expressions](https://maplibre.org/maplibre-gl-js-docs/style-spec/expressions/) feature in mapLibre to insert images into a string of text.  Blank shields are added to the sprite sheet for all possible route networks.  Next, a [styleimagemissing](https://maplibre.org/maplibre-gl-js-docs/api/map/) callback is registered.  As each shield ID is requested, the callback retrieves the sprite shield blank associated with the route's network, draw the `ref` text on the shield, and insert the complete shield back into the map.

Of note, this approach currently results in shields which are rotated about the road rather than being viewport aligned.  This issue is currently documented as maplibre/maplibre-gl-js#188.  A separate repository (https://github.com/ZeLonewolf/maplibre-shield-rotation-sample) has been created as a test case to fix this rotation issue.

Adding route concurrency information to OpenMapTiles would be a major step forward in achieving comprehensive highway shield renderings in a vector map!

**Renderings**:

![routes_1](https://user-images.githubusercontent.com/3254090/126054350-fa7475a7-1b60-4989-bbc2-107678e6c73b.png)
![routes_2](https://user-images.githubusercontent.com/3254090/126054351-fe73bc70-d75f-4ab5-8365-0ee3c3d3eab0.png)
![routes_3](https://user-images.githubusercontent.com/3254090/126054353-a1e74c8f-df21-423c-a300-b7f1a7c9231c.png)
![routes_4](https://user-images.githubusercontent.com/3254090/126054355-6b5dcc83-c611-42b3-bb67-d4f26d789744.png)
2021-07-26 14:28:36 +02:00
Brian Sperlongano 3c15679555
Update brunnel aggregation to avoid splitting highways (#1141)
Fixes #1131

This change does the following:
1. Excludes roads from `transportation_name` that don't have a `name` or a `ref`
2. Updates the road name merging logic to exclude changes in `brunnel` status.  This will ensure that minor bridges don't disrupt the continuity of named roads as the map zooms out.
3. The `brunnel` tag will now only be set when a bridge or tunnel is distinctly named.  Distinctly named is defined as "has a different name from the road on either side".

This example shows an unnamed interstate highway rendered as a continuous feature at low zoom.  This road has many small bridges along its length:

![image](https://user-images.githubusercontent.com/3254090/124370289-b30faa80-dc43-11eb-80d6-034c18ce99ad.png)


This example shows a named bridge rendered with `brunnel` tag set:

![image](https://user-images.githubusercontent.com/3254090/124370298-d0dd0f80-dc43-11eb-8a78-183420a6bd62.png)
2021-07-13 14:44:59 +02:00
Brian Sperlongano 197ea39ae3
Remove unused osm_id column (#1147)
Fixes #1146

This PR removes the always-null osm_id column from the `transportation_name_linestring` table and the series of generalized tables that derive from it.

Demonstration of `transportation_name` objects behaving normally after the column has been removed:

![image](https://user-images.githubusercontent.com/3254090/124684944-4512ef80-de9e-11eb-998c-b66bc23be09e.png)
2021-07-13 13:39:28 +02:00
Frédéric Rodrigo a851f2c9e9
Review index on osm_waterway_linestring on osm_important_waterway_linestring_gen_z* (#1130)
Review index waterway.

* Remove not used index
* Fit index `osm_waterway_linestring_waterway_partial_idx` to query
2021-07-09 09:35:46 +02:00
Brian Sperlongano 4eb240466e
Simplify Trans-Canada Highway logic (#1143)
Fixes #1142

Screenshot from Alberta showing TCH still shown in `transportation_name` layer:
![image](https://user-images.githubusercontent.com/3254090/124532399-77f5ae80-ddde-11eb-8929-36970ebb8386.png)

Screenshot from Ontario showing TCH still shown in `transportation_name` layer:
![image](https://user-images.githubusercontent.com/3254090/124532512-b68b6900-ddde-11eb-9b6a-636c872375c1.png)
2021-07-06 08:43:26 +02:00