diff --git a/Makefile b/Makefile index b25f23e43..f286a939b 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,33 @@ all: \ iD.js \ iD.min.js +# TODO: write a nice node script for this +data/data.js: \ + data/deprecated.json \ + data/discarded.json \ + data/imagery.json \ + data/keys.json + echo 'iD.data = {' > $@ + echo 'deprecated: ' >> $@ + cat data/deprecated.json >> $@ + echo ', discarded: ' >> $@ + cat data/discarded.json >> $@ + echo ', imagery: ' >> $@ + cat data/imagery.json >> $@ + echo ', keys: ' >> $@ + cat data/keys.json >> $@ + echo ', presets: {' >> $@ + echo 'presets: ' >> $@ + cat data/presets/presets.json >> $@ + echo ', defaults: ' >> $@ + cat data/presets/defaults.json >> $@ + echo ', categories: ' >> $@ + cat data/presets/categories.json >> $@ + echo ', forms: ' >> $@ + cat data/presets/forms.json >> $@ + echo '}' >> $@ + echo '};' >> $@ + .INTERMEDIATE iD.js: \ js/lib/bootstrap-tooltip.js \ js/lib/d3.v3.js \ @@ -34,8 +61,6 @@ all: \ js/id/oauth.js \ js/id/services/*.js \ data/data.js \ - data/imagery.js \ - data/deprecated.js \ js/id/util.js \ js/id/geo.js \ js/id/geo/*.js \ diff --git a/NOTES.md b/NOTES.md index abd5738c2..cd52520eb 100644 --- a/NOTES.md +++ b/NOTES.md @@ -306,3 +306,15 @@ The graph supports `transient`, which is storage for non-versioned mutable properties _about_ entities that are stored outside of entities. For instance, `extent` is about an entity, but can be invalidated and stored without getting a new graph. + +## Data sources + +*deprecated.json* +from http://wiki.openstreetmap.org/wiki/Deprecated_features +TODO: deal with deprecated 'class' tag +does not deal with landuse=wood because of indecision +we will not care about http://taginfo.openstreetmap.org/tags/bicycle_parking=sheffield + +*discarded.json* +entirely discarded tags +https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/XMLConnection.as#L24 diff --git a/data/data.js b/data/data.js deleted file mode 100644 index 279b1ea86..000000000 --- a/data/data.js +++ /dev/null @@ -1 +0,0 @@ -iD.data = {}; diff --git a/data/data_dev.js b/data/data_dev.js new file mode 100644 index 000000000..e5f1fb069 --- /dev/null +++ b/data/data_dev.js @@ -0,0 +1,33 @@ +iD.data = { + load: function(path, callback) { + if (!callback) { + callback = path; + path = ''; + } + iD.util.asyncMap([ + path + 'data/deprecated.json', + path + 'data/discarded.json', + path + 'data/imagery.json', + path + 'data/keys.json', + path + 'data/presets/presets.json', + path + 'data/presets/defaults.json', + path + 'data/presets/categories.json', + path + 'data/presets/forms.json'], d3.json, function (err, data) { + + iD.data = { + deprecated: data[0], + discarded: data[1], + imagery: data[2], + keys: data[3], + presets: { + presets: data[4], + defaults: data[5], + categories: data[6], + forms: data[7] + } + }; + + callback(); + }); + } +}; diff --git a/data/deprecated.js b/data/deprecated.js deleted file mode 100644 index 53457c9f3..000000000 --- a/data/deprecated.js +++ /dev/null @@ -1,112 +0,0 @@ -// from http://wiki.openstreetmap.org/wiki/Deprecated_features -// TODO: deal with deprecated 'class' tag -// does not deal with landuse=wood because of indecision -// we will not care about http://taginfo.openstreetmap.org/tags/bicycle_parking=sheffield -iD.data.deprecated = [ - { - old: { barrier: 'wire_fence' }, - replace: { - barrier: 'fence', - fence_type: 'chain' - } - }, - { - old: { barrier: 'wood_fence' }, - replace: { - barrier: 'fence', - fence_type: 'wood' - } - }, - { - old: { highway: 'ford' }, - replace: { - ford: 'yes' - } - }, - { - old: { highway: 'ford' }, - replace: { - ford: 'yes' - } - }, - { - old: { highway: 'ford' }, - replace: { - ford: 'yes' - } - }, - { - old: { highway: 'stile' }, - replace: { - barrier: 'stile' - } - }, - { - old: { highway: 'incline' }, - replace: { - highway: 'road', - incline: 'up' - } - }, - { - old: { highway: 'incline_steep' }, - replace: { - highway: 'road', - incline: 'up' - } - }, - { - old: { highway: 'unsurfaced' }, - replace: { - highway: 'road', - incline: 'unpaved' - } - }, - { - old: { highway: 'unsurfaced' }, - replace: { - highway: 'road', - incline: 'unpaved' - } - }, - { - old: { landuse: 'wood' }, - replace: { - highway: 'road', - incline: 'unpaved' - } - }, - { - old: { natural: 'marsh' }, - replace: { - natural: 'wetland', - wetland: 'marsh' - } - }, - { - old: { shop: 'organic' }, - replace: { - shop: 'supermarket', - organic: 'only' - } - }, - { - old: { power_source: '*' }, - replace: { - 'generator:source': '$1' - } - }, - { - old: { power_rating: '*' }, - replace: { - 'generator:output': '$1' - } - }, - { - old: { bicycle_parking: 'organic' }, - replace: { - shop: 'supermarket', - organic: 'only' - } - } -]; diff --git a/data/deprecated.json b/data/deprecated.json new file mode 100644 index 000000000..fcead3030 --- /dev/null +++ b/data/deprecated.json @@ -0,0 +1,108 @@ +[ + { + "old": { "barrier": "wire_fence" }, + "replace": { + "barrier": "fence", + "fence_type": "chain" + } + }, + { + "old": { "barrier": "wood_fence" }, + "replace": { + "barrier": "fence", + "fence_type": "wood" + } + }, + { + "old": { "highway": "ford" }, + "replace": { + "ford": "yes" + } + }, + { + "old": { "highway": "ford" }, + "replace": { + "ford": "yes" + } + }, + { + "old": { "highway": "ford" }, + "replace": { + "ford": "yes" + } + }, + { + "old": { "highway": "stile" }, + "replace": { + "barrier": "stile" + } + }, + { + "old": { "highway": "incline" }, + "replace": { + "highway": "road", + "incline": "up" + } + }, + { + "old": { "highway": "incline_steep" }, + "replace": { + "highway": "road", + "incline": "up" + } + }, + { + "old": { "highway": "unsurfaced" }, + "replace": { + "highway": "road", + "incline": "unpaved" + } + }, + { + "old": { "highway": "unsurfaced" }, + "replace": { + "highway": "road", + "incline": "unpaved" + } + }, + { + "old": { "landuse": "wood" }, + "replace": { + "highway": "road", + "incline": "unpaved" + } + }, + { + "old": { "natural": "marsh" }, + "replace": { + "natural": "wetland", + "wetland": "marsh" + } + }, + { + "old": { "shop": "organic" }, + "replace": { + "shop": "supermarket", + "organic": "only" + } + }, + { + "old": { "power_source": "*" }, + "replace": { + "generator:source": "$1" + } + }, + { + "old": { "power_rating": "*" }, + "replace": { + "generator:output": "$1" + } + }, + { + "old": { "bicycle_parking": "organic" }, + "replace": { + "shop": "supermarket", + "organic": "only" + } + } +] diff --git a/data/discarded.js b/data/discarded.js deleted file mode 100644 index 3a38a1534..000000000 --- a/data/discarded.js +++ /dev/null @@ -1,20 +0,0 @@ -// entirely discarded tags -// https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/XMLConnection.as#L24 -iD.data.discarded = [ - "created_by", - 'tiger:upload_uuid', - 'tiger:tlid', - 'tiger:source', - 'tiger:separated', - 'geobase:datasetName', - 'geobase:uuid', - 'sub_sea:type', - "odbl", - "odbl:note", - "yh:LINE_NAME", - "yh:LINE_NUM", - "yh:STRUCTURE", - "yh:TOTYUMONO", - "yh:TYPE", - "yh:WIDTH_RANK" -]; diff --git a/data/discarded.json b/data/discarded.json new file mode 100644 index 000000000..5bf8c817d --- /dev/null +++ b/data/discarded.json @@ -0,0 +1,18 @@ +[ + "created_by", + "tiger:upload_uuid", + "tiger:tlid", + "tiger:source", + "tiger:separated", + "geobase:datasetName", + "geobase:uuid", + "sub_sea:type", + "odbl", + "odbl:note", + "yh:LINE_NAME", + "yh:LINE_NUM", + "yh:STRUCTURE", + "yh:TOTYUMONO", + "yh:TYPE", + "yh:WIDTH_RANK" +] diff --git a/data/imagery.js b/data/imagery.js deleted file mode 100644 index 5cda27b95..000000000 --- a/data/imagery.js +++ /dev/null @@ -1,609 +0,0 @@ -iD.data.imagery = [ - { - "name": "Bing aerial imagery", - "template": "http://ecn.t{t}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=587&mkt=en-gb&n=z", - "description": "Satellite imagery.", - "scaleExtent": [ - 0, - 20 - ], - "subdomains": [ - "0", - "1", - "2", - "3" - ], - "default": "yes", - "sourcetag": "Bing", - "logo": "bing_maps.png", - "logo_url": "http://www.bing.com/maps", - "terms_url": "http://opengeodata.org/microsoft-imagery-details" - }, - { - "name": "MapBox Satellite", - "template": "http://{t}.tiles.mapbox.com/v3/openstreetmap.map-4wvf9l0l/{z}/{x}/{y}.png", - "description": "Satellite and aerial imagery", - "scaleExtent": [ - 0, - 16 - ], - "subdomains": [ - "a", - "b", - "c" - ], - "terms_url": "http://mapbox.com/tos/" - }, - { - "name": "OpenStreetMap", - "template": "http://{t}.tile.openstreetmap.org/{z}/{x}/{y}.png", - "description": "The default OpenStreetMap layer.", - "scaleExtent": [ - 0, - 18 - ], - "subdomains": [ - "a", - "b", - "c" - ] - }, - { - "name": " TIGER 2012 Roads Overlay", - "template": "http://{t}.tile.openstreetmap.us/tiger2012_roads_expanded/{z}/{x}/{y}.png", - "subdomains": [ - "a", - "b", - "c" - ], - "extent": [ - [ - -124.81, - 24.055 - ], - [ - -66.865, - 49.386 - ] - ] - }, - { - "name": " TIGER 2012 Roads Overlay", - "template": "http://{t}.tile.openstreetmap.us/tiger2012_roads_expanded/{z}/{x}/{y}.png", - "subdomains": [ - "a", - "b", - "c" - ], - "extent": [ - [ - -179.754, - 50.858 - ], - [ - -129.899, - 71.463 - ] - ] - }, - { - "name": " TIGER 2012 Roads Overlay", - "template": "http://{t}.tile.openstreetmap.us/tiger2012_roads_expanded/{z}/{x}/{y}.png", - "subdomains": [ - "a", - "b", - "c" - ], - "extent": [ - [ - -174.46, - 18.702 - ], - [ - -154.516, - 26.501 - ] - ] - }, - { - "name": " USGS Topographic Maps", - "template": "http://{t}.tile.openstreetmap.us/usgs_scanned_topos/{z}/{x}/{y}.png", - "subdomains": [ - "a", - "b", - "c" - ], - "extent": [ - [ - -125.991, - 24.005 - ], - [ - -65.988, - 50.009 - ] - ] - }, - { - "name": " USGS Topographic Maps", - "template": "http://{t}.tile.openstreetmap.us/usgs_scanned_topos/{z}/{x}/{y}.png", - "subdomains": [ - "a", - "b", - "c" - ], - "extent": [ - [ - -160.579, - 18.902 - ], - [ - -154.793, - 22.508 - ] - ] - }, - { - "name": " USGS Topographic Maps", - "template": "http://{t}.tile.openstreetmap.us/usgs_scanned_topos/{z}/{x}/{y}.png", - "subdomains": [ - "a", - "b", - "c" - ], - "extent": [ - [ - -178.001, - 51.255 - ], - [ - -130.004, - 71.999 - ] - ] - }, - { - "name": " USGS Large Scale Aerial Imagery", - "template": "http://{t}.tile.openstreetmap.us/usgs_large_scale/{z}/{x}/{y}.jpg", - "subdomains": [ - "a", - "b", - "c" - ], - "extent": [ - [ - -124.819, - 24.496 - ], - [ - -66.931, - 49.443 - ] - ] - }, - { - "name": "British Columbia bc_mosaic", - "template": "http://{t}.imagery.paulnorman.ca/tiles/bc_mosaic/{z}/{x}/{y}.png", - "subdomains": [ - "a", - "b", - "c", - "d" - ], - "extent": [ - [ - -123.441, - 48.995 - ], - [ - -121.346, - 50.426 - ] - ], - "sourcetag": "bc_mosaic", - "terms_url": "http://imagery.paulnorman.ca/tiles/about.html" - }, - { - "name": "OS OpenData Streetview", - "template": "http://os.openstreetmap.org/sv/{z}/{x}/{y}.png", - "extent": [ - [ - -8.72, - 49.86 - ], - [ - 1.84, - 60.92 - ] - ], - "sourcetag": "OS_OpenData_StreetView" - }, - { - "name": "OS OpenData Locator", - "template": "http://tiles.itoworld.com/os_locator/{z}/{x}/{y}.png", - "extent": [ - [ - -9, - 49.8 - ], - [ - 1.9, - 61.1 - ] - ], - "sourcetag": "OS_OpenData_Locator" - }, - { - "name": "OS 1:25k historic (OSM)", - "template": "http://ooc.openstreetmap.org/os1/{z}/{x}/{y}.jpg", - "extent": [ - [ - -9, - 49.8 - ], - [ - 1.9, - 61.1 - ] - ], - "sourcetag": "OS 1:25k" - }, - { - "name": "OS 1:25k historic (NLS)", - "template": "http://geo.nls.uk/mapdata2/os/25000/{z}/{x}/{y}.png", - "extent": [ - [ - -9, - 49.8 - ], - [ - 1.9, - 61.1 - ] - ], - "sourcetag": "OS 1:25k", - "logo": "icons/logo_nls70-nq8.png", - "logo_url": "http://geo.nls.uk/maps/" - }, - { - "name": "OS 7th Series historic (OSM)", - "template": "http://ooc.openstreetmap.org/os7/{z}/{x}/{y}.jpg", - "extent": [ - [ - -9, - 49.8 - ], - [ - 1.9, - 61.1 - ] - ], - "sourcetag": "OS7" - }, - { - "name": "OS 7th Series historic (NLS)", - "template": "http://geo.nls.uk/mapdata2/os/seventh/{z}/{x}/{y}.png", - "extent": [ - [ - -9, - 49.8 - ], - [ - 1.9, - 61.1 - ] - ], - "sourcetag": "OS7", - "logo": "icons/logo_nls70-nq8.png", - "logo_url": "http://geo.nls.uk/maps/" - }, - { - "name": "OS New Popular Edition historic", - "template": "http://ooc.openstreetmap.org/npe/{z}/{x}/{y}.png", - "extent": [ - [ - -5.8, - 49.8 - ], - [ - 1.9, - 55.8 - ] - ], - "sourcetag": "NPE" - }, - { - "name": "OS Scottish Popular historic", - "template": "http://ooc.openstreetmap.org/npescotland/tiles/{z}/{x}/{y}.jpg", - "extent": [ - [ - -7.8, - 54.5 - ], - [ - -1.1, - 61.1 - ] - ], - "sourcetag": "NPE" - }, - { - "name": "Surrey aerial", - "template": "http://gravitystorm.dev.openstreetmap.org/surrey/{z}/{x}/{y}.png", - "extent": [ - [ - -0.856, - 51.071 - ], - [ - 0.062, - 51.473 - ] - ], - "sourcetag": "Surrey aerial" - }, - { - "name": "Haiti - GeoEye Jan 13", - "template": "http://gravitystorm.dev.openstreetmap.org/imagery/haiti/{z}/{x}/{y}.jpg", - "extent": [ - [ - -74.5, - 17.95 - ], - [ - -71.58, - 20.12 - ] - ], - "sourcetag": "Haiti GeoEye" - }, - { - "name": "Haiti - GeoEye Jan 13+", - "template": "http://maps.nypl.org/tilecache/1/geoeye/{z}/{x}/{y}.jpg", - "extent": [ - [ - -74.5, - 17.95 - ], - [ - -71.58, - 20.12 - ] - ], - "sourcetag": "Haiti GeoEye" - }, - { - "name": "Haiti - DigitalGlobe", - "template": "http://maps.nypl.org/tilecache/1/dg_crisis/{z}/{x}/{y}.jpg", - "extent": [ - [ - -74.5, - 17.95 - ], - [ - -71.58, - 20.12 - ] - ], - "sourcetag": "Haiti DigitalGlobe" - }, - { - "name": "Haiti - Street names", - "template": "http://hypercube.telascience.org/tiles/1.0.0/haiti-city/{z}/{x}/{y}.jpg", - "extent": [ - [ - -74.5, - 17.95 - ], - [ - -71.58, - 20.12 - ] - ], - "sourcetag": "Haiti streetnames" - }, - { - "name": "NAIP", - "template": "http://cube.telascience.org/tilecache/tilecache.py/NAIP_ALL/{z}/{x}/{y}.png", - "description": "National Agriculture Imagery Program", - "extent": [ - [ - -125.8, - 24.2 - ], - [ - -62.3, - 49.5 - ] - ], - "sourcetag": "NAIP" - }, - { - "name": "NAIP", - "template": "http://cube.telascience.org/tilecache/tilecache.py/NAIP_ALL/{z}/{x}/{y}.png", - "description": "National Agriculture Imagery Program", - "extent": [ - [ - -168.5, - 55.3 - ], - [ - -140, - 71.5 - ] - ], - "sourcetag": "NAIP" - }, - { - "name": "Ireland - NLS Historic Maps", - "template": "http://geo.nls.uk/maps/ireland/gsgs4136/{z}/{x}/{y}.png", - "extent": [ - [ - -10.71, - 51.32 - ], - [ - -5.37, - 55.46 - ] - ], - "sourcetag": "NLS Historic Maps", - "logo": "icons/logo_nls70-nq8.png", - "logo_url": "http://geo.nls.uk/maps/" - }, - { - "name": "Denmark - Fugro Aerial Imagery", - "template": "http://tile.openstreetmap.dk/fugro2005/{z}/{x}/{y}.jpg", - "extent": [ - [ - 7.81, - 54.44 - ], - [ - 15.49, - 57.86 - ] - ], - "sourcetag": "Fugro (2005)" - }, - { - "name": "Denmark - Stevns Kommune", - "template": "http://tile.openstreetmap.dk/stevns/2009/{z}/{x}/{y}.jpg", - "extent": [ - [ - 12.09144, - 55.23403 - ], - [ - 12.47712, - 55.43647 - ] - ], - "sourcetag": "Stevns Kommune (2009)" - }, - { - "name": "Austria - geoimage.at", - "template": "http://geoimage.openstreetmap.at/4d80de696cd562a63ce463a58a61488d/{z}/{x}/{y}.jpg", - "extent": [ - [ - 9.36, - 46.33 - ], - [ - 17.28, - 49.09 - ] - ], - "sourcetag": "geoimage.at" - }, - { - "name": "Russia - Kosmosnimki.ru IRS Satellite", - "template": "http://irs.gis-lab.info/?layers=irs&request=GetTile&z={z}&x={x}&y={y}", - "extent": [ - [ - 19.02, - 40.96 - ], - [ - 77.34, - 70.48 - ] - ], - "sourcetag": "Kosmosnimki.ru IRS" - }, - { - "name": "Belarus - Kosmosnimki.ru SPOT4 Satellite", - "template": "http://irs.gis-lab.info/?layers=spot&request=GetTile&z={z}&x={x}&y={y}", - "extent": [ - [ - 23.16, - 51.25 - ], - [ - 32.83, - 56.19 - ] - ], - "sourcetag": "Kosmosnimki.ru SPOT4" - }, - { - "name": "Australia - Geographic Reference Image", - "template": "http://agri.openstreetmap.org/{z}/{x}/{y}.png", - "extent": [ - [ - 96, - -44 - ], - [ - 168, - -9 - ] - ], - "sourcetag": "AGRI" - }, - { - "name": "Switzerland - Canton Aargau - AGIS 25cm 2011", - "template": "http://tiles.poole.ch/AGIS/OF2011/{z}/{x}/{y}.png", - "extent": [ - [ - 7.69, - 47.13 - ], - [ - 8.48, - 47.63 - ] - ], - "sourcetag": "AGIS OF2011" - }, - { - "name": "Switzerland - Canton Solothurn - SOGIS 2007", - "template": "http://mapproxy.sosm.ch:8080/tiles/sogis2007/EPSG900913/{z}/{x}/{y}.png?origin=nw", - "extent": [ - [ - 7.33, - 47.06 - ], - [ - 8.04, - 47.5 - ] - ], - "sourcetag": "Orthofoto 2007 WMS Solothurn" - }, - { - "name": "Poland - Media-Lab fleet GPS masstracks", - "template": "http://masstracks.media-lab.com.pl/{z}/{x}/{y}.png", - "extent": [ - [ - 14, - 48.9 - ], - [ - 24.2, - 55 - ] - ], - "sourcetag": "masstracks" - }, - { - "name": "South Africa - CD:NGI Aerial", - "template": "http://{t}.aerial.openstreetmap.org.za/ngi-aerial/{z}/{x}/{y}.jpg", - "subdomains": [ - "a", - "b", - "c" - ], - "extent": [ - [ - 17.64, - -34.95 - ], - [ - 32.87, - -22.05 - ] - ], - "sourcetag": "ngi-aerial" - } -]; \ No newline at end of file diff --git a/data/imagery_convert.js b/data/imagery_convert.js index abc5cbef6..6b297322a 100644 --- a/data/imagery_convert.js +++ b/data/imagery_convert.js @@ -84,4 +84,3 @@ $('set').each(function(i) { }); fs.writeFileSync('imagery.json', JSON.stringify(imagery, null, 4)); -fs.writeFileSync('imagery.js', 'iD.data.imagery = ' + JSON.stringify(imagery, null, 4) + ';'); diff --git a/keys.json b/data/keys.json similarity index 100% rename from keys.json rename to data/keys.json diff --git a/index.html b/index.html index 6f41d3f0e..1b35bb7da 100644 --- a/index.html +++ b/index.html @@ -37,10 +37,7 @@ - - - - + @@ -186,29 +183,10 @@ -
-
+ d3.select('#iD') + .call(id.ui()); + + diff --git a/js/id/id.js b/js/id/id.js index 355f105db..dd095dbaa 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -1,4 +1,8 @@ window.iD = function () { + locale + .current('en') + .current(iD.detect().locale); + var context = {}, storage; @@ -21,7 +25,8 @@ window.iD = function () { map = iD.Map(context); // the connection requires .storage() to be available on calling. - var connection = iD.Connection(context); + var connection = iD.Connection(context) + .keys(iD.data.keys); connection.on('load.context', function loadContext(err, result) { history.merge(result); @@ -104,7 +109,8 @@ window.iD = function () { }; /* Presets */ - var presets = iD.presets(context); + var presets = iD.presets(context) + .load(iD.data.presets); context.presets = function() { return presets; diff --git a/js/id/presets.js b/js/id/presets.js index ab7fa52de..d222c732e 100644 --- a/js/id/presets.js +++ b/js/id/presets.js @@ -44,6 +44,8 @@ iD.presets = function(context) { vertex: iD.presets.Collection(d.defaults.vertex.map(getItem)) }; } + + return all; }; all.defaults = function(entity, n) { diff --git a/js/id/presets/category.js b/js/id/presets/category.js index 079838c3c..21f16d939 100644 --- a/js/id/presets/category.js +++ b/js/id/presets/category.js @@ -1,4 +1,5 @@ iD.presets.Category = function(category, all) { + category = _.clone(category); category.members = iD.presets.Collection(category.members.map(function(name) { return all.item(name); diff --git a/test/index.html b/test/index.html index f500d0b08..dc71a2bcc 100644 --- a/test/index.html +++ b/test/index.html @@ -40,10 +40,7 @@ - - - - + @@ -51,7 +48,6 @@ - @@ -260,7 +256,9 @@