Changeset 71

Show
Ignore:
Timestamp:
13.10.2009 11:05:51 (6 weeks ago)
Author:
blackhex
Message:
  • Script that generates nice OpenStretmapPosters? added.
  • osm-template.xml and other relevant files removed. New osm.xml and new Mapnik style customization schema introduced.
  • openlayes.html updated.
  • generate_tiles.py uses internal mapnik buffer at borders now.
Location:
OpenTrackMap
Files:
19 added
8 removed
10 modified

Legend:

Unmodified
Added
Removed
  • OpenTrackMap

    • Property svn:ignore
      •  

        old new  
        1 demtools 
        2 osm2pgsql 
        31commit.sh 
  • OpenTrackMap/bin

    • Property svn:ignore set to
      demtools
      gdal
      mapnik-*
      osm_mapnik
      osmosis-*
      osm2pgsql
      postgis-*
      tiff-*
  • OpenTrackMap/bin/full_update_osmosis.py

    r70 r71  
    2121    return system(command) 
    2222 
    23 """for I in range(14): 
     23for I in range(14): 
    2424    # Delete previous planet file. 
    2525    execute("rm -rf %s" % (osm_data_file,)) 
     
    3636 
    3737# Bound it with bonding region of CR. 
     38#execute('bzcat %s | %s --read-xml file=- --bounding-box left="12.10"' 
     39  #' right="18.87" top="51.06" bottom="48.55" --write-xml file=%s' % ( 
     40  #osm_data_file, osmosis, otm_data_file)) 
    3841execute('bzcat %s | %s --read-xml file=- --bounding-box left="12.10"' 
    39   ' right="18.87" top="51.06" bottom="48.55" --write-xml file=%s' % ( 
    40   osm_data_file, osmosis, otm_data_file))""" 
    41  
    42 timestamp = '090902' 
     42  ' right="18.87" top="51.32" bottom="48.27" --write-xml file=%s' % ( 
     43  osm_data_file, osmosis, otm_data_file)) 
    4344 
    4445# Import data to database. 
  • OpenTrackMap/bin/incremental_update_osm2pgsql.py

    r70 r71  
    77from re import match 
    88 
     9bin_prefix="/home/blackhex/OpenTrackMap/" 
    910prefix = "/mnt/data/OpenTrackMap/" 
    1011mirror = "http://planet.openstreetmap.org" 
    11 osmosis = prefix + "bin/osmosis-0.31/bin/osmosis" 
    12 osm2pgsql = prefix + "bin/osm2pgsql/osm2pgsql" 
     12osmosis = bin_prefix + "bin/osmosis-0.31/bin/osmosis" 
     13osm2pgsql = bin_prefix + "bin/osm2pgsql/osm2pgsql" 
    1314timestamp_filename = prefix + "opentrackmap.timestamp" 
    1415bbox = "12.10,48.55,18.87,51.06" 
  • OpenTrackMap/bin/relations2lines.py

    r70 r71  
    1616 
    1717# Clean previous tracks. 
    18 auxilary_cursor.execute("DELETE FROM planet_osm_track_rels") 
     18auxilary_cursor.execute("DROP TABLE IF EXISTS planet_osm_track_rels") 
     19auxilary_cursor.execute("CREATE TABLE planet_osm_track_rels AS SELECT * FROM planet_osm_line WHERE osm_id = 0") 
     20auxilary_cursor.execute("INSERT INTO geometry_columns VALUES ('', 'public', 'planet_osm_track_rels', 'way', 2, 900910, 'LINESTRING')") 
    1921 
    2022# Select all route relations. 
  • OpenTrackMap/mapnik/default.style

    r70 r71  
    116116 
    117117# International hiking tracks. 
     118way       network              text  linear 
    118119way       iwn                  text  linear 
    119120 
  • OpenTrackMap/mapnik/generate_tiles.py

    r70 r71  
    88import sys, os 
    99 
    10 os.environ['LD_LIBRARY_PATH'] = '/home/blackhex/local/Mapnik/lib' 
    1110path = ['/home/blackhex/local/Mapnik/lib/python2.6/site-packages'] 
    1211path.extend(sys.path) 
     
    6261    # Setup Mapnik 
    6362    gprj = GoogleProjection(maxZoom + 1)  
    64     m = Map(2 * 256, 2 * 256) 
    65     load_map(m, mapFile) 
     63    m = Map(256, 256) 
     64    load_map(m, mapFile, True) 
    6665    prj = Projection("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0" 
    6766      " +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over") 
     
    104103 
    105104                bbox = Envelope(c0.x,c0.y,c1.x,c1.y) 
    106                 bbox.width(bbox.width() * 2) 
    107                 bbox.height(bbox.height() * 2) 
    108105                m.zoom_to_box(bbox) 
     106                m.buffer_size = 64 
    109107 
    110108                str_y = "%s" % y 
    111  
    112109                tileHQFile = os.path.join(tileHQDir, zoom, str_x, str_y + '.png') 
    113110                tileSQFile = os.path.join(tileSQDir, zoom, str_x, str_y + '.png') 
     
    117114                    exists = "exists" 
    118115                else: 
    119                     im = Image(512, 512) 
    120                     render(m, im) 
    121                     view = im.view(128,128,256,256) # x,y,width,height 
     116                    image = Image(256, 256) 
     117                    render(m, image) 
    122118 
    123119                    fsLock.acquire() 
    124120                    # We should check file existance aggain for atomicity. 
    125121                    if not os.path.exists(tileHQFile): 
    126                         view.save(tileHQFile,'png') 
     122                        image.save(tileHQFile,'png') 
    127123                    fsLock.release() 
    128124 
     
    189185 
    190186    # Czech Republic 
    191     minZoom = 0 
     187    minZoom = 1 
    192188    maxZoom = 14 
    193189    bbox = (12.10, 48.55, 18.87, 51.06) 
    194190 
    195191    # Sluknov 
    196     #minZoom = 0 
     192    #minZoom = 1 
    197193    #maxZoom = 15 
    198194    #bbox = (14.16, 50.86, 14.40, 50.95) 
    199195 
    200196    # Brno 
    201     #minZoom = 0 
     197    #minZoom = 1 
    202198    #maxZoom = 15 
    203199    #bbox = (16.4646, 49.1254, 16.7214, 49.3106) 
    204200 
    205201    # Ricany - Kostelec nad Cernymi Lesy 
    206     #minZoom = 9 
     202    #minZoom = 1 
    207203    #maxZoom = 17 
    208204    #bbox = (14.62, 49.95, 14.91, 50.04) 
    209205 
    210206    # Beskydy - TravnÜ 
    211     #minZoom = 13 
     207    #minZoom = 1 
    212208    #maxZoom = 17 
    213209    #bbox = (18.42, 49.49, 18.66, 49.62) 
    214210 
    215211    # KrkonoÅ¡e 
    216     #minZoom = 9 
     212    #minZoom = 1 
    217213    #maxZoom = 17 
    218214    #bbox = (15.10, 50.76, 15.40, 50.88) 
    219215 
    220216    # TiÅ¡nov 
    221     #minZoom = 9 
     217    #minZoom = 1 
    222218    #maxZoom = 17 
    223219    #bbox = (16.41, 49.34, 16.43, 49.36) 
  • OpenTrackMap/mapnik/openlayers.html

    r57 r71  
    11<html> 
    22<head> 
    3     <title>OpenStreetMap</title> 
    4   
    5     <!-- bring in the OpenLayers javascript library 
    6          (here we bring it from the remote site, but you could 
    7          easily serve up this javascript yourself) --> 
    8     <script src="http://www.openlayers.org/api/OpenLayers.js"></script> 
    9   
    10     <!-- bring in the OpenStreetMap OpenLayers layers. 
    11          Using this hosted file will make sure we are kept up 
    12          to date with any necessary changes --> 
    13     <script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script> 
    14   
    15     <script type="text/javascript"> 
    16         // Start position for the map (hardcoded here for simplicity, 
    17         // but maybe you want to get from URL params) 
    18         // (Though to get it from the URL it's simpler to use the Permalink and ArgParser controls) 
    19         var lat=49.19 
    20         var lon=16.61 
    21         var zoom=13 
    22   
    23         var map; //complex object of type OpenLayers.Map 
    24   
    25         //Initialise the 'map' object 
    26         function init() { 
    27   
    28             map = new OpenLayers.Map ("map", { 
    29                 controls:[ 
    30                     new OpenLayers.Control.Navigation(), 
     3  <title>OpenStreetMap</title> 
     4 
     5  <!-- bring in the OpenLayers javascript library 
     6       (here we bring it from the remote site, but you could 
     7       easily serve up this javascript yourself) --> 
     8  <script src="http://www.openlayers.org/api/OpenLayers.js"></script> 
     9 
     10  <!-- bring in the OpenStreetMap OpenLayers layers. 
     11       Using this hosted file will make sure we are kept up 
     12       to date with any necessary changes --> 
     13  <script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script> 
     14 
     15  <script type="text/javascript"> 
     16    // Start position for the map (hardcoded here for simplicity, 
     17    // but maybe you want to get from URL params) 
     18    // (Though to get it from the URL it's simpler to use the Permalink and ArgParser controls) 
     19    var lat=49.7 
     20    var lon=15.2 
     21    var zoom=7 
     22 
     23    var map; //complex object of type OpenLayers.Map 
     24 
     25    function getTileURL(bounds) 
     26    { 
     27      var res = this.map.getResolution(); 
     28      var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); 
     29      var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)); 
     30      var z = this.map.getZoom(); 
     31      var limit = Math.pow(2, z); 
     32 
     33      if (y < 0 || y >= limit) 
     34      { 
     35        return "404.png"; 
     36      } 
     37      else 
     38      { 
     39        x = ((x % limit) + limit) % limit; 
     40        return this.url + z + "/" + x + "/" + y + "." + this.type; 
     41      } 
     42    } 
     43 
     44 
     45    //Initialise the 'map' object 
     46    function init() 
     47    { 
     48      map = new OpenLayers.Map ("map", 
     49      { 
     50        controls : [new OpenLayers.Control.Navigation(), 
    3151                    new OpenLayers.Control.PanZoomBar(), 
    3252                    new OpenLayers.Control.Attribution(), 
    3353                    new OpenLayers.Control.LayerSwitcher({'div': OpenLayers.Util.getElement('layerswitcher')})], 
    34                 maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), 
    35                 maxResolution: 156543.0399, 
    36                 numZoomLevels: 19, 
    37                 units: 'm', 
    38                 projection: new OpenLayers.Projection("EPSG:900913"), 
    39                 displayProjection: new OpenLayers.Projection("EPSG:4326") 
    40             } ); 
     54        maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), 
     55        maxResolution: 156543.0399, 
     56        numZoomLevels: 19, 
     57        units: 'm', 
     58        projection: new OpenLayers.Projection("EPSG:900913"), 
     59        displayProjection: new OpenLayers.Projection("EPSG:4326") 
     60      }); 
    4161 
    42             var openTrackMap = new OpenLayers.Layer.OSM("OpenTrackMap", "tiles_hq/", {numZoomLevels: 18}); 
    43             map.addLayer(openTrackMap); 
     62      var openTrackMap = new OpenLayers.Layer.OSM("OpenTrackMap", "tiles_hq/", {type: 'png', numZoomLevels: 18, getURL: getTileURL}); 
     63      map.addLayer(openTrackMap); 
    4464 
    45             // Define the map layer 
    46             // Note that we use a predefined layer that will be 
    47             // kept up to date with URL changes 
    48             // Here we define just one layer, but providing a choice 
    49             // of several layers is also quite simple 
    50             // Other defined layers are OpenLayers.Layer.OSM.Mapnik, OpenLayers.Layer.OSM.Maplint and OpenLayers.Layer.OSM.CycleMap 
    51             mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik"); 
    52             map.addLayer(mapnik); 
     65      // Define the map layer 
     66      // Note that we use a predefined layer that will be 
     67      // kept up to date with URL changes 
     68      // Here we define just one layer, but providing a choice 
     69      // of several layers is also quite simple 
     70      // Other defined layers are OpenLayers.Layer.OSM.Mapnik, OpenLayers.Layer.OSM.Maplint and OpenLayers.Layer.OSM.CycleMap 
     71      mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik"); 
     72      map.addLayer(mapnik); 
    5373  
    54             if( ! map.getCenter() ){ 
    55                 var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); 
    56                 map.setCenter (lonLat, zoom); 
    57             } 
    58         } 
    59   
    60     </script> 
     74      if( !map.getCenter()) 
     75      { 
     76        var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); 
     77        map.setCenter (lonLat, zoom); 
     78      } 
     79    } 
     80  </script> 
    6181</head> 
    6282  
  • OpenTrackMap/usgs_srtm/srtm2contours.sh

    r70 r71  
    66  rm -f "${TILE%%.zip}" "${TILE%%.hgt.zip}.shp" "${TILE%%.hgt.zip}.shx" "${TILE%%.hgt.zip}.dbf" 
    77 
    8   echo "/home/blackhex/local/gdal/bin/gdal_contour -i 10 -snodata -32767 -a height ${TILE%%.hgt.zip}.tif ${TILE%%.hgt.zip}.shp" 
    9   /home/blackhex/local/Mapnik/bin/gdal_contour -i 10 -snodata -32767 -a height "${TILE%%.hgt.zip}.tif" "${TILE%%.hgt.zip}.shp" 
     8  echo "/home/blackhex/local/gdal/bin/gdal_contour -i 10 -snodata 32767 -a height ${TILE%%.hgt.zip}.tif ${TILE%%.hgt.zip}.shp" 
     9  /home/blackhex/local/Mapnik/bin/gdal_contour -i 10 -snodata 32767 -a height "${TILE%%.hgt.zip}.tif" "${TILE%%.hgt.zip}.shp" 
    1010  if [ "$CREATE" == "1" ]; then 
    1111    echo "/usr/lib/postgresql/8.4/bin/shp2pgsql -d -I -g way ${TILE%%.hgt.zip} contours | psql -q osm" 
  • OpenTrackMap/usgs_srtm/srtm2shade.sh

    r70 r71  
    55export LD_LIBRARY_PATH="${PREFIX}/lib" 
    66 
    7 # for TILE in N*E*.hgt.zip; do 
    8 #   yes | ./srtm_generate_hdr.sh ${TILE} 
    9 #   rm -f "${TILE%%.hgt.zip}.bil" "${TILE%%.hgt.zip}.hdr" "${TILE%%.hgt.zip}.prj" "${TILE%%.hgt.zip}.hgt" 
    10 # done 
    11 #  
    12 # ${PREFIX}/bin/gdal_merge.py -v -o srtm.tif -ul_lr 12.10 51.06 18.87 48.55 N*E*.tif 
    13 # ${PREFIX}/bin/gdalwarp -of GTiff -co "TILED=YES" -co "BIGTIFF=YES" -srcnodata 32767 -dstnodata 0 -t_srs "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgris=@null +no_defs" \ 
    14 #   -rcs -order 3 -tr 30 30 -wt Float32 -ot Float32 -wo SAMPLE_STEPS=100 -multi srtm.tif warped.tif 
     7for TILE in N*E*.hgt.zip; do 
     8  yes | ./srtm_generate_hdr.sh ${TILE} 
     9  rm -f "${TILE%%.hgt.zip}.bil" "${TILE%%.hgt.zip}.hdr" "${TILE%%.hgt.zip}.prj" "${TILE%%.hgt.zip}.hgt" 
     10done 
     11 
     12${PREFIX}/bin/gdal_merge.py -v -o srtm.tif -ul_lr 12.10 51.32 18.86 48.27 N*E*.tif 
     13${PREFIX}/bin/gdalwarp -of GTiff -co "TILED=YES" -co "BIGTIFF=YES" -srcnodata 32767 -dstnodata 0 -t_srs "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgris=@null +no_defs" \ 
     14  -rcs -order 3 -tr 30 30 -wt Float32 -ot Float32 -wo SAMPLE_STEPS=100 -multi srtm.tif warped.tif 
    1515./hillshade warped.tif hillshade.tif -s 0.2