Cartographic web services can be divided into two large groups: dynamic and cached. In the first case, each time when scaling or moving, the data is accessed and the image is redrawn, taking into account the new coverage. At the same time, the client receives only ready-made raster images - they are rendered by the server.
In the case of a cached service, a mosaic of raster images (tiles) for each scale is ready in advance, so the work is done an order of magnitude faster. Of course, the complexity of the design and the data itself does not affect the display speed - this is a big plus. But there are also obvious limitations: when changing data, it is necessary to recalculate the cache, you cannot edit objects and control the display of layers, the list of scales is fixed. It is also worth remembering that the cache recalculation can take several days and even weeks (!) Depending on how complex the card is based on.
Therefore, the choice between dynamic and cached service is not as obvious as it might seem at first glance. As a rule, it makes sense to make a cached service with rarely or fragmentarily updated data, to create maps-substrates for dynamic services, or if the project itself is small - the cache can be quickly recalculated. There is another version of the multilayer cache, where each layer is a separate raster mosaic. However, the performance of the service in this case leaves much to be desired - because the web server has to dynamically overlay the rasters of layers on each other.
sudo apt-get install curl build-essential libssl-dev libsqlite3-0 libsqlite3-dev
git clone --depth 1 git://github.com/joyent/node.git cd node git checkout v0.4.9 export JOBS=2 # optional, sets number of parallel commands. mkdir ~/local ./configure --prefix=$HOME/local/node make make install echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile source ~/.profile
curl http://npmjs.org/install.sh | sh
git clone git://github.com/mapbox/tilestream.git cd tilestream npm install -g tilestream
-g
switch tells npm that the tilestream needs to be installed globally. This will require superuser rights. To install locally (in the current directory), simply omit this key. tilestream
npm install -g expresso cd tilestream npm test
tilestream --host 127.0.0.1 tilestream --host yourhost.com
tilestream start --help
localhost:8888/map/[filename]
localhost:8888/map/[filename]
, where [filename]
name of the tile set, without the .mbtiles extension. world-light.mbtiles control_room.mbtiles PartyLikeIts1999.mbtiles
World Light.mbtiles BlueWorld-1.0.mbtiles
/{z}/{x}/{y}.[image format]
{z}
is the presentation level (zoom), {x}
and {y}
coordinates. TileJSON represents the URL of a set of tiles replacing these tags (placeholders) so that you can get any tile from the set. https://habrastorage.org/getpro/habr/post_images/e09/b8b/605/e09b8b60541e60473a21c777c75bcff9.png
{ "version": "1.0.0", "scheme": "tms", "tiles" ["http://a.tile.mapbox.com/1.0.0/world-light/{z}/{x}/{y}.png"] }
version
key specifies that the 1.0.0 version of the TileJSON specification is used.scheme
key describes the tile coordinate system used (MapBox tile sets use TMS)tiles
key contains an array of URLs from which tiles are requested. git clone git://github.com/mapbox/wax.git
<html> <head> <script src='wax/ext/modestmaps.min.js' type='text/javascript'></script> <script src='wax/dist/wax.mm.js' type='text/javascript'></script> <link href='wax/theme/controls.css' rel='stylesheet' type='text/css' /> ...
wax/ext/modestmaps.min.js
- contains the Modest Maps librarywax/dist/wax.mm.js
- contains code integrating Wax and Modest Mapswax/theme/controls.css
- contains styles for controlswax.mm.connector
. var tilejson = { tilejson: '1.0.0', scheme: 'tms', tiles: ['http://a.tiles.mapbox.com/mapbox/1.0.0/world-light/{z}/{x}/{y}.png'] }; // Alias com.modestmaps to mm. This isn't necessary - // just nice for shorter code. var mm = com.modestmaps; // Set up a map in a div with the id 'modestmaps-setup' var m = new mm.Map('modestmaps-setup', // Use Wax's connector to add a new custom layer new wax.mm.connector(tilejson), // And it'll be 240px by 120px new mm.Point(240,120)); // Center it on the United States, at zoom level 2. m.setCenterZoom(new mm.Location(39, -98), 2);
modestmaps-setup
. <div id="modestmaps-setup"></div>
<html> <head> <script src='wax/ext/leaflet.js' type='text/javascript'></script> <script src='wax/dist/wax.leaf.js' type='text/javascript'></script> <link href='wax/ext/leaflet.css' rel='stylesheet' type='text/css' /> ...
wax/ext/leaflet.js
- contains the LeafLet librarywax/dist/wax.leaf.js
- contains code integrating Wax and LeafLetwax/ext/leaflet.css
- contains design styles for controlswax.leaf.connector
. var tilejson = { tilejson: '1.0.0', scheme: 'tms', tiles: ['http://a.tiles.mapbox.com/mapbox/1.0.0/geography-class/{z}/{x}/{y}.png'], grids: ['http://a.tiles.mapbox.com/mapbox/1.0.0/geography-class/{z}/{x}/{y}.grid.json'], formatter: function(options, data) { return data.NAME } }; var map = new L.Map('leaflet-simple') .addLayer(new wax.leaf.connector(tilejson)) .setView(new L.LatLng(51.505, -0.09), 1); wax.leaf.interaction(map, tilejson);
Source: https://habr.com/ru/post/123290/
All Articles