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

Using this with Open Street Map #144

Open
rsvancara opened this issue Sep 8, 2017 · 12 comments
Open

Using this with Open Street Map #144

rsvancara opened this issue Sep 8, 2017 · 12 comments

Comments

@rsvancara
Copy link

rsvancara commented Sep 8, 2017

I like this project and I want to like it even more. But using this with open street map data in post GIS seems problematic. My configuration is as follows and really all I want to do is just have something work.

My config:

[webserver]
port = ":80"

# register data providers
[[providers]]
name = "us"           # provider name is referenced from map layers
type = "postgis"        # the type of data provider. currently only supports postgis
host = "10.150.251.244" # postgis database host
port = 5432             # postgis database port
database = "north_america"       # postgis database name
user = "gis"         # postgis database user
password = "gis"           # postgis database password
srid = 3857             # The default srid for this provider. If not provided it will be WebMercator (3857)

  [[providers.layers]]
  name = "roads"
  geometry_fieldname = "way"
  id_fieldname = "osm_id"
  tablename = "planet_osm_roads"
  #sql = "SELECT ST_AsBinary(wkb_geometry) AS wkb_geometry, name, ogc_fid FROM all_roads_3857 WHERE wkb_geometry && !BBOX!"

  [[providers.layers]]
  name = "points"
  geometry_fieldname = "way"
  id_fieldname = "osm_id"
  tablename = "planet_osm_point"
  fields = ["name","addr:housenumber","addr:housename"]
  #[[providers.layers]]
  #name = "main_roads"
  #geometry_fieldname = "wkb_geometry"
  #id_fieldname = "ogc_fid"
  #sql = "SELECT ST_AsBinary(wkb_geometry) AS wkb_geometry, name, ogc_fid FROM main_roads_3857 WHERE wkb_geometry && !BBOX!"

  #[[providers.layers]]
  #name = "lakes"
  #geometry_fieldname = "wkb_geometry"
  #id_fieldname = "ogc_fid"
  #tablename = "lakes_3857"
  #fields = ["name"]
  #sql = "SELECT ST_AsBinary(wkb_geometry) AS wkb_geometry, name, ogc_fid FROM lakes_3857 WHERE wkb_geometry && !BBOX!"

[[maps]]
  name = "zoning"

  [[maps.layers]]
  provider_layer = "us.roads"
  min_zoom = 10
  max_zoom = 20

  [[maps.layers]]
  provider_layer = "us.points"
  min_zoom = 10
  max_zoom = 20

The database has the following tables:
public | planet_osm_line | table | gis
public | planet_osm_nodes | table | gis
public | planet_osm_point | table | gis
public | planet_osm_polygon | table | gis
public | planet_osm_rels | table | gis
public | planet_osm_roads | table | gis
public | planet_osm_ways | table | gis

But the map displays nothing. I am trying to use this with mapbox-gl as the client. I was able to get the sample data and configuration to work. I used osm2pgsql to load the data into postgis?

The client configuration is:

<script>

var mymap = L.map('mapid').setView([47.617017, -122.29238], 13);

L.tileLayer('http://10.150.251.244/hot/{z}/{x}/{y}.png', {
	maxZoom: 18,
	attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
		'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
		'Imagery © <a href="http://mapbox.com">Mapbox</a>',
	id: 'mapbox.streets'
}).addTo(mymap);

L.marker([47.617017, -122.29238]).addTo(mymap)
	.bindPopup("<b>Hello mark!</b><br />I am a popup.").openPopup();

 //L.circle([51.508, -0.11], 500, {
 //    color: 'red',
 //    fillColor: '#f03',
 //    fillOpacity: 0.5
 //}).addTo(mymap).bindPopup("I am a circle.");

 //L.polygon([
 //    [51.509, -0.08],
 //    [51.503, -0.06],
 //    [51.51, -0.047]
 //]).addTo(mymap).bindPopup("I am a polygon.");

var popup = L.popup();
function onMapClick(e) {
	popup
		.setLatLng(e.latlng)
		.setContent("You clicked the map at " + e.latlng.toString())
		.openOn(mymap);
}

mymap.on('click', onMapClick);

R

@ARolek
Copy link
Member

ARolek commented Sep 8, 2017

