Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database-reload #2128

Merged
merged 28 commits into from
Jul 1, 2016
Merged

Database-reload #2128

merged 28 commits into from
Jul 1, 2016

Conversation

matthijsmelissen
Copy link
Collaborator

@matthijsmelissen matthijsmelissen commented May 16, 2016

This is a pull-request against the lua branch

This is a new version of #2105. No changes except for dropping some commented lines.

This PR proposes a database-reload. It changes the documentation on the use of
osm2pgsql, and adds a .lua file for preprocessing.

This database import aims to be backwards compatible with older versions of
the style.

This resolves (at least part of) #1504.

Hstore

Adding the hstore option to osm2pgsql allows the database to use all keys.

This PR proposes using hstore for new keys, and using traditional columns for
old keys. This allows us to stay compatible with old versions of the style.

According to @pnorman's benchmarks,
using hstore without dropping columns would lead to a 9% size increase and a
0.38% speed decrease. Given the benefits of having all columns available, I
would consider this acceptable.

Make polygon/linestring decision based on value

This is based on the following unmerged PR to osm2pgsql:
osm2pgsql-dev/osm2pgsql#346

It makes the polygon/linestring decision based on the tag value, in addition to
the tag key. In particular, highway=services and junction=yes are now treated as
polygon, while leisure=track, man_made=embankment, man_made=breakwater,
man_made=groyne, natural=cliff, natural=tree_row, historic=citywalls,
waterway=derelict_canal, waterway=ditch, waterway=drain, waterway=river,
waterway=stream, waterway=wadi, waterway=weir, power=line, and power=minor_line
are now treated as linestring.

This resolves #1362, resolves #137, resolves #268, and resolves #892.

Rendering order

The new .lua file creates a osmcarto_z_order value in the database, which stores
the rendering order we use. This will allow us to simplify the road queries.

Recommend -G flag for multipolygons

This resolves #59.

Import ele on buildings

This resolves #101.

Delete more meta-tags from imports

The .lua file drops some more meta-information from imports that is of no
need for rendering.

This is based on the following unmerged PR to osm2pgsql:

@matthijsmelissen matthijsmelissen changed the title **This is a pull-request against the lua branch** Database-reload May 16, 2016
@matthijsmelissen
Copy link
Collaborator Author

@gravitystorm Would you be able to do a test-run of the import on one of your servers? Doesn't need to be full-planet, but it would be good to have done at least some testing.

@pnorman
Copy link
Collaborator

pnorman commented May 16, 2016

Layer should be an integer.

👎 to having two z_orders, 👎 to trying to maintain compatibility

end

-- Filter out objects with 0 tags
if numberofkeys == 0 then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this branch first as it's a shorter exit and very common

Copy link
Collaborator Author

@matthijsmelissen matthijsmelissen May 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can do this, as line 257-267 might change the numberofkeys variable? Objects with for example only a note of fixme tag are quite common. Or would you be ok with leaving some objects with 0 tags in the database?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the numberofkeys == 0 case is so common it needs to be handled first, even if another check is done at the end

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@pnorman
Copy link
Collaborator

pnorman commented May 16, 2016

The area determination logic is duplicated, put it in its own function

@pnorman
Copy link
Collaborator

pnorman commented May 16, 2016

Can you edit the git commit message to have a more useful first line? This is a major change, so we'll be seeing it a lot in git blame and other commands.

git commit --amend, edit the message, and git push -f should do it

**This is a pull-request against the lua branch**

This PR proposes a database-reload. It changes the documentation on the use of
osm2pgsql, and adds a .lua file for preprocessing.

This database import aims to be backwards compatible with older versions of
the style.

This resolves (at least part of) gravitystorm#1504.

 #Hstore
Adding the hstore option to osm2pgsql allows the database to use all keys.

This PR proposes using hstore for new keys, and using traditional columns for
old keys. This allows us to stay compatible with old versions of the style.

According to [@pnorman's benchmarks](http://www.paulnorman.ca/blog/2014/03/osm2pgsql-and-hstore/),
using hstore without dropping columns would lead to a 9% size increase and a
0.38% speed decrease. Given the benefits of having all columns available, I
would consider this acceptable.

 # Make polygon/linestring decision based on value
This is based on the following unmerged PR to osm2pgsql:
osm2pgsql-dev/osm2pgsql#346

It makes the polygon/linestring decision based on the tag value, in addition to
the tag key. In particular, highway=services and junction=yes are now treated as
polygon, while leisure=track, man_made=embankment, man_made=breakwater,
man_made=groyne, natural=cliff, natural=tree_row, historic=citywalls,
waterway=derelict_canal, waterway=ditch, waterway=drain, waterway=river,
waterway=stream, waterway=wadi, waterway=weir, power=line, and power=minor_line
are now treated as linestring.

This resolves gravitystorm#1362, resolves gravitystorm#137, resolves gravitystorm#268, and resolves gravitystorm#892.

 # Rendering order
The new .lua file creates a osmcarto_z_order value in the database, which stores
the rendering order we use. This will allow us to simplify the road queries.

 # Recommend -G flag for multipolygons
This resolves gravitystorm#59.

 # Import ele on buildings
This resolves gravitystorm#101.

 # Delete more meta-tags from imports
The .lua file drops some more meta-information from imports that is of no
need for rendering.

This is based on the following unmerged PR to osm2pgsql:
* osm2pgsql-dev/osm2pgsql#532
@matthijsmelissen
Copy link
Collaborator Author

Can you edit the git commit message to have a more useful first line?

Done.

I will come back to your other points later.

{ 'bridge', 1, 10, 0, 0 },
{ 'tunnel', 'yes', -10, 0, 0},
{ 'tunnel', 'true', -10, 0, 0},
{ 'tunnel', 1, -10, 0, 0},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lines have an extra leading space

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@matthijsmelissen
Copy link
Collaborator Author

The area determination logic is duplicated, put it in its own function

Fixed

@matthijsmelissen
Copy link
Collaborator Author

matthijsmelissen commented May 17, 2016

the z_order you have in this table is not compatible with osm2pgsql z_order.

We specify in the documentation that osm2pgsql should be run with openstreetmap-carto.style, so if the OSMF tile server maintainers decide to use a different .style, in a way that's their problem. In practice of course they are our main 'customer', so it's not something we can ignore. I wonder what other tile servers that run openstreetmap-carto do - use our style or use the osm2pgsql default one? For context, both styles were identical until osm2pgsql diverged a couple of months ago.

Basically we have three options:

1) Drop the column z_order altogether (we still keep osmcarto_z_order)
Positive: lower complexity (less chance for confusion due to the presence of two similar columns).
Negative: no backwards compatibility with older versions of the stylesheet; harder to share a database with other styles that use the z_order column such as openstreetmap-de and openstreetmap-fr.

