external modules for renderer

This commit is contained in:
Kushan Joshi
2016-06-18 17:21:18 +05:30
parent 68e0400332
commit 6a56ad547c
10 changed files with 1648 additions and 44 deletions
-9
View File
@@ -44,7 +44,6 @@ $(BUILDJS_TARGETS): $(BUILDJS_SOURCES) build.js
MODULE_TARGETS = \
js/lib/id/index.js \
js/lib/id/renderer.js \
js/lib/id/services.js \
js/lib/id/ui/index.js \
js/lib/id/ui/core.js \
@@ -55,14 +54,6 @@ js/lib/id/index.js: $(shell find modules/index.js -type f)
@rm -f $@
node_modules/.bin/rollup -f umd -n iD modules/index.js --no-strict -o $@
js/lib/id/modes.js: $(shell find modules/modes -type f)
@rm -f $@
node_modules/.bin/rollup -f umd -n iD.modes modules/modes/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 $@
-1
View File
@@ -37,7 +37,6 @@
<script src='js/lib/id/index.js'></script>
<script src='js/lib/id/renderer.js'></script>
<script src='js/lib/id/services.js'></script>
<script src='js/lib/id/ui/index.js'></script>
+1597
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -7,6 +7,7 @@ import * as operations from './operations/index';
import * as presets from './presets/index';
import * as validations from './validations/index';
// core
export { Connection } from './core/connection';
export { Difference } from './core/difference';
export { Entity } from './core/entity';
@@ -18,6 +19,13 @@ export { oneWayTags, pavedTags, interestingTag } from './core/tags';
export { Tree } from './core/tree';
export { Way } from './core/way';
// renderer
export { BackgroundSource } from './renderer/background_source';
export { Background } from './renderer/background';
export { Features } from './renderer/features';
export { Map } from './renderer/map';
export { TileLayer } from './renderer/tile_layer';
export {
actions,
geo,
+8 -6
View File
@@ -1,3 +1,5 @@
import { stringQs, qsString } from '../util/index';
import { offsetToMeters, Extent, metersToOffset } from '../geo/index';
import { BackgroundSource } from './background_source';
import { TileLayer } from './tile_layer';
@@ -44,11 +46,11 @@ export function Background(context) {
background.updateImagery = function() {
var b = background.baseLayerSource(),
o = overlayLayers.map(function (d) { return d.source().id; }).join(','),
meters = iD.geo.offsetToMeters(b.offset()),
meters = offsetToMeters(b.offset()),
epsilon = 0.01,
x = +meters[0].toFixed(2),
y = +meters[1].toFixed(2),
q = iD.util.stringQs(location.hash.substring(1));
q = stringQs(location.hash.substring(1));
var id = b.id;
if (id === 'custom') {
@@ -73,7 +75,7 @@ export function Background(context) {
delete q.offset;
}
location.replace('#' + iD.util.qsString(q, true));
location.replace('#' + qsString(q, true));
var imageryUsed = [b.imageryUsed()];
@@ -181,10 +183,10 @@ export function Background(context) {
if (!qmap) return false;
var args = qmap.split('/').map(Number);
if (args.length < 3 || args.some(isNaN)) return false;
return iD.geo.Extent([args[1], args[2]]);
return Extent([args[1], args[2]]);
}
var q = iD.util.stringQs(location.hash.substring(1)),
var q = stringQs(location.hash.substring(1)),
chosen = q.background || q.layer,
extent = parseMap(q.map),
best;
@@ -238,7 +240,7 @@ export function Background(context) {
});
if (offset.length === 2) {
background.offset(iD.geo.metersToOffset(offset));
background.offset(metersToOffset(offset));
}
}
};
+3 -2
View File
@@ -1,3 +1,4 @@
import { polygonIntersectsPolygon, Extent } from '../geo/index';
export function BackgroundSource(data) {
var source = _.clone(data),
offset = [0, 0],
@@ -64,7 +65,7 @@ export function BackgroundSource(data) {
source.intersects = function(extent) {
extent = extent.polygon();
return !data.polygon || data.polygon.some(function(polygon) {
return iD.geo.polygonIntersectsPolygon(polygon, extent, true);
return polygonIntersectsPolygon(polygon, extent, true);
});
};
@@ -101,7 +102,7 @@ BackgroundSource.Bing = function(data, dispatch) {
areas: provider.coverageAreas.map(function(area) {
return {
zoom: [area.zoomMin, area.zoomMax],
extent: iD.geo.Extent([area.bbox[1], area.bbox[0]], [area.bbox[3], area.bbox[2]])
extent: Extent([area.bbox[1], area.bbox[0]], [area.bbox[3], area.bbox[2]])
};
})
};
+5 -4
View File
@@ -1,3 +1,4 @@
import { Entity } from '../core/index';
export function Features(context) {
var traffic_roads = {
'motorway': true,
@@ -271,7 +272,7 @@ export function Features(context) {
};
features.clearEntity = function(entity) {
delete _cache[iD.Entity.key(entity)];
delete _cache[Entity.key(entity)];
};
features.reset = function() {
@@ -281,7 +282,7 @@ export function Features(context) {
features.getMatches = function(entity, resolver, geometry) {
if (geometry === 'vertex' || geometry === 'relation') return {};
var ent = iD.Entity.key(entity);
var ent = Entity.key(entity);
if (!_cache[ent]) {
_cache[ent] = {};
}
@@ -307,7 +308,7 @@ export function Features(context) {
if (entity.type === 'way') {
var parents = features.getParents(entity, resolver, geometry);
if (parents.length === 1 && parents[0].isMultipolygon()) {
var pkey = iD.Entity.key(parents[0]);
var pkey = Entity.key(parents[0]);
if (_cache[pkey] && _cache[pkey].matches) {
matches = _.clone(_cache[pkey].matches);
continue;
@@ -329,7 +330,7 @@ export function Features(context) {
features.getParents = function(entity, resolver, geometry) {
if (geometry === 'point') return [];
var ent = iD.Entity.key(entity);
var ent = Entity.key(entity);
if (!_cache[ent]) {
_cache[ent] = {};
}
+25 -20
View File
@@ -1,3 +1,8 @@
import { setTransform, fastMouse } from '../util/index';
import { interp, Extent } from '../geo/index';
import { Layers, Areas, Midpoints, Points, Vertices, Lines, Labels } from '../svg/index';
import { flash } from '../ui/core/index';
export function Map(context) {
var dimensions = [1, 1],
dispatch = d3.dispatch('move', 'drawn'),
@@ -13,13 +18,13 @@ export function Map(context) {
transformed = false,
easing = false,
minzoom = 0,
drawLayers = iD.svg.Layers(projection, context),
drawPoints = iD.svg.Points(projection, context),
drawVertices = iD.svg.Vertices(projection, context),
drawLines = iD.svg.Lines(projection),
drawAreas = iD.svg.Areas(projection),
drawMidpoints = iD.svg.Midpoints(projection, context),
drawLabels = iD.svg.Labels(projection, context),
drawLayers = Layers(projection, context),
drawPoints = Points(projection, context),
drawVertices = Vertices(projection, context),
drawLines = Lines(projection),
drawAreas = Areas(projection),
drawMidpoints = Midpoints(projection, context),
drawLabels = Labels(projection, context),
supersurface,
wrapper,
surface,
@@ -47,7 +52,7 @@ export function Map(context) {
supersurface = selection.append('div')
.attr('id', 'supersurface')
.call(iD.util.setTransform, 0, 0);
.call(setTransform, 0, 0);
// Need a wrapper div because Opera can't cope with an absolutely positioned
// SVG element: http://bl.ocks.org/jfirebaugh/6fbfbd922552bf776c16
@@ -174,7 +179,7 @@ export function Map(context) {
function zoomPan() {
if (Math.log(d3.event.scale) / Math.LN2 - 8 < minzoom) {
surface.interrupt();
iD.ui.flash(context.container())
flash(context.container())
.select('.content')
.text(t('cannot_zoom'));
setZoom(context.minEditableZoom(), true);
@@ -192,7 +197,7 @@ export function Map(context) {
tY = (d3.event.translate[1] / scale - transformStart[1][1]) * scale;
transformed = true;
iD.util.setTransform(supersurface, tX, tY, scale);
setTransform(supersurface, tX, tY, scale);
queueRedraw();
dispatch.move(map);
@@ -202,7 +207,7 @@ export function Map(context) {
if (!transformed) return false;
surface.selectAll('.radial-menu').interrupt().remove();
iD.util.setTransform(supersurface, 0, 0);
setTransform(supersurface, 0, 0);
transformed = false;
return true;
}
@@ -351,7 +356,7 @@ export function Map(context) {
drawLayers.dimensions(dimensions);
context.background().dimensions(dimensions);
projection.clipExtent([[0, 0], dimensions]);
mouse = iD.util.fastMouse(supersurface.node());
mouse = fastMouse(supersurface.node());
setCenter(center);
return redraw();
};
@@ -389,7 +394,7 @@ export function Map(context) {
if (z < minzoom) {
surface.interrupt();
iD.ui.flash(context.container())
flash(context.container())
.select('.content')
.text(t('cannot_zoom'));
z = context.minEditableZoom();
@@ -449,7 +454,7 @@ export function Map(context) {
easing = false;
}
var locNow = iD.geo.interp(loc1, loc2, ease((tNow - t1) / duration));
var locNow = interp(loc1, loc2, ease((tNow - t1) / duration));
setCenter(locNow);
d3.event = {
@@ -472,10 +477,10 @@ export function Map(context) {
map.extent = function(_) {
if (!arguments.length) {
return new iD.geo.Extent(projection.invert([0, dimensions[1]]),
return new Extent(projection.invert([0, dimensions[1]]),
projection.invert([dimensions[0], 0]));
} else {
var extent = iD.geo.Extent(_);
var extent = Extent(_);
map.centerZoom(extent.center(), map.extentZoom(extent));
}
};
@@ -483,10 +488,10 @@ export function Map(context) {
map.trimmedExtent = function(_) {
if (!arguments.length) {
var headerY = 60, footerY = 30, pad = 10;
return new iD.geo.Extent(projection.invert([pad, dimensions[1] - footerY - pad]),
return new Extent(projection.invert([pad, dimensions[1] - footerY - pad]),
projection.invert([dimensions[0] - pad, headerY + pad]));
} else {
var extent = iD.geo.Extent(_);
var extent = Extent(_);
map.centerZoom(extent.center(), map.trimmedExtentZoom(extent));
}
};
@@ -506,13 +511,13 @@ export function Map(context) {
}
map.extentZoom = function(_) {
return calcZoom(iD.geo.Extent(_), dimensions);
return calcZoom(Extent(_), dimensions);
};
map.trimmedExtentZoom = function(_) {
var trimY = 120, trimX = 40,
trimmed = [dimensions[0] - trimX, dimensions[1] - trimY];
return calcZoom(iD.geo.Extent(_), trimmed);
return calcZoom(Extent(_), trimmed);
};
map.editable = function() {
+2 -1
View File
@@ -1,3 +1,4 @@
import { prefixCSSProperty } from '../util/index';
export function TileLayer(context) {
var tileSize = 256,
tile = d3.geo.tile(),
@@ -5,7 +6,7 @@ export function TileLayer(context) {
cache = {},
tileOrigin,
z,
transformProp = iD.util.prefixCSSProperty('Transform'),
transformProp = prefixCSSProperty('Transform'),
source = d3.functor('');
-1
View File
@@ -42,7 +42,6 @@
<script src='../js/id/id.js'></script>
<script src='../js/lib/id/index.js'></script>
<script src='../js/lib/id/renderer.js'></script>
<script src='../js/lib/id/services.js'></script>
<script src='../js/lib/id/ui/index.js'></script>