@rsvancara what version of tegola are you using?

When debugging I would start at the SQL. You can turn on SQL debug statements by setting the environment variable SQL_DEBUG=EXECUTE_SQL which will show you the SQL that is being run. You can then run that output against PostGIS to see if you're getting features back. If the result set is 0 then this is where the issue is. If the result set is above 0 the I would suspect the issue is with the your client side styles.

@rsvancara
Copy link
Author

I am using the latest tegola build. Here is a sample query:

SELECT "osm_id", "access", "addr:housename", "addr:housenumber", "addr:interpolation", "admin_level", "aerialway", "aeroway", "amenity", "barrier", "bicycle", "bridge", "boundary", "building", "construction", "covered", "foot", "highway", "historic", "horse", "junction", "landuse", "layer", "leisure", "lock", "man_made", "military", "name", "natural", "oneway", "place", "power", "railway", "ref", "religion", "route", "service", "shop", "surface", "tourism", "tracktype", "tunnel", "water", "waterway", "way_area", "z_order", "tags", ST_AsBinary("way") AS "way" FROM planet_osm_roads WHERE "way" && ST_MakeEnvelope(1.3658379708320316e+07,6.026906805390624e+06,1.3697515466796879e+07,5.9877710469140615e+06,3857);

@ARolek
Copy link
Member

ARolek commented Sep 8, 2017

@rsvancara just to confirm, you're using v0.4.0-alpha?

Did you test that query against your database to confirm it returned features?

@rsvancara
Copy link
Author

Yes, I am using v0.4.0-alpha.

That is the query and it is not returning features. I guess I dont understand how to find my bounding box to query for features. I have only loaded north america as my region.

Thanks,

@ARolek
Copy link
Member

ARolek commented Sep 8, 2017

@rsvancara I think the issue might be your import actually (sorry I missed that initially). When working with the OSM PBF extracts you will want to use a tool like imposm3 to convert from the node / ways storage that OSM uses.

We have a repo to help with setting up tegola and OSM. It comes with imposm3 mapping files, tegola config files, and mapbox-gl style files. Check out tegola-osm.

@ARolek
Copy link
Member

ARolek commented Oct 14, 2017

@rsvancara were you able to get setup using tegola and OSM? I would like to close this issue unless you're still in need of assistance.

@MohammedAlsayed
Copy link

@ARolek where are the mapbox-gl style files ?

@ARolek
Copy link
Member

ARolek commented Jan 15, 2018

@MohammedAlsayed All the styles that use the tegola-osm schema and can be seen at demo.tegola.io can be found in the demo repo at https://github.com/go-spatial/tegola-web-demo/tree/master/styles.

@simonpoole
Copy link

simonpoole commented Feb 3, 2019

Surprised that this is still open, but anyway: osm2pgsql -is- an importer for OSM data than instantiates geometries in a Postgres/PostGIS database and matter of fact it is the by far the most popular one as it hits a sweet spot between enabling rendering and still remaining close to the original OSM data.

It would be very nice if there were pre-made examples that support the osm2pgsql schema and not only imposm and would likely do wonders for tegolas adoption.

@ARolek
Copy link
Member

ARolek commented Feb 3, 2019

@simonpoole I completely agree I just have not carved out time to build the tegola config and test it with osm2pgsql schema. I would gladly help with this effort and I think it would make a great addition to the tegola-osm repo. That repo could be reorganized to show examples from imposm, osm2pgsql and OpenMapTiles. Ideally there would be example configs for each schema and associated base styles.

Would you be interested in helping with the effort?

@dBitech
Copy link

dBitech commented Feb 3, 2019

@ARolek I'd be interesting in helping with this effort as well.

@simonpoole
Copy link

Well I can at least give a couple of pointers if necessary.

mstock added a commit to mstock/tegola-openstreetmap-carto that referenced this issue Jun 3, 2019
This is a pretty complex sample as it is based on the openstreetmap-carto
CartoCSS style [1] and is thus showing that it is indeed possible to setup
Tegola with an osm2pgsql-based database (see also go-spatial/tegola#144 for
a discussion about this) and might thus serve as the example mentioned in
go-spatial/tegola-osm#51.

[1] https://github.com/gravitystorm/openstreetmap-carto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants