sexta-feira, 26 de agosto de 2016

Create your own OpenStreet Maps Server

Why?

Did you see this site? http://leafletjs.com/





Do you like the sample, and now, how to implement? There are a great different between Google Maps because LeaFlet use OSM (Open Street Maps) and now is time to create your own server.

"If it's just for your own use, that should be fine, but if you are writing an application for many people to use (with many people needing to download tiles), then that might put too much load on the project's servers and it would probably be better to make your own tiles.

Anyone can do this, using free software, and there are various how-to guides explaining how to do it, like the one at Serving Tiles | switch2osm . Basically you download the OSM database itself, and render your own tiles (in whatever style you like) on your own computer. You can license your map tiles however you like (you can even charge money for them), so long as you display the OSM copyright message, which is a license requirement of using the database."

just little hack ...ignore all this and download this docker...
https://hub.docker.com/r/homme/openstreetmap-tiles-docker/~/dockerfile/ 

How?


This is not a GUIDE, but is SANDBOX with all good steps to generate your first Map.


Python 2.x https://www.python.org/downloads/
GIS Server http://postgis.net/


drop table planet_osm_ways;
drop table planet_osm_roads;
drop table planet_osm_rels;
drop table planet_osm_polygon;
drop table planet_osm_point;
drop table planet_osm_nodes;
drop table planet_osm_line;


SELECT ST_AsBinary("way") AS geom,"railway" FROM (select way,highway,
case when tunnel in ('yes','true','1') then 'yes'::text else tunnel end as tunnel,
case when railway='preserved' and service in ('spur','siding','yard') then 'INT-preserved-ssy'::text else railway end as railway
from planet_osm_roads
where highway is not null
or (railway is not null and railway!='preserved' and (service is null or service not in ('spur','siding','yard')))
or railway='preserved'
order by z_order
) as roads WHERE "way" && ST_SetSRID('BOX3D(66653.08866467369 6665920.362693647,69099.07356979932 6668366.347598774)'::box3d, 900913)




select *
from planet_osm_point
where aeroway in ('airport','aerodrome','helipad')
or barrier in ('bollard','gate','lift_gate','block')
or highway in ('mini_roundabout','gate')
or man_made in ('lighthouse','power_wind','windmill','mast')
or (power='generator' and ("generator:source"='wind' or power_source='wind'))
or "natural" in ('peak','volcano','spring','tree','cave_entrance')
or railway='level_crossing'




Processed Data
These tables hold the data which Mapnik uses for rendering:

planet_osm_line: contains all imported ways
planet_osm_point: contains all imported nodes with tags
planet_osm_polygon: contains all imported polygons. Relations seem to be resolved for that.
planet_osm_roads: contains a subset of `planet_osm_line` suitable for rendering at low zoom levels. `planet_osm_line` contains too many elements to render on overview maps. Selection is based on certain tags being set[1]
Each table has a way column containing the geometry for the object in the chosen projection. Two indices are created for each table: one for the way column and one for the osm_id column. Geometry uses coordinates in the EPSG:900913 AKA G00GlE projection and can be easily used in e.g. OpenLayers based JavaScript.

Notice that relations are not imported directly. Ways which are members of relations are imported in a special manner (see description for planet_osm_line), but there is no easy way to establish a relationship between a relation and its members, or to get tags associated with a relation (unless they have ways as members).


a) Download all fonts and storage on /gis/fonts/DejaVuSans*.*

http://dejavu-fonts.org/wiki/Download

               python -c "import mapnik;print mapnik.fontscollectionpath"

 https://github.com/gravitystorm/openstreetmap-carto/blob/master/INSTALL.md





b) Download symbols on   /mapnik-v2.2.0/symbols/aerodrome.p.16.png*.*

c)wget --no-check-certificate https://download.geofabrik.de/south-america/suriname-latest.osm.pbf
osm2pgsql -c -d osm -U postgres -H localhost -S default.style suriname-latest.osm.pbf

http://learnosm.org/en/osm-data/osm2pgsql/


Teste with QGIS - http://www.qgis.org/en/site/

d) python generate_xml.py osm.xml brz_osm2.xml  --dbname gis --user postgres --host 'localhost' --port 5432 --user postgres --password password

A little bit about the osm.xml. This file contains all the styling rules for generating the tiles and serves as a template for building your final styling .xml. It defines the icons to use, how to draw the lines and so forth. If you are not happy with the default mapnik styling and want to highlight certain features differently, you can manually edit this xml file and resave it under say osm_custom.xml before you start to build you run the generate_xml.py and use that where we are using osm.xml.

 e)exports:
    MAPNIK_MAP_FILE=/mapnik-v2.2.0/brz_osm2.xml
    MAPNIK_TILE_DIR=/mapnik-v2.2.0/mapa/saopaulo


#!/usr/bin/env python

try:
import mapnik2 as mapnik
except:
import mapnik


import sys, os


f) vim generate_tiles.py
 
Zoom level 0: 256 px
Zoom level 1: 512 px
Zoom level 2: 1024 px
Zoom level 3: 2048 px
Zoom level 4: 4096 px
Zoom level 5: 8192 px
Zoom level 6: 16384 px


g) python vim generate_tiles.py

   Choose the Bounds: https://www.openstreetmap.org/export#map=5/54.521/-2.197

Done.


I know that is no so simple, but is a macro vision about the process.

Are you lost? Try other refers.
Refer:

https://nominatim.openstreetmap.org/
https://translate.mapsmarker.com/projects/lmm
https://www.mapsmarker.com/2013/06/05/pro-preview-marker-clustering/
http://wiki.openstreetmap.org/wiki/Zoom_levels
https://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/
https://hub.docker.com/r/homme/openstreetmap-tiles-docker/~/dockerfile/
https://www.packtpub.com/hardware-and-creative/openstreetmap
https://www.openstreetmap.org/#map=16/-22.9783/-43.3945 VilaOlimpica
http://download.geofabrik.de/south-america/brazil.html
https://github.com/mapserver/mapserver/wiki/RenderingOsmDataWindows#osm-import
http://ms4w.com/download.html#download
http://wiki.openstreetmap.org/wiki/Nominatim/Installation_on_CentOS
nonimatim demo: https://nominatim.openstreetmap.org/
http://wiki.openstreetmap.org/wiki/Pt-br:Nominatim

http://softwaresimian.com/2012/12/02/openstreetmap-osm-install-on-windows-part-i-the-database/
http://softwaresimian.com/2013/02/20/openstreetmap-osm-install-on-windows-part-ii-generate-tiles/

http://learnosm.org/en/osm-data/osm2pgsql/
https://github.com/mapnik/mapnik/wiki/WindowsInstallation
https://github.com/mapnik/mapnik/wiki/GettingStartedInPython



gdal_translate -of JPEG -out size 16384 16384 eso1119a.jpg eso.jpg

gdal_translate -of JPEG -out size «target witdth» «target height» «source file» «target file»

gdal2tiles.py -p raster -z 0-6 -w none saopaulo.png
python-3.4.0.amd64.msi
gdal-111-1800-x64-core.msi
GDAL-1.11.3.win-amd64-py3.4.msi

Editores: TileMill-v0.10.1-Setup.exe,
https://josm.openstreetmap.de/
, QGis

https://astrodigital.com/
https://vimeo.com/162880558 
http://ncap.org.uk/

Postar um comentário