{"action":"created","issue":{"url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/issues/287","repository_url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles","labels_url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/issues/287/labels{/name}","comments_url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/issues/287/comments","events_url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/issues/287/events","html_url":"https://github.com/osm2vectortiles/osm2vectortiles/pull/287","id":150861294,"number":287,"title":"use_single_id_space in imposm mapping","user":{"login":"lukasmartinelli","id":1288339,"avatar_url":"https://avatars.githubusercontent.com/u/1288339?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasmartinelli","html_url":"https://github.com/lukasmartinelli","followers_url":"https://api.github.com/users/lukasmartinelli/followers","following_url":"https://api.github.com/users/lukasmartinelli/following{/other_user}","gists_url":"https://api.github.com/users/lukasmartinelli/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasmartinelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasmartinelli/subscriptions","organizations_url":"https://api.github.com/users/lukasmartinelli/orgs","repos_url":"https://api.github.com/users/lukasmartinelli/repos","events_url":"https://api.github.com/users/lukasmartinelli/events{/privacy}","received_events_url":"https://api.github.com/users/lukasmartinelli/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"lukasmartinelli","id":1288339,"avatar_url":"https://avatars.githubusercontent.com/u/1288339?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasmartinelli","html_url":"https://github.com/lukasmartinelli","followers_url":"https://api.github.com/users/lukasmartinelli/followers","following_url":"https://api.github.com/users/lukasmartinelli/following{/other_user}","gists_url":"https://api.github.com/users/lukasmartinelli/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasmartinelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasmartinelli/subscriptions","organizations_url":"https://api.github.com/users/lukasmartinelli/orgs","repos_url":"https://api.github.com/users/lukasmartinelli/repos","events_url":"https://api.github.com/users/lukasmartinelli/events{/privacy}","received_events_url":"https://api.github.com/users/lukasmartinelli/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/milestones/17","html_url":"https://github.com/osm2vectortiles/osm2vectortiles/milestones/v1.5","labels_url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/milestones/17/labels","id":1619632,"number":17,"title":"v1.5","description":"","creator":{"login":"manuelroth","id":1810384,"avatar_url":"https://avatars.githubusercontent.com/u/1810384?v=3","gravatar_id":"","url":"https://api.github.com/users/manuelroth","html_url":"https://github.com/manuelroth","followers_url":"https://api.github.com/users/manuelroth/followers","following_url":"https://api.github.com/users/manuelroth/following{/other_user}","gists_url":"https://api.github.com/users/manuelroth/gists{/gist_id}","starred_url":"https://api.github.com/users/manuelroth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manuelroth/subscriptions","organizations_url":"https://api.github.com/users/manuelroth/orgs","repos_url":"https://api.github.com/users/manuelroth/repos","events_url":"https://api.github.com/users/manuelroth/events{/privacy}","received_events_url":"https://api.github.com/users/manuelroth/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":49,"state":"open","created_at":"2016-03-03T08:46:29Z","updated_at":"2016-04-25T15:24:13Z","due_on":"2016-05-01T22:00:00Z","closed_at":null},"comments":3,"created_at":"2016-04-25T13:35:00Z","updated_at":"2016-04-25T16:38:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/pulls/287","html_url":"https://github.com/osm2vectortiles/osm2vectortiles/pull/287","diff_url":"https://github.com/osm2vectortiles/osm2vectortiles/pull/287.diff","patch_url":"https://github.com/osm2vectortiles/osm2vectortiles/pull/287.patch"},"body":"Resolves #281 \r\n\r\nOnly possible thanks to the research of @ImreSamu in #281.\r\n\r\n*This is how I understand it, please correct me @ImreSamu *\r\n`use_single_id_space=true` will divides the id range up into three ranges.\r\n\r\n`id < - 1e17`: Ways\r\n`0 < id > - 1e17 `: Relations\r\n`id > 0`: Points\r\n\r\nWhat I can do now is to map the relations back into the negative range (by adding `1e17`).\r\nAnd ways back to the positive range (by making them absolute). And then the functions we created previously (`osm_id_linestring`, `osm_id_polygon`, `osm_id_point`, `osm_id_geometry` handle the rest because they make the decision based on geometry type and whether it originated from a relation.\r\n\r\n![drawing](https://cloud.githubusercontent.com/assets/1288339/14785378/c1159c5e-0afa-11e6-8c80-a8f2cad8ceb9.png)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/issues/comments/214432750","html_url":"https://github.com/osm2vectortiles/osm2vectortiles/pull/287#issuecomment-214432750","issue_url":"https://api.github.com/repos/osm2vectortiles/osm2vectortiles/issues/287","id":214432750,"user":{"login":"ImreSamu","id":2217320,"avatar_url":"https://avatars.githubusercontent.com/u/2217320?v=3","gravatar_id":"","url":"https://api.github.com/users/ImreSamu","html_url":"https://github.com/ImreSamu","followers_url":"https://api.github.com/users/ImreSamu/followers","following_url":"https://api.github.com/users/ImreSamu/following{/other_user}","gists_url":"https://api.github.com/users/ImreSamu/gists{/gist_id}","starred_url":"https://api.github.com/users/ImreSamu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ImreSamu/subscriptions","organizations_url":"https://api.github.com/users/ImreSamu/orgs","repos_url":"https://api.github.com/users/ImreSamu/repos","events_url":"https://api.github.com/users/ImreSamu/events{/privacy}","received_events_url":"https://api.github.com/users/ImreSamu/received_events","type":"User","site_admin":false},"created_at":"2016-04-25T16:38:25Z","updated_at":"2016-04-25T16:38:25Z","body":"as usual ..  it is a matter of taste .. \r\n\r\nbut \r\n* with the #284  patch there will be a problem, because we will lost the geometry information (` osm_id_geometry()` )   [ this is polygon or not ? ]   \r\n  so there will be a problem with the proposed  2 step conversion , without redesign.\r\n\r\n\r\n  \r\nmy alternative solutions:\r\n```sql\r\n\r\n-- specification : https://www.mapbox.com/vector-tiles/mapbox-streets-v7/\r\n-- osm_ids :  imposm3 single space id\r\nCREATE OR REPLACE FUNCTION osm_ids2mbid (osm_ids BIGINT, is_polygon bool ) RETURNS BIGINT AS $$\r\nBEGIN\r\n RETURN CASE\r\n   WHEN                      (osm_ids >=    0  )                    THEN (       osm_ids          * 10)       -- +0 point \r\n   WHEN (NOT is_polygon) AND (osm_ids >= -1e17 ) AND (osm_ids < 0 ) THEN ( (abs( osm_ids)       ) * 10) + 1   -- +1 way linestring\r\n   WHEN (    is_polygon) AND (osm_ids >= -1e17 ) AND (osm_ids < 0 ) THEN ( (abs( osm_ids)       ) * 10) + 2   -- +2 way poly\r\n   WHEN (NOT is_polygon) AND (osm_ids <  -1e17 )                    THEN ( (abs( osm_ids) -1e17 ) * 10) + 3   -- +3 relations linestring\r\n   WHEN (    is_polygon) AND (osm_ids <  -1e17 )                    THEN ( (abs( osm_ids) -1e17 ) * 10) + 4   -- +3 relations poly                     \r\n   ELSE 0\r\n END;\r\nEND;\r\n$$ LANGUAGE plpgsql IMMUTABLE;\r\n\r\n\r\nCREATE OR REPLACE FUNCTION is_polygon( geom geometry) RETURNS bool AS $$\r\nBEGIN RETURN CASE\r\n        WHEN ST_GeometryType(geom) IN ('ST_Polygon', 'ST_MultiPolygon') THEN true\r\n        ELSE false\r\n      END;\r\nEND;\r\n$$ LANGUAGE plpgsql IMMUTABLE;\r\n\r\n\r\nselect osm_id\r\n      ,osm_ids2mbid ( osm_id,   is_polygon( geometry ) )  as from_real_geom\r\n      ,osm_ids2mbid ( osm_id,   false                  )  as from_fake_geom_false \r\n      ,osm_ids2mbid ( osm_id,   true                   )  as from_fake_geom_true       \r\nfrom osm_place_geometry ;\r\n\r\n       osm_id        | from_real_geom | from_fake_geom_false | from_fake_geom_true \r\n---------------------+----------------+----------------------+---------------------\r\n -100000000000000003 |             34 |                   33 |                  34\r\n -100000000000000002 |             24 |                   23 |                  24\r\n -100000000000000001 |             14 |                   13 |                  14\r\n                   1 |             10 |                   10 |                  10\r\n                  -3 |             32 |                   31 |                  32\r\n                  -2 |             22 |                   21 |                  22\r\n                   2 |             20 |                   20 |                  20\r\n                   3 |             30 |                   30 |                  30\r\n(8 rows)\r\n\r\n\r\n```\r\n\r\n \r\nand carefully - we can use the  `is_polygon` parameter for tables - without checking real geometry. \r\n\r\nnow\r\n```sql\r\n SELECT osm_id_geometry(osm_id, geometry) as osm_id\r\n             , geometry\r\n              , barrier_line_class(type) AS class\r\n          FROM barrier_line_z14\r\n```\r\n\r\nBut if we knows that `barrier_line_z14`  is not contains polygons,\r\nthen we can use the 'false' constant - to the 'is_polygon' information.\r\n[  and  we can add a Check Constraints for safer implementation ]\r\n\r\nso the optimal will be:\r\n```sql\r\n SELECT osm_ids2mbid ( osm_id,   false  )  as osm_id\r\n             , geometry\r\n              , barrier_line_class(type) AS class\r\n          FROM barrier_line_z14\r\n```\r\n\r\nThis is not perfect yet ,   but  maybe you can reuse some ideas ..\r\n"}}