News for hackers. Stuff that matters.
Re:Openstreetmap, a global map for worldwide insight by kristopolous on Friday July 03, 2020 @05:55AM (#23722622)
Let me plug OpenLayers, which uses OSM and is way harder to use than google maps but once you stop hating on it you realize it can do a bunch of things that google maps really can't and is more versatile in numerous ways - ymmv as always. (https://openlayers.org/en/latest/examples/).

I've found it more useful for specific applications that I build because it's far more customizable. The map truly feels like it's part of the app and not just some mapbox or leaflet thing sitting on top of gmaps. Again, these aren't hard facts, just stylistic preferences on my part.

The ES6 is not really a dealbreaker if you're using something more traditional. I just make my own "map.js" that exposes the interfaces I need, then I transpile it and include it like anything else.

I know that sounded really complicated, but my package.json is 10 lines, that's it.

This way you can use it in a much more conventional classical way without jumping the whole project over to ES6 syntax.

Re:Openstreetmap, a global map for worldwide insight by 7952 on Friday July 03, 2020 @07:37AM (#23723118)
I find that if you need more complex mapping features then OpenLayers is really good. It can do an amazing amount straight out of the box, but it does take time to get used to the API. It is more like an actual mapping or GIS program.

But for building functionality outside of the map I tend to use Leaflet instead due to the ease of use. You can treat the map more like a black box and the API is easier to use.

Re:Openstreetmap, a global map for worldwide insight by xfour on Friday July 03, 2020 @11:12AM (#23724694)
Surprised that no one is talking about ways to leverage the server so you’re not doing all the work on the client. You can shift layers by precomputing either raster or vector so you don’t push your poor, maybe mobile client to the max.

Classically you would do this with Tilemill for rasters which was amazing software, if crashy. And since we’re on a mapbox thread what I think put them on the map. I wish it was still actively developed and adapted for vectors.

Re:Openstreetmap, a global map for worldwide insight by bdon on Friday July 03, 2020 @11:29AM (#23724834)
Precomputing raster tiles became painful once screen densities started to demand @2x and even @3x resolution images.

https://github.com/go-spatial/fresco and https://github.com/maputnik/editor are TileMill-like editing programs, though specific to one tile format and renderer (MapboxGL)

Re:Openstreetmap, a global map for worldwide insight by bentaber on Friday July 03, 2020 @12:17PM (#23725228)
tippecanoe (also from mapbox) is fantastic software for vector tile generation. https://github.com/mapbox/tippecanoe
Re:Openstreetmap, a global map for worldwide insight by everybodyknows on Friday July 03, 2020 @01:11PM (#23725666)
OpenLayers supports rotation, Leaflet does not -- a considerable difference in implementation burden.

https://github.com/Leaflet/Leaflet/issues/268

https://openlayers.org/en/latest/examples/rotation.html

This is a critical point for anyone selecting an API to build on top of with their own ambitious new web app idea.

Re:Openstreetmap, a global map for worldwide insight by kristopolous on Friday July 03, 2020 @09:32AM (#23723839)
Absolutely. If you want something that's no hassles there's a lot of great options.

Heck I'll just do the straight Google maps api often, it's really easy.

OpenLayer is like vim/emacs, some people think the hassle is worth it.

Re:Openstreetmap, a global map for worldwide insight by alec_kendall on Friday July 03, 2020 @11:25AM (#23724799)
The viability of using Google maps really comes down to the application. An application with a lot of users that rely on the usage of street view can become very expensive.

Nice quote: “Don't lose out on the potential of tomorrow by thinking too big today.”

Re:Openstreetmap, a global map for worldwide insight by jokoon on Friday July 03, 2020 @08:18AM (#23723313)
How can I generate raster tiles myself for a specific region, so I don't have to use planet.osm?

I can find regions on geofabrik.

Re:Openstreetmap, a global map for worldwide insight by bdon on Friday July 03, 2020 @08:46AM (#23723490)
Most production raster tile systems use osm2pgsql + Mapnik. These are not easy to install. You may need to generate two or three sets of raster tiles for different pixel densities. The total number of tiles will explode past around zoom level 15. https://switch2osm.org is a good intro.

The newer way to do raster tiles is to actually generate vector tiles first, and then do the rasterization dynamically. Mapnik can do this, renderers like MapboxGL can be run in headless mode to do this as well.

Yes, I wish this was easier too.

Re:Openstreetmap, a global map for worldwide insight by berkes on Friday July 03, 2020 @09:36AM (#23723879)
In addition, modern browsers can display vector tiles directly. Mobile and apps have a somewhat harder time with this. https://www.maptiler.com/ has a good introduction for this wrt Open Street Map.
Re:Openstreetmap, a global map for worldwide insight by bdon on Friday July 03, 2020 @10:04AM (#23724116)
Vector tiles with OpenLayers doesn't feel as smooth to me compared to MapboxGL or Tangram https://openlayers.org/en/latest/examples/mapbox-style.html but it seems to be improving rapidly.
Re:Openstreetmap, a global map for worldwide insight by for_xyz on Saturday July 04, 2020 @05:00AM (#23731096)
Last time I checked (almost 2 years ago) OpenLayers did not support webgl backend for vector graphics. That's why it was slower.
Re:Openstreetmap, a global map for worldwide insight by jokoon on Friday July 03, 2020 @02:53PM (#23726465)
Aren't those vector tiles a little heavy, since they're likely json?

Of course I can guess a lot of data can be removed and simplified, but still, PNG seem lighter...

Re:Openstreetmap, a global map for worldwide insight by nbadg on Friday July 03, 2020 @07:01PM (#23728370)
I believe, but haven't bothered to profile, that they're lighter. You can also pre-"render" the vector tiles and store them in eg S3. All styling is done in-browser, which means you can do neat things like swap out the styles client-side for dark mode without needing to reload map tiles.

The primary standard for vector tiles is Mapbox Vector Tiles (it's an open standard), which is really just a sqlite database following a particular schema.

My own personal experience developing against both png and vector tiles over the past few months is that vector tiles are better in just about every way for the kinds of things you use maps for in apps. I expect that some dataviz applications, though, would be better served by raster tiles, since you'd end up generating a raster overlay anyways.

Re:Openstreetmap, a global map for worldwide insight by durkie on Friday July 03, 2020 @03:27PM (#23726747)
It depends on the application, but I don't think they're necessarily larger in size. I believe the format is quite compressed (Mapbox Vector Tile/MVT, which I believe is a variant of protocol buffers).

Many vector tile encoders have wide flexibility in geometry simplification/removal depending on zoom layer and this helps big time with tile size. I find them to be quite nice in lower bandwidth situations because you can overzoom them and still have them look good: if you zoom in and the tiles for the next zoom level haven't loaded, the vector geometry is still able to look decent, rather than pixellated like a raster tile.

Re:Openstreetmap, a global map for worldwide insight by nbadg on Friday July 03, 2020 @07:03PM (#23728385)
You're mixing up the formats slightly: MVT is sqlite with a particular schema; OSM raw data is PBF with a particular schema.
Re:Openstreetmap, a global map for worldwide insight by durkie on Saturday July 04, 2020 @03:15PM (#23734286)
Isn't mbtiles sqlite?
Re:Openstreetmap, a global map for worldwide insight by nbadg on Sunday July 05, 2020 @02:50AM (#23737040)
It might be that pbfs are stored inside sqlite? The whole thing is really incredibly confusing to be honest.

What I can tell you is that my vector slippymap XHR is requesting .pbf files, so that would definitely imply protobuffers as the wire format. Ultimately that's using t-rex and mapbox-gl.js, so... not sure if there's something intermediate. But the mapbox docs say sqlite? I'm just very confused now.

Re:Openstreetmap, a global map for worldwide insight by maxerickson on Sunday July 05, 2020 @12:36PM (#23739915)
Re:Openstreetmap, a global map for worldwide insight by nbadg on Monday July 06, 2020 @05:34PM (#23753044)
Yep, versus https://docs.mapbox.com/help/glossary/mbtiles/ -- I had them backwards. My confusion might have been because of the name similarities (mbtiles vs mvt), which took me 3 tries to even just type correctly.
Re:Openstreetmap, a global map for worldwide insight by jokoon on Friday July 03, 2020 @04:54PM (#23727533)
Compressed? Are you saying decompression is done with JS?
Re:Openstreetmap, a global map for worldwide insight by kylebarron on Friday July 03, 2020 @10:16AM (#23724231)
A popular open source server-side rasterization program is tileserver-gl: https://github.com/maptiler/tileserver-gl
Re:Openstreetmap, a global map for worldwide insight by jokoon on Friday July 03, 2020 @03:03PM (#23726538)
> Yes, I wish this was easier too.

I've used spatialite, and even though the doc is poor, I've managed to do things with it, and it works fine.

I'm not sure I can generate tiles with QGIS and spatialite.

It's true that open source GIS software is not easy to find, since GIS is not easy in the first place.

Re:Openstreetmap, a global map for worldwide insight by kristopolous on Friday July 03, 2020 @09:43AM (#23723936)
You can map layers using different sources. You need to use fromlatlng to do the mapping. You can define your source so long as you use the tile server protocol (TMS).

You don't need everything, you just provide the areas you want and layer accordingly

I'm on my mobile typing this but hopefully that's enough to get you started.

It should probably take less than a day. There's certainly nuanced GIS wonkiness, let's not pretend otherwise. But when I did set up a tile server I remember it being one of those things you think you simply cannot do without taking like 6 months of cartography night school, but then 45 minutes later it's done.

The domain specific knowledge requirements for standard usage required lightly scanning a couple Wikipedia pages. nothing serious.

Re:Openstreetmap, a global map for worldwide insight by srrr on Friday July 03, 2020 @01:42PM (#23725901)
I do a cycle map with my own style and these are my steps and tools:

1) Download a region from geofabrik. 2) Extract, transform and load the data into pgsql with osm2pgsql. I use the osm2pgsql flex mode. QGis can load osm extracts direcly, but the resulting layers have many errors in the details and using pgsql is much faster while viewing and rendering. Imposm is also a good alternative to osmpgsql. 3) Use QGis for styling the map. 4) Generate static tiles with https://docs.qgis.org/3.10/en/docs/user_manual/processing_al... (With DPI 250 and a tilesize of 512x512 for use on high resolution screens.) 5) Upload the tiles to my own server. 6) Load the tiles in OSMAnd as a custom map.

Qgis has a build in tile server https://www.qgis.org/de/site/about/features.html#qgis-server and leaflet can load the tiles via https://leafletjs.com/reference-1.6.0.html#tilelayer-wms . But this does not work for OSMAnd.

QGis can also create beautiful print maps with the "Atlas" feature.

Re:Openstreetmap, a global map for worldwide insight by jokoon on Friday July 03, 2020 @03:04PM (#23726550)
Can I use spatialite coupled with QGIS to generate those tiles? How well does it perform?
Re:Openstreetmap, a global map for worldwide insight by srrr on Friday July 03, 2020 @07:39PM (#23728631)
On my system spatialite is 10% the speed with the Germany extract compared to PostgreSQL. Bigger extracts don't work properly.

But loading data directly from a osm.pbf or loading data via the QGis QuickOSM plugin into a spatialite file gives two problems:

1) You can not transform the data to fit your personal usage. Raw osm data is not nice to work with.

2) I had many problems with areas stored as relations (example: islands in lakes) and relation handling overall is a mess.

For the first steps and to toy around osm data in spatialite works. But don't fear osm2pgsql. For standard use cases it's a oneliner.

Re:Openstreetmap, a global map for worldwide insight by OmarShehata on Friday July 03, 2020 @07:27PM (#23728535)
(Disclaimer, I work at Cesium) we've been working on making this easier. If you have a bunch of GeoTIFFs of satellite imagery you can drag and drop them into our platform and get WMTS/TMS tiles you can stream into whatever client.

See: https://cesium.com/docs/tutorials/uploading/

Would love to hear your feedback.

Re:Openstreetmap, a global map for worldwide insight by veza on Friday July 03, 2020 @06:34AM (#23722811)
I feel like this is the story of open source tools. Way harder to use but once you know the tool the power and freedom is much greater, and even the pleasure of using it.

I'm also thinking of cli vs gui here.

Sounds like delayed gratification.

Re:Openstreetmap, a global map for worldwide insight by grawprog on Saturday July 04, 2020 @03:28PM (#23734345)
Years ago I used openlayers and osm to develop an online map to display data for a research project I was working on. I originally considered using Google's api, but their licensing at the time was incompatible with the terms of our grant regarding our collected data.

I enjoyed working with OSM, it was actually my first experience building an application around an external API. It was a fun experience and i was fairly pleased with the way it turned out.

It ended up going live for a small time, though, we ended up running into a snag with the government after finding an endangered species in an active mine site and were forced to remove our public data and submit it all to a private government database locked behind fees.

Re:Openstreetmap, a global map for worldwide insight by kalyanganjam on Friday July 03, 2020 @08:22AM (#23723332)
Started using OpenLayers 2 weeks ago for a side project. Agree with you on power of OL. I just started basic features and already loving it.

Apart from OL API doc. Could you please recommend any book/course to learn both concepts & API.

Re:Openstreetmap, a global map for worldwide insight by kristopolous on Friday July 03, 2020 @09:28AM (#23723808)
Nope. Just read the source code. All the references I have seen online are outdated or aggravatingly incomplete.

Seriously. The nicest part about the source is that it doesn't lie.

It's rarely as scary as your anxiety tells you it's going to be. Even for larger projects. You got it, may as well use is.

Re:Openstreetmap, a global map for worldwide insight by simonw on Friday July 03, 2020 @05:07PM (#23727665)
Any chance you could share your package.json in a gist? I'm trying to get more familiar with them, would love to see a clean 10-line example.
Re:Openstreetmap, a global map for worldwide insight by jseliger on Friday July 03, 2020 @11:29AM (#23724841)
Let me plug OpenLayers, which uses OSM and is way harder to use than google maps but once you stop hating on it you realize it can do a bunch of things that google maps really can't and is more versatile in numerous ways

I have Open Street Map on my phone, and "harder to use" describes it well. The problem is that for me, and, I'd bet, for many others, "easy to use" is the most important thing a map app can do.

Re:Openstreetmap, a global map for worldwide insight by D_Guidi on Friday July 03, 2020 @03:19PM (#23726682)
openlayers is more a gis platform, while leaflet is easier to use and closer to Google maps api