2) Import z_order as currently defined by osm2pgsql and used on the OSMF servers (in addition to osmcarto_z_order)
Positive: Backwards compatibility (largely) with older versions of the stylesheet. Easy to share a database with other styles that use the default z_order column from osm2pgsql, and even (accepting some small changes in behaviour) with styles that use z_order column from openstreetmap-carto.style.
Negative: We might lose backwards compatibility anyway if we eventually decide to drop columns for which we will use hstore.

3) Import z_order as currently defined by openstreetmap-carto.style (in addition to osmcarto_z_order)
Positive: Backwards compatibility with older versions of the stylesheet. Easy to share a database with other styles that use the default z_order column from openstreetmap-carto.style, and (accepting some small changes in behaviour) with styles that use z_order column from osm2pgsql.
Negative: Same as for 2.

Feel free to extend.

@gravitystorm Would you be able to make the final decision? The current proposal implements 3), but on changing the proposal to 1) or 2) is trivial.

@pnorman
Copy link
Collaborator

pnorman commented May 18, 2016

the z_order you have in this table is not compatible with osm2pgsql z_order.

We specify in the documentation that osm2pgsql should be run with openstreetmap-carto.style, so if the OSMF tile server maintainers decide to use a different .style, in a way that's their problem. In practice of course they are our main 'customer', so it's not something we can ignore. I wonder what other tile servers that run openstreetmap-carto do - use our style or use the osm2pgsql default one? For context, both styles were identical until osm2pgsql diverged a couple of months ago.

The styles are still identical with respect to z_order - and z_order isn't defined in the .style file anyways.

@pnorman
Copy link
Collaborator

pnorman commented Jun 2, 2016

With the C transforms and osm2pgsql's style.lua example I have 28662 rows in planet_osm_roads with the extract I'm testing with, but 1667987 with this code, very close to the number of lines. Could 1 and 0 be flipped in what you've got? This would also account for some of the speed difference we found, since it has to do a lot more DB work

{'railway', 'miniature', 0, 420, 1},
{'railway', 'turntable', 0, 420, 1},
{'railway', 'tram', 0, 410, 1},
{'railway', 'tram-service', 0, 405, 1},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this line work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - not sure now where it comes from actually.

@pnorman
Copy link
Collaborator

pnorman commented Jun 19, 2016

ping @math1985, I have two open PRs against this branch.

@matthijsmelissen
Copy link
Collaborator Author

I'm currently reviewing them.

@matthijsmelissen
Copy link
Collaborator Author

@pnorman's PR's have been merged.

From my side this is (again) ready for review/merge.

@pnorman
Copy link
Collaborator

pnorman commented Jun 25, 2016

From my side this is (again) ready for review/merge.

Have you fixed the problem with the roads table?

Also, this is failing CI

@matthijsmelissen
Copy link
Collaborator Author

Have you fixed the problem with the roads table?

I must have missed that, what problem are you referring to?

Also, this is failing CI

It failed because of 'The command "./scripts/travis_check_project_files" exited with 1.', that's a new check as far as I know, so I think this should fix itself when merging.

@pnorman
Copy link
Collaborator

pnorman commented Jun 26, 2016

Have you fixed the problem with the roads table?
I must have missed that, what problem are you referring to?

#2128 (comment)

It failed because of 'The command "./scripts/travis_check_project_files" exited with 1.', that's a new check as far as I know, so I think this should fix itself when merging.

It looks like you didn't run yaml2mml.py

@matthijsmelissen
Copy link
Collaborator Author

matthijsmelissen commented Jun 26, 2016

With the C transforms and osm2pgsql's style.lua example I have 28662 rows in planet_osm_roads with the extract I'm testing with, but 1667987 with this code, very close to the number of lines

I cannot reproduce this.

For Luxembourg, I get these numbers (old/new):
planet_osm_nodes 1572472/1572472
planet_osm_ways 201180/201180
planet_osm_rels 3804/3804

planet_osm_point 45338/48484
planet_osm_line 84918/85127
planet_osm_polygon 115719/113992
planet_osm_roads 13481/13056

@pnorman Can you reproduce this problem with the Luxembourg abstract?

@matthijsmelissen
Copy link
Collaborator Author

It looks like you didn't run yaml2mml.py

Fixed.

@pnorman
Copy link
Collaborator

pnorman commented Jun 27, 2016

@pnorman Can you reproduce this problem with the Luxembourg abstract?

I'm having trouble reproducing, I'll try further debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants