mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
modularize iD.renderer
This commit is contained in:
11
Makefile
11
Makefile
@@ -49,6 +49,7 @@ MODULE_TARGETS = \
|
||||
js/lib/id/modes.js \
|
||||
js/lib/id/operations.js \
|
||||
js/lib/id/presets.js \
|
||||
js/lib/id/renderer.js \
|
||||
js/lib/id/services.js \
|
||||
js/lib/id/svg.js \
|
||||
js/lib/id/util.js \
|
||||
@@ -78,6 +79,10 @@ js/lib/id/presets.js: $(shell find modules/presets -type f)
|
||||
@rm -f $@
|
||||
node_modules/.bin/rollup -f umd -n iD.presets modules/presets/index.js --no-strict -o $@
|
||||
|
||||
js/lib/id/renderer.js: $(shell find modules/renderer -type f)
|
||||
@rm -f $@
|
||||
node_modules/.bin/rollup -f umd -n iD modules/renderer/index.js --no-strict -o $@
|
||||
|
||||
js/lib/id/services.js: $(shell find modules/services -type f)
|
||||
@rm -f $@
|
||||
node_modules/.bin/rollup -f umd -n iD.services modules/services/index.js --no-strict -o $@
|
||||
@@ -94,7 +99,6 @@ js/lib/id/validations.js: $(shell find modules/validations -type f)
|
||||
@rm -f $@
|
||||
node_modules/.bin/rollup -f umd -n iD.validations modules/validations/index.js --no-strict -o $@
|
||||
|
||||
|
||||
dist/iD.js: \
|
||||
js/lib/bootstrap-tooltip.js \
|
||||
js/lib/d3.v3.js \
|
||||
@@ -132,11 +136,6 @@ dist/iD.js: \
|
||||
js/id/behavior/paste.js \
|
||||
js/id/behavior/select.js \
|
||||
js/id/behavior/tail.js \
|
||||
js/id/renderer/background.js \
|
||||
js/id/renderer/background_source.js \
|
||||
js/id/renderer/features.js \
|
||||
js/id/renderer/map.js \
|
||||
js/id/renderer/tile_layer.js \
|
||||
js/id/ui.js \
|
||||
js/id/ui/account.js \
|
||||
js/id/ui/attribution.js \
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
<script src='js/lib/id/modes.js'></script>
|
||||
<script src='js/lib/id/operations.js'></script>
|
||||
<script src='js/lib/id/presets.js'></script>
|
||||
<script src='js/lib/id/renderer.js'></script>
|
||||
<script src='js/lib/id/services.js'></script>
|
||||
<script src='js/lib/id/svg.js'></script>
|
||||
<script src='js/lib/id/util.js'></script>
|
||||
@@ -47,12 +48,6 @@
|
||||
|
||||
<script src='data/data_dev.js'></script>
|
||||
|
||||
<script src='js/id/renderer/background.js'></script>
|
||||
<script src='js/id/renderer/background_source.js'></script>
|
||||
<script src='js/id/renderer/features.js'></script>
|
||||
<script src='js/id/renderer/map.js'></script>
|
||||
<script src='js/id/renderer/tile_layer.js'></script>
|
||||
|
||||
<script src='js/id/ui.js'></script>
|
||||
<script src='js/id/ui/intro.js'></script>
|
||||
<script src='js/id/ui/info.js'></script>
|
||||
|
||||
1587
js/lib/id/renderer.js
Normal file
1587
js/lib/id/renderer.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,9 @@
|
||||
iD.Background = function(context) {
|
||||
import { BackgroundSource } from './background_source';
|
||||
import { TileLayer } from './tile_layer';
|
||||
|
||||
export function Background(context) {
|
||||
var dispatch = d3.dispatch('change'),
|
||||
baseLayer = iD.TileLayer(context).projection(context.projection),
|
||||
baseLayer = TileLayer(context).projection(context.projection),
|
||||
overlayLayers = [],
|
||||
backgroundSources;
|
||||
|
||||
@@ -148,7 +151,7 @@ iD.Background = function(context) {
|
||||
}
|
||||
}
|
||||
|
||||
layer = iD.TileLayer(context)
|
||||
layer = TileLayer(context)
|
||||
.source(d)
|
||||
.projection(context.projection)
|
||||
.dimensions(baseLayer.dimensions());
|
||||
@@ -188,20 +191,20 @@ iD.Background = function(context) {
|
||||
|
||||
backgroundSources = imagery.map(function(source) {
|
||||
if (source.type === 'bing') {
|
||||
return iD.BackgroundSource.Bing(source, dispatch);
|
||||
return BackgroundSource.Bing(source, dispatch);
|
||||
} else {
|
||||
return iD.BackgroundSource(source);
|
||||
return BackgroundSource(source);
|
||||
}
|
||||
});
|
||||
|
||||
backgroundSources.unshift(iD.BackgroundSource.None());
|
||||
backgroundSources.unshift(BackgroundSource.None());
|
||||
|
||||
if (!chosen && extent) {
|
||||
best = _.find(this.sources(extent), function(s) { return s.best(); });
|
||||
}
|
||||
|
||||
if (chosen && chosen.indexOf('custom:') === 0) {
|
||||
background.baseLayerSource(iD.BackgroundSource.Custom(chosen.replace(/^custom:/, '')));
|
||||
background.baseLayerSource(BackgroundSource.Custom(chosen.replace(/^custom:/, '')));
|
||||
} else {
|
||||
background.baseLayerSource(findSource(chosen) || best || findSource('Bing') || backgroundSources[1] || backgroundSources[0]);
|
||||
}
|
||||
@@ -241,4 +244,4 @@ iD.Background = function(context) {
|
||||
};
|
||||
|
||||
return d3.rebind(background, dispatch, 'on');
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.BackgroundSource = function(data) {
|
||||
export function BackgroundSource(data) {
|
||||
var source = _.clone(data),
|
||||
offset = [0, 0],
|
||||
name = source.name,
|
||||
@@ -80,15 +80,15 @@ iD.BackgroundSource = function(data) {
|
||||
source.copyrightNotices = function() {};
|
||||
|
||||
return source;
|
||||
};
|
||||
}
|
||||
|
||||
iD.BackgroundSource.Bing = function(data, dispatch) {
|
||||
BackgroundSource.Bing = function(data, dispatch) {
|
||||
// http://msdn.microsoft.com/en-us/library/ff701716.aspx
|
||||
// http://msdn.microsoft.com/en-us/library/ff701701.aspx
|
||||
|
||||
data.template = 'https://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=587&mkt=en-gb&n=z';
|
||||
|
||||
var bing = iD.BackgroundSource(data),
|
||||
var bing = BackgroundSource(data),
|
||||
key = 'Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU', // Same as P2 and JOSM
|
||||
url = 'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?include=ImageryProviders&key=' +
|
||||
key + '&jsonp={callback}',
|
||||
@@ -128,8 +128,8 @@ iD.BackgroundSource.Bing = function(data, dispatch) {
|
||||
return bing;
|
||||
};
|
||||
|
||||
iD.BackgroundSource.None = function() {
|
||||
var source = iD.BackgroundSource({id: 'none', template: ''});
|
||||
BackgroundSource.None = function() {
|
||||
var source = BackgroundSource({id: 'none', template: ''});
|
||||
|
||||
source.name = function() {
|
||||
return t('background.none');
|
||||
@@ -146,8 +146,8 @@ iD.BackgroundSource.None = function() {
|
||||
return source;
|
||||
};
|
||||
|
||||
iD.BackgroundSource.Custom = function(template) {
|
||||
var source = iD.BackgroundSource({id: 'custom', template: template});
|
||||
BackgroundSource.Custom = function(template) {
|
||||
var source = BackgroundSource({id: 'custom', template: template});
|
||||
|
||||
source.name = function() {
|
||||
return t('background.custom');
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.Features = function(context) {
|
||||
export function Features(context) {
|
||||
var traffic_roads = {
|
||||
'motorway': true,
|
||||
'motorway_link': true,
|
||||
@@ -417,4 +417,4 @@ iD.Features = function(context) {
|
||||
};
|
||||
|
||||
return d3.rebind(features, dispatch, 'on');
|
||||
};
|
||||
}
|
||||
5
modules/renderer/index.js
Normal file
5
modules/renderer/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export { BackgroundSource } from './background_source';
|
||||
export { Background } from './background';
|
||||
export { Features } from './features';
|
||||
export { Map } from './map';
|
||||
export { TileLayer } from './tile_layer';
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.Map = function(context) {
|
||||
export function Map(context) {
|
||||
var dimensions = [1, 1],
|
||||
dispatch = d3.dispatch('move', 'drawn'),
|
||||
projection = context.projection,
|
||||
@@ -528,4 +528,4 @@ iD.Map = function(context) {
|
||||
map.layers = drawLayers;
|
||||
|
||||
return d3.rebind(map, dispatch, 'on');
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
iD.TileLayer = function(context) {
|
||||
export function TileLayer(context) {
|
||||
var tileSize = 256,
|
||||
tile = d3.geo.tile(),
|
||||
projection,
|
||||
@@ -204,4 +204,4 @@ iD.TileLayer = function(context) {
|
||||
};
|
||||
|
||||
return background;
|
||||
};
|
||||
}
|
||||
@@ -47,17 +47,12 @@
|
||||
<script src='../js/lib/id/modes.js'></script>
|
||||
<script src='../js/lib/id/operations.js'></script>
|
||||
<script src='../js/lib/id/presets.js'></script>
|
||||
<script src='../js/lib/id/renderer.js'></script>
|
||||
<script src='../js/lib/id/services.js'></script>
|
||||
<script src='../js/lib/id/svg.js'></script>
|
||||
<script src='../js/lib/id/util.js'></script>
|
||||
<script src='../js/lib/id/validations.js'></script>
|
||||
|
||||
<script src='../js/id/renderer/background.js'></script>
|
||||
<script src='../js/id/renderer/background_source.js'></script>
|
||||
<script src='../js/id/renderer/features.js'></script>
|
||||
<script src='../js/id/renderer/map.js'></script>
|
||||
<script src='../js/id/renderer/tile_layer.js'></script>
|
||||
|
||||
<script src='../js/id/ui.js'></script>
|
||||
<script src='../js/id/ui/attribution.js'></script>
|
||||
<script src='../js/id/ui/radial_menu.js'></script>
|
||||
|
||||
Reference in New Issue
Block a user