Changeset b2ad4a7 in osmose-frontend


Ignore:
Timestamp:
Feb 5, 2015 10:57:46 PM (5 years ago)
Author:
Jocelyn Jaubert <jocelyn.jaubert@…>
Children:
033659b
Parents:
9b55ebc
git-author:
Frédéric Rodrigo <fred.rodrigo@…> (02/02/2015 22:14:04)
git-committer:
Jocelyn Jaubert <jocelyn.jaubert@…> (05/02/2015 22:57:46)
Message:

Use topojson.pbf as cover file format

Files:
7 added
4 edited

Legend:

Unmodified
Added
Removed
  • .gitmodules

    r622eaeb rb2ad4a7  
    2626        path = externals/Leaflet-active-area 
    2727        url = https://github.com/Mappy/Leaflet-active-area.git 
     28[submodule "externals/topojson"] 
     29        path = externals/topojson 
     30        url = https://github.com/mbostock/topojson.git 
  • static/map/Osmose.Coverage.js

    rc43a815 rb2ad4a7  
    11OsmoseCoverage = L.GeoJSON.extend({ 
    22 
    3   initialize: function (geojson_url, options) { 
     3  initialize: function (topojson_url, options) { 
    44    L.Util.setOptions(this, options); 
    55 
    66    this._layers = {}; 
    7     this._geojson_url = geojson_url; 
    8     this._geojson = null; 
     7    this._topojson_url = topojson_url; 
     8    this._topojson = null; 
    99  }, 
    1010 
    1111  onAdd: function (map, insertAtTheBottom) { 
    1212    this._map = map; 
    13     if (this._geojson === null) { 
     13    if (this._topojson === null) { 
    1414      this.fetchData(); 
    1515    } 
     
    2121    var self = this; 
    2222    this._map.spin(true); 
    23     $.ajax({ 
    24       'url': this._geojson_url 
    25     }).done(function (data) { 
    26       self.addData(data); 
    27       self._geojson = data; 
    28     }).always(function () { 
     23 
     24    var xhr = new XMLHttpRequest(); 
     25    xhr.open('GET', this._topojson_url, true); 
     26    xhr.responseType = 'arraybuffer'; 
     27 
     28    xhr.onload = function(e) { 
     29      if (this.status == 200) { 
     30        data = geobuf.decode(new Pbf(new Uint8Array(xhr.response))); 
     31        data = topojson.feature(data, data.objects['osmose-cover']); 
     32        self.addData(data); 
     33        self._topojson = data; 
     34      } 
    2935      self._map.spin(false); 
    30     }); 
     36    }; 
     37 
     38    xhr.send(); 
    3139  }, 
    3240}); 
  • static/map/map.js

    rc42bb4a rb2ad4a7  
    1414  map.setView(new L.LatLng(lat, lon)); 
    1515 
    16   var coverage = new OsmoseCoverage('/osmose-coverage.json'); 
     16  var coverage = new OsmoseCoverage('/osmose-coverage.topojson.pbf'); 
    1717  mapOverlay['Coverage'] = coverage; 
    1818 
  • tools/assets.py

    r622eaeb rb2ad4a7  
    55 
    66environment = Environment('static', '') 
    7 # environment.debug = True 
     7environment.debug = True 
    88 
    99css_map_bundle = Bundle( 
     
    3535    'map/leaflet-active-area/L.activearea.js', 
    3636    'map/Location.js', 
     37    'map/geobuf/ieee754.js', 
     38    'map/geobuf/pbf-dev.js', 
     39    'map/geobuf/geobuf-dev.js', 
     40    'map/geobuf/topojson.js', 
    3741    'map/Osmose.Menu.js', 
    3842    'map/Osmose.Editor.js', 
Note: See TracChangeset for help on using the changeset viewer.