Wykres commitów

42 Commity (9de3ff39216880fa56630bcb7a98b0faa3deaee1)

Autor SHA1 Wiadomość Data
Brian Sperlongano 9de3ff3921
Restore missing route zooms (#1579)
This PR restores missing transportation_name features that are missing from zoom 11 and improves the mechanism by which transportation_name features are merged through lower zooms. This prevents route features from being dropped due to bridge interleaving (when a bridge interrupts an otherwise continuous route).

This fix moves the length check to a later stage of processing and merges bridges/tunnels if they're too small.  This is similar to the work done in the transportation layer to merge bridges that are too small to render lines.  In this layer, bridges are merged when they're too small to justify a separate label.
2023-09-14 15:55:01 +02:00
benedikt-brandtner-bikemap 66731f3544
LineString Merging Updates (#1538)
This PR addresses two main issues introduced by the new ID-Based Merged-LineString Updates

1. Partial Indexes can only be accessed when the query matches more or less exactly and the query-planner will fail to use indexes when targeted via the join-condition and not the where-condition
    - `osm_transportation_merge_linestring_gen_z9`
    - `osm_transportation_name_network`
    - `osm_shipway_linestring`
    - `osm_aerialway_linestring`
    - `osm_waterway_linestring`
2. When intersecting updated Source-LineStrings with the existing Merged-LineStrings we join the Source-IDs of each existing Merged-LineString. This bloats the table unnecessarily and slows down bigger updates considerably.
    - This is addressed by aggregating the Source-IDs of each existing Merged-LineString into an array and concatinating these arrays when grouping them. Afterwards we add the IDs of updated SourceLineStrings and deduplicate the result before adding it to the Source-IDs-Table.
2023-06-19 10:12:57 +02:00
benedikt-brandtner-bikemap d0d87e52d5
fixed analyzing of changes table in refresh_[shipway/aerialway]_linestring (#1536)
Fixes a typo analyzing the `name_changes` table during execution of `transportation_name.refresh_shipway_linestring` and `transportation_name.refresh_aerialway_linestring`
2023-06-13 18:13:17 +02:00
benedikt-brandtner-bikemap b2a57b3755
Update Performance transportation_name Layer (#1512)
Improved update performance of transportation_name layer
- Refactored LineString-merging and diff updates in update_transportation_name.sql
- Refactored transportation_route_member_coalesced materialized view to table
- Added analyze statements before update queries during transportation_name.refresh_network and update_osm_route_member
2023-03-22 19:39:18 +01:00
Brian Sperlongano b7edcf6153
Convert osm_route_member unique index to trigger (#1501)
This PR changes the three-column unique index to an on-insert trigger. This should fix the issues we're having with CI failures and still achieve the behavior of coalescing duplicate routes. 

I moved the concurrency_index calculation into an intermediate materialized view to separate the de-duplication capability from both DENSE_RANK() and from imposm updates.
2023-03-06 17:10:30 +01:00
Adam Laža 7f08414f20
Use equal operator in combination with coalesce() function instead of IS NOT DISTINCT FROM operator. (#1344)
Updates on `transporation_name` layer take much more time than before.

In 3.13 there had been introduced highway concurrency into `transportation` and `transportation_name` so I expected the update process will take more time but not that much. Because of this it's impossible to use updates on larger areas because the process takes too long.

The issue is caused by `IS NOT DISTINCT FROM` operator over `tags` (hstore) columns. I replaced it with `=` operator in combination with `coalesce()` function which returns the same results but in shorter time.
2022-02-04 15:25:47 +01:00
Tomas Pohanka 73dcd23497
Run get_basic_name after osml10n_street_abbrev_* (#1326)
PR move `get_basic_names(tags, geometry)` function from `transportation_name_tags` function and adding it after `transportation_name_tags` resolve street abbrevation.

PR runs through `test-sql` test without error. Adding to `osm_transportation_name_network` (table and for update) was done in consequence of `test-sql` errors ([update test 500](a747d98550/tests/test-post-update.sql (L53))). Originally `get_basic_names` was just in `osm_transportation_name_linestring` table.

FIX #1324

![seattle_fix](https://user-images.githubusercontent.com/5182210/145085141-7857e97e-9b83-4467-bb98-84cc4a2e0623.png)
2021-12-08 08:20:15 +01:00
Nicholas Skehin 207396269e
Implement aerialway labels (#1309)
This PR adds labels to `aerialway` linestrings after zoom level 12. I roughly followed PR https://github.com/openmaptiles/openmaptiles/pull/1179

These are useful in ski resorts and should not inflate the size of the tiles by much as aerialways are rare:
![Screenshot from 2021-11-18 12-18-58](https://user-images.githubusercontent.com/632493/142680225-1875904b-d146-4932-8a22-8c36919b875d.png)


Co-authored-by: Tomas Pohanka <TomPohys@gmail.com>
2021-11-26 10:16:41 +01:00
Brian Sperlongano ec74480414
BUGFIX: Fix name-based way fragmentation in transportation_name (#1295)
I discovered this bug while investigating issues with the updates process related to #1190 #1292, and #814.

The `transportation_name` layer produces slightly different `tags` hstore values in the `osm_transportation_name_linestring` table during the initial import versus when running an update.  As currently written, the import code produces null-value keys in the `tags` column, while the update code suppresses them.  This PR removes that difference and makes the import code use same method that is currently used in the update code.

With a test case I've written, the import code produces a tags hstore that looks like this:
`"name"=>"OpenMapTiles Secondary 2", "name:de"=>NULL, "name:en"=>NULL, "name_int"=>"OpenMapTiles Secondary 2", "name:latin"=>"OpenMapTiles Secondary 2"`

...while the update code produces a tags hstore that looks like this:

`"name"=>"OpenMapTiles Secondary 2", "name_int"=>"OpenMapTiles Secondary 2", "name:latin"=>"OpenMapTiles Secondary 2"`

Note the missing NULL values.

This bug causes a small amount of space wastage after an update is run, because the update matching code detects the `tags` value as different, resulting in a duplicate copy of the tags value if that row is updated.  This causes duplicate objects and breaks GROUP BY clauses that expect to group same-tagged features together.  I've tested this by inspection of a generated mbtiles, database spot checks, and the unit test code included in this PR.
2021-11-25 10:45:11 +01:00
Brian Sperlongano 75d8c80228
Selective rendering of tracks and paths at z12-13 (#1190)
Closes #271

This PR adds track and path rendering at lower zooms than currently provided, and also achieves near-parity with openstreetmap-carto on track and path rendering. A previously-abandoned attempt, with significant discussion, was #1169.
2021-11-18 17:35:34 +01:00
zstadler 5b2e43497e
`transportation_name` update to consider `tags` (#1289)
Following 8bb77b67a1 (r59190611)
2021-11-04 13:51:28 +01: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
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
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 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 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
Brian Sperlongano c8377d38ac
include route relation ref in existence check (#1139)
Fixes #1138
Unblocks #1131
Unblocks #1128 

Below is an example of a way that is part of a route relation (in this case, RI-3), but does not have a ref set on the way itself:
![image](https://user-images.githubusercontent.com/3254090/124366616-1509e900-dc1f-11eb-87ab-aadd4f21287d.png)

This screenshot demonstrates that the `transportation_name` object now contains the ref from the route relation:
![image](https://user-images.githubusercontent.com/3254090/124366563-b5abd900-dc1e-11eb-9fd9-96315ddf7682.png)
2021-07-05 11:21:35 +02:00
Brian Sperlongano 1b0b1fd121
Compute separate concurrency_index on osm_route_member (#1135)
Closes #1134 

Adds a `concurrency_index` column to `osm_route_member` as described in #1134.  For example, listing concurrencies on a [segment of the Washington Bridge](https://www.openstreetmap.org/way/43080535) in Providence, Rhode Island, USA:

```
openmaptiles=# select osm_id, network, ref, network_type, name, concurrency_index from osm_route_member where member=43080535 order by concurrency_index asc;
  osm_id  | network | ref | network_type  |     name      | concurrency_index
----------+---------+-----+---------------+---------------+-------------------
 -1694950 | US:I    | 195 | us-interstate | I 195 (RI/MA) |                 1
 -2308410 | US:US   | 6   | us-highway    | US 6 (RI)     |                 2
 -1347856 | US:US   | 1A  | us-highway    | US 1A (RI)    |                 3
 -2309143 | US:US   | 44  | us-highway    | US 44 (RI)    |                 4
(4 rows)
```
2021-07-02 15:00:25 +02:00
Brian Sperlongano 3f70b878e2
nulling subclass when not present (#1132)
PR #1119 (adding support for `highway=motorway_junction`) missed a few cases where NULLIF functions were needed in order to suppress empty-string `subclass` tags from appearing in vector tiles, resulting in unnecessary  `subclass` entries on `transportation_name` objects where it was not needed, for example:
![image](https://user-images.githubusercontent.com/3254090/123889414-7a11c600-d923-11eb-938c-f278b9bf1ffa.png)

This PR adds the missing NULLIF function so that those empty tags are suppressed:
![image](https://user-images.githubusercontent.com/3254090/123889540-b6452680-d923-11eb-8f0b-5c8c03640059.png)
2021-06-30 07:06:22 +02:00
Brian Sperlongano 79c2ec929d
Add new layer to serve highway=motorway_junction nodes (#1119)
This PR adds a layer for `highway=motorway_junction` features.

This implementation of highway exits in the transportation_name layer add to the existing layer table structure, and renames the internal column name from "construction" (which was already overloaded with non-construction usages) to "subclass", which will be less confusing to future developers.  The string 'junction' is used as the universal sub-class for highway exits.

A new documentation PR has been opened at openmaptiles/www.openmaptiles.org#69 to reflect these changes in the documentation.
2021-06-28 14:35:27 +02:00
Eva Jelinkova 341c4df171
Brunnel changes in transportation and transportation_name layers (#1027)
https://github.com/openmaptiles/openmaptiles/issues/999

- Point 1 solved only partially - there is `brunnel` value added into zooms 9, 10, 11. For zooms 8 and smaller it would need change in osm_transportation_merge_ tables - I am going to try it but maybe its SQL costs will be to high.

- Point 2 solved.
2020-10-14 15:26:43 +03:00
Frédéric Rodrigo 36b7533d3b
Add timers to trigger function (#1006)
Add timer to all trigger refresh functions to help point where the time is spend on update.
2020-10-08 16:57:16 +03:00
Frédéric Rodrigo 8bb77b67a1
Diff update osm transportation name network linestring (#996)
Replacing materialized view by a tables with update from trigger on change only.

Differential update of `osm_transportation_name_linestring`, `osm_transportation_name_linestring` and `osm_transportation_name_linestring_genX`).

At the end of the transaction the dependent rows are updated.

The goal is to update more quickly the content of derivated tables by just updating the changing content. It replaces the update of materialized view because their need a full recompute (with lock issue).

It is the last part of the replacement of materialized view for the transportation layer.

It addresses #814 and a part of #809.
2020-09-28 15:56:10 +03:00
Frédéric Rodrigo 47cdfc2c8b
Move where condition from osm_transportation_name_linestring to materialized view osm_transportation_name_network (fix) (#993)
On PR #991 the differential update was not updated like the main code.

Make similar change to the update code.
2020-09-23 11:10:59 +03:00
zstadler 45f5b53c9c
Stitch `transportation_name` by all language tags (#989)
When OSM roads in the `transportation_name` layer are stitched together, their grouping does not consider all `name:*` tags.
As a result, roads with different `name:*` tags may be stitched together.

The `waterway` layer performs the grouping properly, for the same purpose:
1685eaccbd/layers/waterway/update_important_waterway.sql (L34)

Co-authored-by: Frédéric Rodrigo <fred.rodrigo@gmail.com>
2020-09-21 12:38:13 +03:00
Frédéric Rodrigo 5c640daf4f
Move where condition from osm_transportation_name_linestring to materialized view osm_transportation_name_network (#991)
Reduce the size of the materialized view osm_transportation_name_network by moving the weare clause.
osm_transportation_name_network is only used for osm_transportation_name_linestring.

Co-authored-by: zstadler <zeev.stadler@gmail.com>
2020-09-21 10:02:20 +03:00
Frédéric Rodrigo 550b1f8f90
Replace materialized view osm_transportation_name_network by a table with diff update (#987)
Replacing materialized view by a tables with update from trigger on change only.

The osm_id of object changing on table osm_route_member and osm_highway_linestring are logged.
At the end of the transaction the dependent row of osm_transportation_name_network are updated.

The goal is to update more quickly the content of derivated tables by just updating the changing content. It replaces the update of materialized view because their need a full recompute (with lock issue).

Note, it is only a part of the materialized view of the transportation layer, I am also working on the other parts, other parts are in #892 (omaterialized view on sm_transportation_name_linestring and osm_transportation_name_linestring_genX).

It addresses #814 and a part of #809.
2020-09-18 16:49:55 +03:00
Frédéric Rodrigo 9bb17792a6
Remove alignment of AS in SQL and few others (#932)
* Remove alignment of AS in SQL

* Remove alignment of CREATE TABLE in SQL
2020-07-22 13:48:25 +02:00
Yuri Astrakhan 6457419e0d
NOOP: Format all layer's SQL code (#917)
I would like to reformat all of our SQL to have a concise coding style.
This makes it far easier to understand the code for a casual contributor,
and lets us spot errors more easily.

Most importantly, it makes it much easier to grep (search) the code because it is more likely to be in the same syntax

Some key changes:
* SQL keywords are always UPPERCASE, e.g. `SELECT WHEN AS END ...`
* types, variables, aliases, and field names (identifiers) are always lower case
* `LANGUAGE 'plpgsql'` is now `LANGUAGE plpgsql` (no quotes)
* a few minor spacing/semicolon cleanups

P.S. Per @TomPohys request, `TABLE` is spelled using upper case despite being a type for consistency with PG Docs. Same for `LANGUAGE SQL` vs `LANGUAGE plpgsql`.
2020-06-08 12:19:55 -04:00
Yuri Astrakhan c9e7ad90c6
Remove unneeded "else null" in conditions (#732)
Minor code cleanup:
SQL already returns NULL in the "WHEN" condition
if it is not matched by any of the cases.

Co-authored-by: Eva Jelinkova <evka.jelinkova@gmail.com>
2020-01-22 17:24:28 -05:00
Yuri Astrakhan 1d91b9ef6e
Noop: tag sql MAT VIEWS with a special comment (#733)
Tag all SQL materialized views with a machine-readable comment
to indicate that this materialized view can be created without
data:

   /* DELAY_MATERIALIZED_VIEW_CREATION */

In the next version of tools this comment can be optionally
replaced with the "WITH NO DATA" parameter, thus allowing
a much faster execution of the SQL script. All materialized
viewes will be populated with data in parallel afterwards
using the `refresh-views` tools script.
2020-01-20 12:02:49 -05:00
golubev 73307a610b layers/transportation_name/: add roads under construction, fix SQL error (#321) 2019-10-04 14:50:05 +03:00
jirik 92a056ab78 Abbreviate also name:latin of streets 2018-11-30 15:32:26 +01:00
jirik bae5f21bb4 Respect current grouping of osm_transportation_name_network 2018-11-07 11:08:06 +01:00
Joakim Kronqvist 7ec9e49a44 Only group transportation name based on language tags 2018-11-07 11:08:06 +01:00
jirik 63f6915fab Add missing transportation_name features
Fix #372
2017-11-25 11:10:01 +01:00
jirik e95f2d476b Add layer, level, and indoor tags for footways and steps 2017-11-09 10:13:53 +01:00
jirik 893918761c Fix SQL update logic (patch from 3.6.2) 2017-08-01 09:12:15 +02:00