loading large geojson files on demand - geojson

we are implementing Mapbox gljs and we have several large geojson files roughly 70-100mb that we are loading from an API (REST URL) THe map does load the layer and will render it performantly which is fine however the browser memory increases significantly and clearly will not work on mobile view downloading such large files over the mobile network.
Is there a way to load a different URL based on the current viewport and change the data source on map movement for example?
Interested to know the best way to implement this.

I think what you are looking for are Vector Tiles. It's an implementation of spatial data, where whenever the viewport changes the Coordinates and Zoomlevel are send to a server and only the data within the bbox is served.
You need to create a Tileset and either host it on a mapbox server or on your own tileserver. A tool worth recommanding for creating tilesets is is tippecanoe.

Related

how to draw custom lands for OSM

I would like to know how to draw custom lands for an Openstreetmap project. My final purpose is to reproduce a fantasy map with OSM technology.
It's not clear to me how I can generate lands data (continents, islands and so on).
I know is it possible because the project https://opengeofiction.net/ do basically the same thing.
I am a new OSM user and I am moving the firsts steps with GIS software.
I have built my own tile server on the cloud (Ubuntu 18-04) following different tutorials.
I installed JOSM and QGIS to edit maps, but I feel a bit lost with all that options and features.
I already posted questions in openstreetmap forum but I got no response.
I am sure I need only a little hint to get started.
My expected result is to be able to draw a little "imaginary" island.
On a small scale you can use JOSM without OSM download/upload, and just save your edited data locally as an OSM XML file.
That again can then be fed into the different renderers as source file.
On a large scale you would end up creating a copy of the whole OSM stack, serving your own data, like https://wiki.openstreetmap.org/wiki/OpenGeofiction does

MapBox, Google Maps and big datasets

Could you please explain me how to work with big datasets in Mapbox and GMaps? Let me explain - imagine you have service with big amount of points (for example - directory of lost things around the world) and you need to show to users points in his region. Currently I see only those options:
allow to download entire database to the client (browser or mobile), but it will take a lot of traffic :(
determine on client visible bounds of map and send information about visible area to application server on each zoom in/out, but it may take a lot of requests to application server.
In both cases I will need to deal with clustering API to keep map useful for users.
But, as I understand - there are Dataset API on mapbox and Data layer on google maps to deal with big amount of data without application server (only with S3 in mapbox). Could you explain me best practices and show examples how to work with big amount of points?

Temporary tiles cache for Mapserver

I was searching on Google and StackOverflow to see if anyone have solution for my problem, but didn't found anyone with same problems.
So, currently I'm running Debian machine with Mapserver installed on it. The server also run webserver for displaying map data over the browser. The generation of map is dynamic, based on layers definition in database I built mapfile in PHP and based on that generated PHP the map is shown to user. The data is defined in database and as a SHP files (both combined in single mapfile).
It is fully dynamic, what I mean with that is that user can enable/disable any of layers or click inside polygon (select some points on map) it color the selection (generate new mapfile based on selection and re-generate tiles).
So the execution of all that code from selecting some area to coloring selected items somtimes take too much time for good user experience.
For solution I'd like to use some kind of temporary tiles cache, that can be used for single user, and to be able to delete it's content when user select some items on map or enable/disable one of the layers.
P.S. I already did all the optimizations provided from Mapserver documentation.
Thanks for any help.
It sounds to me like your problem is not going to be helped by server-side caching. If all of the tiles depend on user selections, then you're going to be generating a bunch of new tiles every time there's an interaction.
I've been using MapCache to solve a similar problem, where I am rendering a tileset in response to a user query. But I've broken up my tiles into multiple logical layers, and I do the compositing on the browser side. This lets me cache, server-side, the tiles for various queries, and sped up performance immensely. I did seed the cache down to zoom level 12, and I needed to use the BerkeleyDB cache type to keep from running out of inodes.
I'm using Leaflet.js for the browser-side rendering, but you should also consider OpenLayers.
After looking at the source code, I have some other ideas.
It looks like you're drawing each layer the same way each time. Is that right? That is, the style and predicate of a particular layer never change. Each user sees the image for that layer the same way, if they have selected the layer. But the combination of layers you show does change, based on OpenLayers control? If that's the case, you don't need per-user caching on the server. Instead, use per-layer caching, and let the user's browser figure out the client side caching.
A quick technique for finding slow layers is to turn them all of. Then reenable them one by one to find the culprit. Invoke Mapserver from the command line, and time the runs, for greater precision than you'll get by running it from your webserver.
You mentioned you're serving the images in Google 3857 while the layers are in Gauss-Kruger/EPSG 3912. Reprojecting this on the fly is expensive. Reprojecting the rasters on the fly is very expensive. If you can, you should reproject them ahead of time, and store them in 3857 (add an additional geometry column).
I don't know what a DOF file is--maybe Digital Obstacle File? Perhaps preload the DOF file into PostGIS too? That would eliminate the two pieces you think are problematic.
Take a look at the SQL queries that PostGIS is performing, and make sure those are using indexes
In any case, these individual layers should go into MapCache, in my opinion. Here is a video of a September 2014 talk by the MapCache project leader.

How to set up an image to be used with openlayers?

I have a big image that I want to display on my website, and allow people to navigate it like a map (zoom and move around).
OpenLayers 3 seems to be a good technology for the client side.
Now the question is: how do I set up the server side so that it can serve the image tiles in a way that works with OpenLayers?
Note that there is no "geographical data" to be displayed, just a plain image.
More details: the server side is a pretty common apache+php host. Ideally, I'd just want to split the image with an automatic tool and upload it, and let openlayers take care of the rest.
Could possibly use a service like http://www.maptiler.com/ ?
It looks like you can add non-georeferenced raster images, and have it create tiles for you. Then the tiles could be hosted on your server and used with OL3 or whatever client-side mapping tool.
If your image is not prohibitevely big you could use the ol.layer.Image layer that allows feeding a static image from a URL to it. This has the benefit that you can use the image as-is, without having to split it into tiles or use some fancy protocol to communicate with the tiles server.
There is an official live example with code included.

Ideas for rendering 2d autocad drawings in a browser

I'm working on a .net mvc web application. A core piece of functionality is a requirement to take a DWG (AutoCAD) file, and render it on the web application, in such a way that the user can zoom in/out and move about the drawing. I also need to add overlays to the drawing to represent various things.
I'm trying to work out the best way to do this. There are various .net CAD libraries out there but the best you can get browser-based are tools that will convert the file to an image on the server and render it on the page.
My current idea is to convert the dwg to an image, use something like google maptiler to chop up the image at various zoom levels, and then use something like openlayers.org to present this to the user.
Are there other/easier/better solutions?
You could convert the DWG to a GIS format like a geo-referenced image (e.g. geoTIFF), and then use a map server to serve the image to OpenLayers or to Google Maps.
Essentially the map server chops up the tiles for you on-the-fly as they are requested. This means you can support arbitrary zooming and panning.
This is the "purest" way of doing things with OpenLayers - and it's a lot easier than it might sound. MapServer & GeoServer are good free open source map servers, this is vanilla stuff for them. In the past I used to chop up images into Google Maps tiles myself, but I'm not going back now.
You may want to look Autodesk's Freewheel application, which allows you to render 2D and 3D files on the server.
Another possibility would be to convert the relevant parts of the drawing file to your own format, and render them with Javascript. You can use a library like Dojo to facilitate this. This approach is more work, but you will get cross-browser compatibility and more control over the display.

Resources