mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-21 11:16:36 +02:00
Refactor Entity, Node, Relation, Tags, Way from core to osm
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { geoEuclideanDistance, geoInterp } from '../geo/index';
|
||||
import { coreNode } from '../core/index';
|
||||
import { osmNode } from '../osm/index';
|
||||
|
||||
import {
|
||||
polygonArea as d3polygonArea,
|
||||
@@ -105,7 +105,7 @@ export function actionCircularize(wayId, projection, maxAngle) {
|
||||
centroid[0] + Math.cos(angle) * radius,
|
||||
centroid[1] + Math.sin(angle) * radius]);
|
||||
|
||||
node = coreNode({loc: loc});
|
||||
node = osmNode({loc: loc});
|
||||
graph = graph.replace(node);
|
||||
|
||||
nodes.splice(endNodeIndex + j, 0, node);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { coreNode } from '../core/index';
|
||||
import { osmNode } from '../osm/node';
|
||||
|
||||
|
||||
// Disconect the ways at the given node.
|
||||
@@ -25,7 +25,7 @@ export function actionDisconnect(nodeId, newNodeId) {
|
||||
|
||||
connections.forEach(function(connection) {
|
||||
var way = graph.entity(connection.wayID),
|
||||
newNode = coreNode({id: newNodeId, loc: node.loc, tags: node.tags});
|
||||
newNode = osmNode({id: newNodeId, loc: node.loc, tags: node.tags});
|
||||
|
||||
graph = graph.replace(newNode);
|
||||
if (connection.index === 0 && way.isArea()) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { actionDeleteWay } from './delete_way';
|
||||
import { coreInterestingTag } from '../core/index';
|
||||
import { osmIsInterestingTag } from '../osm/index';
|
||||
import { geoJoinWays } from '../geo/index';
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ export function actionJoin(ids) {
|
||||
for (var k in way.tags) {
|
||||
if (!(k in tags)) {
|
||||
tags[k] = way.tags[k];
|
||||
} else if (tags[k] && coreInterestingTag(k) && tags[k] !== way.tags[k]) {
|
||||
} else if (tags[k] && osmIsInterestingTag(k) && tags[k] !== way.tags[k]) {
|
||||
conflicting = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { geoJoinWays, geoPolygonContainsPolygon } from '../geo/index';
|
||||
import { coreRelation } from '../core/index';
|
||||
import { osmRelation } from '../osm/index';
|
||||
|
||||
|
||||
export function actionMergePolygon(ids, newRelationId) {
|
||||
@@ -85,7 +85,7 @@ export function actionMergePolygon(ids, newRelationId) {
|
||||
|
||||
// Move all tags to one relation
|
||||
var relation = entities.multipolygon[0] ||
|
||||
coreRelation({ id: newRelationId, tags: { type: 'multipolygon' }});
|
||||
osmRelation({ id: newRelationId, tags: { type: 'multipolygon' }});
|
||||
|
||||
entities.multipolygon.slice(1).forEach(function(m) {
|
||||
relation = relation.mergeTags(m.tags);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import { t } from '../util/locale';
|
||||
import { actionDeleteMultiple } from './delete_multiple';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { diff3_merge } from '../util/diff3';
|
||||
import { dataDiscarded } from '../../data/index';
|
||||
|
||||
@@ -103,14 +103,14 @@ export function actionMergeRemoteChanges(id, localGraph, remoteGraph, formatUser
|
||||
updates.replacements.push(remote);
|
||||
|
||||
} else if (option === 'force_local' && local) {
|
||||
target = coreEntity(local);
|
||||
target = osmEntity(local);
|
||||
if (remote) {
|
||||
target = target.update({ version: remote.version });
|
||||
}
|
||||
updates.replacements.push(target);
|
||||
|
||||
} else if (option === 'safe' && local && remote && local.version !== remote.version) {
|
||||
target = coreEntity(local, { version: remote.version });
|
||||
target = osmEntity(local, { version: remote.version });
|
||||
if (remote.visible) {
|
||||
target = mergeLocation(remote, target);
|
||||
} else {
|
||||
@@ -208,7 +208,7 @@ export function actionMergeRemoteChanges(id, localGraph, remoteGraph, formatUser
|
||||
base = graph.base().entities[id],
|
||||
local = localGraph.entity(id),
|
||||
remote = remoteGraph.entity(id),
|
||||
target = coreEntity(local, { version: remote.version });
|
||||
target = osmEntity(local, { version: remote.version });
|
||||
|
||||
// delete/undelete
|
||||
if (!remote.visible) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
import { coreNode } from '../core/index';
|
||||
import { osmNode } from '../osm/index';
|
||||
import {
|
||||
geoChooseEdge,
|
||||
geoAngle,
|
||||
@@ -133,7 +133,7 @@ export function actionMove(moveIds, tryDelta, projection, cache) {
|
||||
var key = wayId + '_' + nodeId,
|
||||
orig = cache.replacedVertex[key];
|
||||
if (!orig) {
|
||||
orig = coreNode();
|
||||
orig = osmNode();
|
||||
cache.replacedVertex[key] = orig;
|
||||
cache.startLoc[orig.id] = cache.startLoc[nodeId];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { coreRelation, coreWay } from '../core/index';
|
||||
import { actionSplit } from './split';
|
||||
import { geoInferRestriction } from '../geo/index';
|
||||
import { osmRelation, osmWay } from '../osm/index';
|
||||
|
||||
|
||||
// Create a restriction relation for `turn`, which must have the following structure:
|
||||
@@ -39,7 +39,7 @@ export function actionRestrictTurn(turn, projection, restrictionId) {
|
||||
}
|
||||
|
||||
function split(toOrFrom) {
|
||||
var newID = toOrFrom.newID || coreWay().id;
|
||||
var newID = toOrFrom.newID || osmWay().id;
|
||||
graph = actionSplit(via.id, [newID])
|
||||
.limitWays([toOrFrom.way])(graph);
|
||||
|
||||
@@ -72,7 +72,7 @@ export function actionRestrictTurn(turn, projection, restrictionId) {
|
||||
to = split(turn.to)[0];
|
||||
}
|
||||
|
||||
return graph.replace(coreRelation({
|
||||
return graph.replace(osmRelation({
|
||||
id: restrictionId,
|
||||
tags: {
|
||||
type: 'restriction',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
import { coreRelation, coreWay } from '../core/index';
|
||||
import { osmRelation, osmWay } from '../osm/index';
|
||||
import { geoIsSimpleMultipolygonOuterMember, geoSphericalDistance } from '../geo/index';
|
||||
import { actionAddMember } from './add_member';
|
||||
import { utilWrap } from '../util/index';
|
||||
@@ -75,7 +75,7 @@ export function actionSplit(nodeId, newWayIds) {
|
||||
|
||||
|
||||
function split(graph, wayA, newWayId) {
|
||||
var wayB = coreWay({id: newWayId, tags: wayA.tags}),
|
||||
var wayB = osmWay({id: newWayId, tags: wayA.tags}),
|
||||
nodesA,
|
||||
nodesB,
|
||||
isArea = wayA.isArea(),
|
||||
@@ -130,7 +130,7 @@ export function actionSplit(nodeId, newWayIds) {
|
||||
});
|
||||
|
||||
if (!isOuter && isArea) {
|
||||
var multipolygon = coreRelation({
|
||||
var multipolygon = osmRelation({
|
||||
tags: _.extend({}, wayA.tags, {type: 'multipolygon'}),
|
||||
members: [
|
||||
{id: wayA.id, role: 'outer', type: 'way'},
|
||||
|
||||
@@ -14,9 +14,9 @@ import {
|
||||
} from '../modes/index';
|
||||
|
||||
import {
|
||||
coreNode,
|
||||
coreWay
|
||||
} from '../core/index';
|
||||
osmNode,
|
||||
osmWay
|
||||
} from '../osm/index';
|
||||
|
||||
import {
|
||||
geoChooseEdge,
|
||||
@@ -44,9 +44,9 @@ export function behaviorDrawWay(context, wayId, index, mode, baseGraph) {
|
||||
draw = behaviorDraw(context);
|
||||
|
||||
var startIndex = typeof index === 'undefined' ? way.nodes.length - 1 : 0,
|
||||
start = coreNode({loc: context.graph().entity(way.nodes[startIndex]).loc}),
|
||||
end = coreNode({loc: context.map().mouseCoordinates()}),
|
||||
segment = coreWay({
|
||||
start = osmNode({loc: context.graph().entity(way.nodes[startIndex]).loc}),
|
||||
end = osmNode({loc: context.map().mouseCoordinates()}),
|
||||
segment = osmWay({
|
||||
nodes: typeof index === 'undefined' ? [start.id, end.id] : [end.id, start.id],
|
||||
tags: _.clone(way.tags)
|
||||
});
|
||||
@@ -165,7 +165,7 @@ export function behaviorDrawWay(context, wayId, index, mode, baseGraph) {
|
||||
var last = context.hasEntity(way.nodes[way.nodes.length - (isArea ? 2 : 1)]);
|
||||
if (last && last.loc[0] === loc[0] && last.loc[1] === loc[1]) return;
|
||||
|
||||
var newNode = coreNode({loc: loc});
|
||||
var newNode = osmNode({loc: loc});
|
||||
|
||||
context.replace(
|
||||
actionAddEntity(newNode),
|
||||
@@ -188,7 +188,7 @@ export function behaviorDrawWay(context, wayId, index, mode, baseGraph) {
|
||||
if (!isArea && geoEdgeEqual(edge, previousEdge))
|
||||
return;
|
||||
|
||||
var newNode = coreNode({ loc: loc });
|
||||
var newNode = osmNode({ loc: loc });
|
||||
|
||||
context.perform(
|
||||
actionAddMidpoint({ loc: loc, edge: edge}, newNode),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as d3 from 'd3';
|
||||
import { d3keybinding } from '../lib/d3.keybinding.js';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { utilRebind } from '../util/rebind';
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ export function behaviorHover() {
|
||||
selection.selectAll('.hover-suppressed')
|
||||
.classed('hover-suppressed', false);
|
||||
|
||||
if (target instanceof coreEntity) {
|
||||
if (target instanceof osmEntity) {
|
||||
var selector = '.' + target.id;
|
||||
|
||||
if (target.type === 'relation') {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { modeBrowse, modeSelect } from '../modes/index';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
|
||||
|
||||
export function behaviorSelect(context) {
|
||||
@@ -27,7 +27,7 @@ export function behaviorSelect(context) {
|
||||
lasso = d3.select('#surface .lasso').node(),
|
||||
mode = context.mode();
|
||||
|
||||
if (!(datum instanceof coreEntity)) {
|
||||
if (!(datum instanceof osmEntity)) {
|
||||
if (!d3.event.shiftKey && !lasso && mode.id !== 'browse')
|
||||
context.enter(modeBrowse(context));
|
||||
|
||||
|
||||
+17
-20
@@ -1,16 +1,13 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { utilRebind } from '../util/rebind';
|
||||
import { utilFunctor } from '../util/index';
|
||||
import osmAuth from 'osm-auth';
|
||||
import { JXON } from '../util/jxon';
|
||||
import { d3geoTile } from '../lib/d3.geo.tile';
|
||||
import { geoExtent } from '../geo/index';
|
||||
import { osmEntity, osmNode, osmRelation, osmWay } from '../osm/index';
|
||||
import { utilDetect } from '../util/detect';
|
||||
import { coreEntity } from './entity';
|
||||
import { coreNode } from './node';
|
||||
import { coreRelation } from './relation';
|
||||
import { coreWay } from './way';
|
||||
import { JXON } from '../util/jxon';
|
||||
import osmAuth from 'osm-auth';
|
||||
import { utilRebind } from '../util/rebind';
|
||||
import { utilFunctor } from '../util/index';
|
||||
|
||||
|
||||
export function coreConnection(useHttps) {
|
||||
@@ -75,8 +72,8 @@ export function coreConnection(useHttps) {
|
||||
|
||||
|
||||
connection.loadEntity = function(id, callback) {
|
||||
var type = coreEntity.id.type(id),
|
||||
osmID = coreEntity.id.toOSM(id);
|
||||
var type = osmEntity.id.type(id),
|
||||
osmID = osmEntity.id.toOSM(id);
|
||||
|
||||
connection.loadFromURL(
|
||||
url + '/api/0.6/' + type + '/' + osmID + (type !== 'node' ? '/full' : ''),
|
||||
@@ -87,8 +84,8 @@ export function coreConnection(useHttps) {
|
||||
|
||||
|
||||
connection.loadEntityVersion = function(id, version, callback) {
|
||||
var type = coreEntity.id.type(id),
|
||||
osmID = coreEntity.id.toOSM(id);
|
||||
var type = osmEntity.id.type(id),
|
||||
osmID = osmEntity.id.toOSM(id);
|
||||
|
||||
connection.loadFromURL(
|
||||
url + '/api/0.6/' + type + '/' + osmID + '/' + version,
|
||||
@@ -99,9 +96,9 @@ export function coreConnection(useHttps) {
|
||||
|
||||
|
||||
connection.loadMultiple = function(ids, callback) {
|
||||
_.each(_.groupBy(_.uniq(ids), coreEntity.id.type), function(v, k) {
|
||||
_.each(_.groupBy(_.uniq(ids), osmEntity.id.type), function(v, k) {
|
||||
var type = k + 's',
|
||||
osmIDs = _.map(v, coreEntity.id.toOSM);
|
||||
osmIDs = _.map(v, osmEntity.id.toOSM);
|
||||
|
||||
_.each(_.chunk(osmIDs, 150), function(arr) {
|
||||
connection.loadFromURL(
|
||||
@@ -175,8 +172,8 @@ export function coreConnection(useHttps) {
|
||||
var parsers = {
|
||||
node: function nodeData(obj) {
|
||||
var attrs = obj.attributes;
|
||||
return new coreNode({
|
||||
id: coreEntity.id.fromOSM(nodeStr, attrs.id.value),
|
||||
return new osmNode({
|
||||
id: osmEntity.id.fromOSM(nodeStr, attrs.id.value),
|
||||
loc: getLoc(attrs),
|
||||
version: attrs.version.value,
|
||||
user: attrs.user && attrs.user.value,
|
||||
@@ -187,8 +184,8 @@ export function coreConnection(useHttps) {
|
||||
|
||||
way: function wayData(obj) {
|
||||
var attrs = obj.attributes;
|
||||
return new coreWay({
|
||||
id: coreEntity.id.fromOSM(wayStr, attrs.id.value),
|
||||
return new osmWay({
|
||||
id: osmEntity.id.fromOSM(wayStr, attrs.id.value),
|
||||
version: attrs.version.value,
|
||||
user: attrs.user && attrs.user.value,
|
||||
tags: getTags(obj),
|
||||
@@ -199,8 +196,8 @@ export function coreConnection(useHttps) {
|
||||
|
||||
relation: function relationData(obj) {
|
||||
var attrs = obj.attributes;
|
||||
return new coreRelation({
|
||||
id: coreEntity.id.fromOSM(relationStr, attrs.id.value),
|
||||
return new osmRelation({
|
||||
id: osmEntity.id.fromOSM(relationStr, attrs.id.value),
|
||||
version: attrs.version.value,
|
||||
user: attrs.user && attrs.user.value,
|
||||
tags: getTags(obj),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { utilGetPrototypeOf } from '../util/index';
|
||||
import { debug } from '../index';
|
||||
import { utilGetPrototypeOf } from '../util/index';
|
||||
|
||||
|
||||
export function coreGraph(other, mutable) {
|
||||
|
||||
@@ -2,9 +2,9 @@ import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import * as Validations from '../validations/index';
|
||||
import { coreDifference } from './difference';
|
||||
import { coreEntity } from './entity';
|
||||
import { coreGraph } from './graph';
|
||||
import { coreTree } from './tree';
|
||||
import { osmEntity } from '../osm/entity';
|
||||
import { uiLoading } from '../ui/index';
|
||||
import { utilSessionMutex } from '../util/index';
|
||||
import { utilRebind } from '../util/rebind';
|
||||
@@ -244,7 +244,7 @@ export function coreHistory(context) {
|
||||
|
||||
_.forEach(i.graph.entities, function(entity, id) {
|
||||
if (entity) {
|
||||
var key = coreEntity.key(entity);
|
||||
var key = osmEntity.key(entity);
|
||||
allEntities[key] = entity;
|
||||
modified.push(key);
|
||||
} else {
|
||||
@@ -279,7 +279,7 @@ export function coreHistory(context) {
|
||||
entities: _.values(allEntities),
|
||||
baseEntities: _.values(baseEntities),
|
||||
stack: s,
|
||||
nextIDs: coreEntity.id.next,
|
||||
nextIDs: osmEntity.id.next,
|
||||
index: index
|
||||
});
|
||||
},
|
||||
@@ -289,21 +289,21 @@ export function coreHistory(context) {
|
||||
var h = JSON.parse(json),
|
||||
loadComplete = true;
|
||||
|
||||
coreEntity.id.next = h.nextIDs;
|
||||
osmEntity.id.next = h.nextIDs;
|
||||
index = h.index;
|
||||
|
||||
if (h.version === 2 || h.version === 3) {
|
||||
var allEntities = {};
|
||||
|
||||
h.entities.forEach(function(entity) {
|
||||
allEntities[coreEntity.key(entity)] = coreEntity(entity);
|
||||
allEntities[osmEntity.key(entity)] = osmEntity(entity);
|
||||
});
|
||||
|
||||
if (h.version === 3) {
|
||||
// This merges originals for changed entities into the base of
|
||||
// the stack even if the current stack doesn't have them (for
|
||||
// example when iD has been restarted in a different region)
|
||||
var baseEntities = h.baseEntities.map(function(d) { return coreEntity(d); });
|
||||
var baseEntities = h.baseEntities.map(function(d) { return osmEntity(d); });
|
||||
stack[0].graph.rebase(baseEntities, _.map(stack, 'graph'), true);
|
||||
tree.rebase(baseEntities, true);
|
||||
|
||||
@@ -382,7 +382,7 @@ export function coreHistory(context) {
|
||||
|
||||
for (var i in d.entities) {
|
||||
var entity = d.entities[i];
|
||||
entities[i] = entity === 'undefined' ? undefined : coreEntity(entity);
|
||||
entities[i] = entity === 'undefined' ? undefined : osmEntity(entity);
|
||||
}
|
||||
|
||||
d.graph = coreGraph(stack[0].graph).load(entities);
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
export { coreConnection } from './connection';
|
||||
export { coreContext } from './context';
|
||||
export { coreDifference } from './difference';
|
||||
export { coreEntity } from './entity';
|
||||
export { coreGraph } from './graph';
|
||||
export { coreHistory } from './history';
|
||||
export { coreNode } from './node';
|
||||
export { coreRelation } from './relation';
|
||||
export { coreOneWayTags, corePavedTags, coreInterestingTag } from './tags';
|
||||
export { coreTree } from './tree';
|
||||
export { coreWay } from './way';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { coreWay } from '../core/index';
|
||||
import { geoAngle } from './index';
|
||||
import { osmWay } from '../osm/index';
|
||||
|
||||
|
||||
export function geoTurn(turn) {
|
||||
@@ -44,14 +44,14 @@ export function geoIntersection(graph, vertexId) {
|
||||
var splitIndex, wayA, wayB, indexA, indexB;
|
||||
if (isClosingNode) {
|
||||
splitIndex = Math.ceil(way.nodes.length / 2); // split at midpoint
|
||||
wayA = coreWay({id: way.id + '-a', tags: way.tags, nodes: way.nodes.slice(0, splitIndex)});
|
||||
wayB = coreWay({id: way.id + '-b', tags: way.tags, nodes: way.nodes.slice(splitIndex)});
|
||||
wayA = osmWay({id: way.id + '-a', tags: way.tags, nodes: way.nodes.slice(0, splitIndex)});
|
||||
wayB = osmWay({id: way.id + '-b', tags: way.tags, nodes: way.nodes.slice(splitIndex)});
|
||||
indexA = 1;
|
||||
indexB = way.nodes.length - 2;
|
||||
} else {
|
||||
splitIndex = _.indexOf(way.nodes, vertex.id, 1); // split at vertexid
|
||||
wayA = coreWay({id: way.id + '-a', tags: way.tags, nodes: way.nodes.slice(0, splitIndex + 1)});
|
||||
wayB = coreWay({id: way.id + '-b', tags: way.tags, nodes: way.nodes.slice(splitIndex)});
|
||||
wayA = osmWay({id: way.id + '-a', tags: way.tags, nodes: way.nodes.slice(0, splitIndex + 1)});
|
||||
wayB = osmWay({id: way.id + '-b', tags: way.tags, nodes: way.nodes.slice(splitIndex)});
|
||||
indexA = splitIndex - 1;
|
||||
indexB = splitIndex + 1;
|
||||
}
|
||||
|
||||
+6
-5
@@ -1,10 +1,11 @@
|
||||
export * from './actions/index';
|
||||
export * from './behavior/index';
|
||||
export * from './core/index';
|
||||
export * from '../data/index.js';
|
||||
export * from '../data/index';
|
||||
export * from './geo/index';
|
||||
export * from './modes/index';
|
||||
export * from './operations/index';
|
||||
export * from './osm/index';
|
||||
export * from './presets/index';
|
||||
export * from './renderer/index';
|
||||
export * from './services/index';
|
||||
@@ -20,13 +21,13 @@ export * from './validations/index';
|
||||
export { coreConnection as Connection } from './core/connection';
|
||||
export { coreContext as Context, setAreaKeys } from './core/context';
|
||||
export { coreDifference as Difference } from './core/difference';
|
||||
export { coreEntity as Entity } from './core/entity';
|
||||
export { coreGraph as Graph } from './core/graph';
|
||||
export { coreHistory as History } from './core/history';
|
||||
export { coreNode as Node } from './core/node';
|
||||
export { coreRelation as Relation } from './core/relation';
|
||||
export { coreTree as Tree } from './core/tree';
|
||||
export { coreWay as Way } from './core/way';
|
||||
export { osmEntity as Entity } from './osm/entity';
|
||||
export { osmNode as Node } from './osm/node';
|
||||
export { osmRelation as Relation } from './osm/relation';
|
||||
export { osmWay as Way } from './osm/way';
|
||||
export { rendererBackgroundSource as BackgroundSource } from './renderer/background_source';
|
||||
export { rendererBackground as Background } from './renderer/background';
|
||||
export { rendererFeatures as Features } from './renderer/features';
|
||||
|
||||
@@ -5,9 +5,9 @@ import {
|
||||
actionAddVertex
|
||||
} from '../actions/index';
|
||||
|
||||
import { coreNode, coreWay } from '../core/index';
|
||||
import { behaviorAddWay } from '../behavior/index';
|
||||
import { modeDrawArea } from './index';
|
||||
import { osmNode, osmWay } from '../osm/index';
|
||||
|
||||
|
||||
export function modeAddArea(context) {
|
||||
@@ -29,8 +29,8 @@ export function modeAddArea(context) {
|
||||
|
||||
function start(loc) {
|
||||
var graph = context.graph(),
|
||||
node = coreNode({ loc: loc }),
|
||||
way = coreWay({ tags: defaultTags });
|
||||
node = osmNode({ loc: loc }),
|
||||
way = osmWay({ tags: defaultTags });
|
||||
|
||||
context.perform(
|
||||
actionAddEntity(node),
|
||||
@@ -45,8 +45,8 @@ export function modeAddArea(context) {
|
||||
|
||||
function startFromWay(loc, edge) {
|
||||
var graph = context.graph(),
|
||||
node = coreNode({ loc: loc }),
|
||||
way = coreWay({ tags: defaultTags });
|
||||
node = osmNode({ loc: loc }),
|
||||
way = osmWay({ tags: defaultTags });
|
||||
|
||||
context.perform(
|
||||
actionAddEntity(node),
|
||||
@@ -62,7 +62,7 @@ export function modeAddArea(context) {
|
||||
|
||||
function startFromNode(node) {
|
||||
var graph = context.graph(),
|
||||
way = coreWay({ tags: defaultTags });
|
||||
way = osmWay({ tags: defaultTags });
|
||||
|
||||
context.perform(
|
||||
actionAddEntity(way),
|
||||
|
||||
@@ -5,9 +5,9 @@ import {
|
||||
actionAddVertex
|
||||
} from '../actions/index';
|
||||
|
||||
import { coreNode, coreWay } from '../core/index';
|
||||
import { behaviorAddWay } from '../behavior/index';
|
||||
import { modeDrawLine } from './index';
|
||||
import { osmNode, osmWay } from '../osm/index';
|
||||
|
||||
|
||||
export function modeAddLine(context) {
|
||||
@@ -28,8 +28,8 @@ export function modeAddLine(context) {
|
||||
|
||||
function start(loc) {
|
||||
var baseGraph = context.graph(),
|
||||
node = coreNode({ loc: loc }),
|
||||
way = coreWay();
|
||||
node = osmNode({ loc: loc }),
|
||||
way = osmWay();
|
||||
|
||||
context.perform(
|
||||
actionAddEntity(node),
|
||||
@@ -43,8 +43,8 @@ export function modeAddLine(context) {
|
||||
|
||||
function startFromWay(loc, edge) {
|
||||
var baseGraph = context.graph(),
|
||||
node = coreNode({ loc: loc }),
|
||||
way = coreWay();
|
||||
node = osmNode({ loc: loc }),
|
||||
way = osmWay();
|
||||
|
||||
context.perform(
|
||||
actionAddEntity(node),
|
||||
@@ -59,7 +59,7 @@ export function modeAddLine(context) {
|
||||
|
||||
function startFromNode(node) {
|
||||
var baseGraph = context.graph(),
|
||||
way = coreWay();
|
||||
way = osmWay();
|
||||
|
||||
context.perform(
|
||||
actionAddEntity(way),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { t } from '../util/locale';
|
||||
import { modeBrowse, modeSelect } from './index';
|
||||
import { actionAddEntity } from '../actions/index';
|
||||
import { behaviorDraw } from '../behavior/index';
|
||||
import { coreNode } from '../core/index';
|
||||
import { modeBrowse, modeSelect } from './index';
|
||||
import { osmNode } from '../osm/index';
|
||||
|
||||
|
||||
export function modeAddPoint(context) {
|
||||
@@ -24,7 +24,7 @@ export function modeAddPoint(context) {
|
||||
|
||||
|
||||
function add(loc) {
|
||||
var node = coreNode({ loc: loc });
|
||||
var node = osmNode({ loc: loc });
|
||||
|
||||
context.perform(
|
||||
actionAddEntity(node),
|
||||
|
||||
@@ -19,8 +19,8 @@ import {
|
||||
modeSelect
|
||||
} from './index';
|
||||
|
||||
import { coreNode } from '../core/index';
|
||||
import { geoChooseEdge } from '../geo/index';
|
||||
import { osmNode } from '../osm/index';
|
||||
import { utilEntitySelector } from '../util/index';
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ export function modeDragNode(context) {
|
||||
wasMidpoint = entity.type === 'midpoint';
|
||||
if (wasMidpoint) {
|
||||
var midpoint = entity;
|
||||
entity = coreNode();
|
||||
entity = osmNode();
|
||||
context.perform(actionAddMidpoint(midpoint, entity));
|
||||
|
||||
var vertex = context.surface().selectAll('.' + entity.id);
|
||||
|
||||
@@ -21,9 +21,9 @@ import {
|
||||
} from '../geo/index';
|
||||
|
||||
import {
|
||||
coreNode,
|
||||
coreWay
|
||||
} from '../core/index';
|
||||
osmNode,
|
||||
osmWay
|
||||
} from '../osm/index';
|
||||
|
||||
import { modeBrowse } from './browse';
|
||||
import { modeDragNode } from './drag_node';
|
||||
@@ -154,9 +154,9 @@ export function modeSelect(context, selectedIDs) {
|
||||
var target = d3.select(d3.event.target),
|
||||
datum = target.datum();
|
||||
|
||||
if (datum instanceof coreWay && !target.classed('fill')) {
|
||||
if (datum instanceof osmWay && !target.classed('fill')) {
|
||||
var choice = geoChooseEdge(context.childNodes(datum), context.mouse(), context.projection),
|
||||
node = coreNode();
|
||||
node = osmNode();
|
||||
|
||||
var prev = datum.nodes[choice.index - 1],
|
||||
next = datum.nodes[choice.index];
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
import _ from 'lodash';
|
||||
import { debug } from '../index';
|
||||
import { coreInterestingTag } from './tags';
|
||||
import { osmIsInterestingTag } from './tags';
|
||||
import { dataDeprecated } from '../../data/index';
|
||||
|
||||
|
||||
export function coreEntity(attrs) {
|
||||
export function osmEntity(attrs) {
|
||||
// For prototypal inheritance.
|
||||
if (this instanceof coreEntity) return;
|
||||
if (this instanceof osmEntity) return;
|
||||
|
||||
// Create the appropriate subtype.
|
||||
if (attrs && attrs.type) {
|
||||
return coreEntity[attrs.type].apply(this, arguments);
|
||||
return osmEntity[attrs.type].apply(this, arguments);
|
||||
} else if (attrs && attrs.id) {
|
||||
return coreEntity[coreEntity.id.type(attrs.id)].apply(this, arguments);
|
||||
return osmEntity[osmEntity.id.type(attrs.id)].apply(this, arguments);
|
||||
}
|
||||
|
||||
// Initialize a generic Entity (used only in tests).
|
||||
return (new coreEntity()).initialize(arguments);
|
||||
return (new osmEntity()).initialize(arguments);
|
||||
}
|
||||
|
||||
|
||||
coreEntity.id = function(type) {
|
||||
return coreEntity.id.fromOSM(type, coreEntity.id.next[type]--);
|
||||
osmEntity.id = function(type) {
|
||||
return osmEntity.id.fromOSM(type, osmEntity.id.next[type]--);
|
||||
};
|
||||
|
||||
|
||||
coreEntity.id.next = {
|
||||
osmEntity.id.next = {
|
||||
node: -1, way: -1, relation: -1
|
||||
};
|
||||
|
||||
|
||||
coreEntity.id.fromOSM = function(type, id) {
|
||||
osmEntity.id.fromOSM = function(type, id) {
|
||||
return type[0] + id;
|
||||
};
|
||||
|
||||
|
||||
coreEntity.id.toOSM = function(id) {
|
||||
osmEntity.id.toOSM = function(id) {
|
||||
return id.slice(1);
|
||||
};
|
||||
|
||||
|
||||
coreEntity.id.type = function(id) {
|
||||
osmEntity.id.type = function(id) {
|
||||
return { 'n': 'node', 'w': 'way', 'r': 'relation' }[id[0]];
|
||||
};
|
||||
|
||||
|
||||
// A function suitable for use as the second argument to d3.selection#data().
|
||||
coreEntity.key = function(entity) {
|
||||
osmEntity.key = function(entity) {
|
||||
return entity.id + 'v' + (entity.v || 0);
|
||||
};
|
||||
|
||||
|
||||
coreEntity.prototype = {
|
||||
osmEntity.prototype = {
|
||||
|
||||
tags: {},
|
||||
|
||||
@@ -71,7 +71,7 @@ coreEntity.prototype = {
|
||||
}
|
||||
|
||||
if (!this.id && this.type) {
|
||||
this.id = coreEntity.id(this.type);
|
||||
this.id = osmEntity.id(this.type);
|
||||
}
|
||||
if (!this.hasOwnProperty('visible')) {
|
||||
this.visible = true;
|
||||
@@ -94,7 +94,7 @@ coreEntity.prototype = {
|
||||
if (copies[this.id])
|
||||
return copies[this.id];
|
||||
|
||||
var copy = coreEntity(this, {id: undefined, user: undefined, version: undefined});
|
||||
var copy = osmEntity(this, {id: undefined, user: undefined, version: undefined});
|
||||
copies[this.id] = copy;
|
||||
|
||||
return copy;
|
||||
@@ -102,7 +102,7 @@ coreEntity.prototype = {
|
||||
|
||||
|
||||
osmId: function() {
|
||||
return coreEntity.id.toOSM(this.id);
|
||||
return osmEntity.id.toOSM(this.id);
|
||||
},
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ coreEntity.prototype = {
|
||||
|
||||
|
||||
update: function(attrs) {
|
||||
return coreEntity(this, attrs, {v: 1 + (this.v || 0)});
|
||||
return osmEntity(this, attrs, {v: 1 + (this.v || 0)});
|
||||
},
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ coreEntity.prototype = {
|
||||
|
||||
|
||||
hasInterestingTags: function() {
|
||||
return _.keys(this.tags).some(coreInterestingTag);
|
||||
return _.keys(this.tags).some(osmIsInterestingTag);
|
||||
},
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
export { osmEntity } from './entity';
|
||||
export { osmNode } from './node';
|
||||
export { osmRelation } from './relation';
|
||||
export { osmWay } from './way';
|
||||
|
||||
export {
|
||||
osmOneWayTags,
|
||||
osmPavedTags,
|
||||
osmIsInterestingTag
|
||||
} from './tags';
|
||||
@@ -1,20 +1,20 @@
|
||||
import _ from 'lodash';
|
||||
import { coreEntity } from './entity';
|
||||
import { osmEntity } from './entity';
|
||||
import { geoExtent } from '../geo/index';
|
||||
|
||||
export function coreNode() {
|
||||
if (!(this instanceof coreNode)) {
|
||||
return (new coreNode()).initialize(arguments);
|
||||
export function osmNode() {
|
||||
if (!(this instanceof osmNode)) {
|
||||
return (new osmNode()).initialize(arguments);
|
||||
} else if (arguments.length) {
|
||||
this.initialize(arguments);
|
||||
}
|
||||
}
|
||||
|
||||
coreEntity.node = coreNode;
|
||||
osmEntity.node = osmNode;
|
||||
|
||||
coreNode.prototype = Object.create(coreEntity.prototype);
|
||||
osmNode.prototype = Object.create(osmEntity.prototype);
|
||||
|
||||
_.extend(coreNode.prototype, {
|
||||
_.extend(osmNode.prototype, {
|
||||
|
||||
type: 'node',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { coreEntity } from './entity';
|
||||
import { osmEntity } from './entity';
|
||||
import {
|
||||
geoExtent,
|
||||
geoJoinWays,
|
||||
@@ -9,30 +9,30 @@ import {
|
||||
} from '../geo/index';
|
||||
|
||||
|
||||
export function coreRelation() {
|
||||
if (!(this instanceof coreRelation)) {
|
||||
return (new coreRelation()).initialize(arguments);
|
||||
export function osmRelation() {
|
||||
if (!(this instanceof osmRelation)) {
|
||||
return (new osmRelation()).initialize(arguments);
|
||||
} else if (arguments.length) {
|
||||
this.initialize(arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
coreEntity.relation = coreRelation;
|
||||
osmEntity.relation = osmRelation;
|
||||
|
||||
coreRelation.prototype = Object.create(coreEntity.prototype);
|
||||
osmRelation.prototype = Object.create(osmEntity.prototype);
|
||||
|
||||
|
||||
coreRelation.creationOrder = function(a, b) {
|
||||
var aId = parseInt(coreEntity.id.toOSM(a.id), 10);
|
||||
var bId = parseInt(coreEntity.id.toOSM(b.id), 10);
|
||||
osmRelation.creationOrder = function(a, b) {
|
||||
var aId = parseInt(osmEntity.id.toOSM(a.id), 10);
|
||||
var bId = parseInt(osmEntity.id.toOSM(b.id), 10);
|
||||
|
||||
if (aId < 0 || bId < 0) return aId - bId;
|
||||
return bId - aId;
|
||||
};
|
||||
|
||||
|
||||
_.extend(coreRelation.prototype, {
|
||||
_.extend(osmRelation.prototype, {
|
||||
type: 'relation',
|
||||
members: [],
|
||||
|
||||
@@ -41,7 +41,7 @@ _.extend(coreRelation.prototype, {
|
||||
if (copies[this.id])
|
||||
return copies[this.id];
|
||||
|
||||
var copy = coreEntity.prototype.copy.call(this, resolver, copies);
|
||||
var copy = osmEntity.prototype.copy.call(this, resolver, copies);
|
||||
|
||||
var members = this.members.map(function(member) {
|
||||
return _.extend({}, member, { id: resolver.entity(member.id).copy(resolver, copies).id });
|
||||
@@ -188,7 +188,7 @@ _.extend(coreRelation.prototype, {
|
||||
keyAttributes: {
|
||||
type: member.type,
|
||||
role: member.role,
|
||||
ref: coreEntity.id.toOSM(member.id)
|
||||
ref: osmEntity.id.toOSM(member.id)
|
||||
}
|
||||
};
|
||||
}),
|
||||
@@ -1,4 +1,4 @@
|
||||
export function coreInterestingTag(key) {
|
||||
export function osmIsInterestingTag(key) {
|
||||
return key !== 'attribution' &&
|
||||
key !== 'created_by' &&
|
||||
key !== 'source' &&
|
||||
@@ -8,7 +8,7 @@ export function coreInterestingTag(key) {
|
||||
}
|
||||
|
||||
|
||||
export var coreOneWayTags = {
|
||||
export var osmOneWayTags = {
|
||||
'aerialway': {
|
||||
'chair_lift': true,
|
||||
'mixed_lift': true,
|
||||
@@ -41,7 +41,7 @@ export var coreOneWayTags = {
|
||||
};
|
||||
|
||||
|
||||
export var corePavedTags = {
|
||||
export var osmPavedTags = {
|
||||
'surface': {
|
||||
'paved': true,
|
||||
'asphalt': true,
|
||||
@@ -1,26 +1,26 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { geoExtent, geoCross } from '../geo/index';
|
||||
import { coreEntity } from './entity';
|
||||
import { coreOneWayTags } from './tags';
|
||||
import { areaKeys } from './context';
|
||||
import { osmEntity } from './entity';
|
||||
import { osmOneWayTags } from './tags';
|
||||
import { areaKeys } from '../core/context';
|
||||
|
||||
|
||||
export function coreWay() {
|
||||
if (!(this instanceof coreWay)) {
|
||||
return (new coreWay()).initialize(arguments);
|
||||
export function osmWay() {
|
||||
if (!(this instanceof osmWay)) {
|
||||
return (new osmWay()).initialize(arguments);
|
||||
} else if (arguments.length) {
|
||||
this.initialize(arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
coreEntity.way = coreWay;
|
||||
osmEntity.way = osmWay;
|
||||
|
||||
coreWay.prototype = Object.create(coreEntity.prototype);
|
||||
osmWay.prototype = Object.create(osmEntity.prototype);
|
||||
|
||||
|
||||
_.extend(coreWay.prototype, {
|
||||
_.extend(osmWay.prototype, {
|
||||
type: 'way',
|
||||
nodes: [],
|
||||
|
||||
@@ -29,7 +29,7 @@ _.extend(coreWay.prototype, {
|
||||
if (copies[this.id])
|
||||
return copies[this.id];
|
||||
|
||||
var copy = coreEntity.prototype.copy.call(this, resolver, copies);
|
||||
var copy = osmEntity.prototype.copy.call(this, resolver, copies);
|
||||
|
||||
var nodes = this.nodes.map(function(id) {
|
||||
return resolver.entity(id).copy(resolver, copies).id;
|
||||
@@ -108,7 +108,7 @@ _.extend(coreWay.prototype, {
|
||||
|
||||
// implied oneway tag..
|
||||
for (var key in this.tags) {
|
||||
if (key in coreOneWayTags && (this.tags[key] in coreOneWayTags[key]))
|
||||
if (key in osmOneWayTags && (this.tags[key] in osmOneWayTags[key]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -466,7 +466,7 @@ _.extend(coreWay.prototype, {
|
||||
'@id': this.osmId(),
|
||||
'@version': this.version || 0,
|
||||
nd: _.map(this.nodes, function(id) {
|
||||
return { keyAttributes: { ref: coreEntity.id.toOSM(id) } };
|
||||
return { keyAttributes: { ref: osmEntity.id.toOSM(id) } };
|
||||
}),
|
||||
tag: _.map(this.tags, function(v, k) {
|
||||
return { keyAttributes: { k: k, v: v } };
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { utilRebind } from '../util/rebind';
|
||||
import { coreEntity } from '../core/index';
|
||||
|
||||
|
||||
export function rendererFeatures(context) {
|
||||
@@ -293,7 +293,7 @@ export function rendererFeatures(context) {
|
||||
|
||||
|
||||
features.clearEntity = function(entity) {
|
||||
delete _cache[coreEntity.key(entity)];
|
||||
delete _cache[osmEntity.key(entity)];
|
||||
};
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ export function rendererFeatures(context) {
|
||||
features.getMatches = function(entity, resolver, geometry) {
|
||||
if (geometry === 'vertex' || geometry === 'relation') return {};
|
||||
|
||||
var ent = coreEntity.key(entity);
|
||||
var ent = osmEntity.key(entity);
|
||||
if (!_cache[ent]) {
|
||||
_cache[ent] = {};
|
||||
}
|
||||
@@ -331,7 +331,7 @@ export function rendererFeatures(context) {
|
||||
if (entity.type === 'way') {
|
||||
var parents = features.getParents(entity, resolver, geometry);
|
||||
if (parents.length === 1 && parents[0].isMultipolygon()) {
|
||||
var pkey = coreEntity.key(parents[0]);
|
||||
var pkey = osmEntity.key(parents[0]);
|
||||
if (_cache[pkey] && _cache[pkey].matches) {
|
||||
matches = _.clone(_cache[pkey].matches);
|
||||
continue;
|
||||
@@ -354,7 +354,7 @@ export function rendererFeatures(context) {
|
||||
features.getParents = function(entity, resolver, geometry) {
|
||||
if (geometry === 'point') return [];
|
||||
|
||||
var ent = coreEntity.key(entity);
|
||||
var ent = osmEntity.key(entity);
|
||||
if (!_cache[ent]) {
|
||||
_cache[ent] = {};
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import { svgPath, svgTagClasses } from './index';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { geoIsSimpleMultipolygonOuterMember } from '../geo/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { svgPath, svgTagClasses } from './index';
|
||||
|
||||
|
||||
export function svgAreas(projection, context) {
|
||||
@@ -76,7 +76,7 @@ export function svgAreas(projection, context) {
|
||||
|
||||
var clipPaths = context.surface().selectAll('defs').selectAll('.clipPath')
|
||||
.filter(filter)
|
||||
.data(data.clip, coreEntity.key);
|
||||
.data(data.clip, osmEntity.key);
|
||||
|
||||
clipPaths.exit()
|
||||
.remove();
|
||||
@@ -108,7 +108,7 @@ export function svgAreas(projection, context) {
|
||||
var paths = areagroup
|
||||
.selectAll('path')
|
||||
.filter(filter)
|
||||
.data(function(layer) { return data[layer]; }, coreEntity.key);
|
||||
.data(function(layer) { return data[layer]; }, osmEntity.key);
|
||||
|
||||
// Remove exiting areas first, so they aren't included in the `fills`
|
||||
// array used for sorting below (https://github.com/openstreetmap/iD/issues/1903).
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as d3 from 'd3';
|
||||
import _ from 'lodash';
|
||||
import rbush from 'rbush';
|
||||
import { utilDisplayName, utilGetStyle } from '../util/index';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { geoPathLength } from '../geo/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { utilDisplayName, utilGetStyle } from '../util/index';
|
||||
|
||||
|
||||
export function svgLabels(projection, context) {
|
||||
@@ -104,7 +104,7 @@ export function svgLabels(projection, context) {
|
||||
function drawLinePaths(selection, entities, filter, classes, labels) {
|
||||
var paths = selection.selectAll('path')
|
||||
.filter(filter)
|
||||
.data(entities, coreEntity.key);
|
||||
.data(entities, osmEntity.key);
|
||||
|
||||
paths.exit()
|
||||
.remove();
|
||||
@@ -122,7 +122,7 @@ export function svgLabels(projection, context) {
|
||||
function drawLineLabels(selection, entities, filter, classes, labels) {
|
||||
var texts = selection.selectAll('text.' + classes)
|
||||
.filter(filter)
|
||||
.data(entities, coreEntity.key);
|
||||
.data(entities, osmEntity.key);
|
||||
|
||||
texts.exit()
|
||||
.remove();
|
||||
@@ -137,7 +137,7 @@ export function svgLabels(projection, context) {
|
||||
|
||||
texts.selectAll('.textpath')
|
||||
.filter(filter)
|
||||
.data(entities, coreEntity.key)
|
||||
.data(entities, osmEntity.key)
|
||||
.attr('startOffset', '50%')
|
||||
.attr('xlink:href', function(d) { return '#labelpath-' + d.id; })
|
||||
.text(utilDisplayName);
|
||||
@@ -147,7 +147,7 @@ export function svgLabels(projection, context) {
|
||||
function drawPointLabels(selection, entities, filter, classes, labels) {
|
||||
var texts = selection.selectAll('text.' + classes)
|
||||
.filter(filter)
|
||||
.data(entities, coreEntity.key);
|
||||
.data(entities, osmEntity.key);
|
||||
|
||||
texts.exit()
|
||||
.remove();
|
||||
@@ -184,7 +184,7 @@ export function svgLabels(projection, context) {
|
||||
function drawAreaIcons(selection, entities, filter, classes, labels) {
|
||||
var icons = selection.selectAll('use')
|
||||
.filter(filter)
|
||||
.data(entities, coreEntity.key);
|
||||
.data(entities, osmEntity.key);
|
||||
|
||||
icons.exit()
|
||||
.remove();
|
||||
|
||||
@@ -7,9 +7,9 @@ import {
|
||||
svgTagClasses
|
||||
} from './index';
|
||||
|
||||
import { utilDetect } from '../util/detect';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { geoSimpleMultipolygonOuterMember } from '../geo/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { utilDetect } from '../util/detect';
|
||||
|
||||
|
||||
export function svgLines(projection) {
|
||||
@@ -90,14 +90,14 @@ export function svgLines(projection) {
|
||||
.filter(filter)
|
||||
.data(
|
||||
function() { return pathdata[this.parentNode.__data__] || []; },
|
||||
coreEntity.key
|
||||
osmEntity.key
|
||||
);
|
||||
|
||||
lines.exit()
|
||||
.remove();
|
||||
|
||||
// Optimization: call simple TagClasses only on enter selection. This
|
||||
// works because coreEntity.key is defined to include the entity v attribute.
|
||||
// works because osmEntity.key is defined to include the entity v attribute.
|
||||
lines.enter()
|
||||
.append('path')
|
||||
.attr('class', function(d) { return 'way line ' + this.parentNode.__data__ + ' ' + d.id; })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { svgPointTransform, svgTagClasses } from './index';
|
||||
import { coreEntity } from '../core/index';
|
||||
|
||||
|
||||
export function svgPoints(projection, context) {
|
||||
@@ -29,7 +29,7 @@ export function svgPoints(projection, context) {
|
||||
|
||||
var groups = layer.selectAll('g.point')
|
||||
.filter(filter)
|
||||
.data(points, coreEntity.key);
|
||||
.data(points, osmEntity.key);
|
||||
|
||||
groups.exit()
|
||||
.remove();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as d3 from 'd3';
|
||||
import { corePavedTags } from '../core/tags';
|
||||
import { osmPavedTags } from '../osm/tags';
|
||||
|
||||
|
||||
export function svgTagClasses() {
|
||||
@@ -89,8 +89,8 @@ export function svgTagClasses() {
|
||||
var paved = (t.highway !== 'track');
|
||||
for (k in t) {
|
||||
v = t[k];
|
||||
if (k in corePavedTags) {
|
||||
paved = !!corePavedTags[k][v];
|
||||
if (k in osmPavedTags) {
|
||||
paved = !!osmPavedTags[k][v];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as d3 from 'd3';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { svgPointTransform } from './index';
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ export function svgVertices(projection, context) {
|
||||
z = (zoom < 17 ? 0 : zoom < 18 ? 1 : 2);
|
||||
|
||||
var groups = selection
|
||||
.data(vertices, coreEntity.key);
|
||||
.data(vertices, osmEntity.key);
|
||||
|
||||
groups.exit()
|
||||
.remove();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as d3 from 'd3';
|
||||
import * as sexagesimal from 'sexagesimal';
|
||||
import { t } from '../util/locale';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { geoExtent, geoChooseEdge } from '../geo/index';
|
||||
import { modeSelect } from '../modes/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { utilDisplayName, utilEntityOrMemberSelector } from '../util/index';
|
||||
|
||||
@@ -134,7 +134,7 @@ export function uiFeatureList(context) {
|
||||
// https://github.com/openstreetmap/iD/issues/1890
|
||||
if (d.osm_type && d.osm_id) {
|
||||
result.push({
|
||||
id: coreEntity.id.fromOSM(d.osm_type, d.osm_id),
|
||||
id: osmEntity.id.fromOSM(d.osm_type, d.osm_id),
|
||||
geometry: d.osm_type === 'relation' ? 'relation' : d.osm_type === 'way' ? 'line' : 'point',
|
||||
type: d.type !== 'yes' ? (d.type.charAt(0).toUpperCase() + d.type.slice(1)).replace('_', ' ')
|
||||
: (d.class.charAt(0).toUpperCase() + d.class.slice(1)).replace('_', ' '),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as d3 from 'd3';
|
||||
import { utilRebind } from '../../util/rebind';
|
||||
import { t } from '../../util/locale';
|
||||
import { coreOneWayTags } from '../../core/index';
|
||||
import { osmOneWayTags } from '../../osm/index';
|
||||
|
||||
export { uiFieldCheck as uiFieldDefaultcheck };
|
||||
|
||||
@@ -36,7 +36,7 @@ export function uiFieldCheck(field) {
|
||||
// where implied oneway tag exists (e.g. `junction=roundabout`) #2220, #1841
|
||||
if (field.id === 'oneway') {
|
||||
for (var key in entity.tags) {
|
||||
if (key in coreOneWayTags && (entity.tags[key] in coreOneWayTags[key])) {
|
||||
if (key in osmOneWayTags && (entity.tags[key] in osmOneWayTags[key])) {
|
||||
texts[0] = t('presets.fields.oneway_yes.options.undefined');
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as d3 from 'd3';
|
||||
import { t } from '../../util/locale';
|
||||
|
||||
import { behaviorHover } from '../../behavior/index';
|
||||
import { coreEntity } from '../../core/index';
|
||||
import { osmEntity } from '../../osm/index';
|
||||
|
||||
import {
|
||||
actionRestrictTurn,
|
||||
@@ -128,7 +128,7 @@ export function uiFieldRestrictions(field, context) {
|
||||
|
||||
function click() {
|
||||
var datum = d3.event.target.__data__;
|
||||
if (datum instanceof coreEntity) {
|
||||
if (datum instanceof osmEntity) {
|
||||
fromNodeID = intersection.adjacentNodeId(datum.id);
|
||||
render();
|
||||
} else if (datum instanceof geoTurn) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import * as d3 from 'd3';
|
||||
import { t } from '../../util/locale';
|
||||
import { coreEntity, coreGraph } from '../../core/index';
|
||||
import { coreGraph } from '../../core/graph';
|
||||
import { modeBrowse } from '../../modes/index';
|
||||
import { osmEntity } from '../../osm/entity';
|
||||
import { d3curtain } from '../../util/curtain';
|
||||
import { default as introGraphRaw } from '../../../data/intro_graph.json';
|
||||
|
||||
@@ -76,7 +77,7 @@ export function uiIntro(context) {
|
||||
var introGraph = {};
|
||||
|
||||
for (var key in introGraphRaw) {
|
||||
introGraph[key] = coreEntity(introGraphRaw[key]);
|
||||
introGraph[key] = osmEntity(introGraphRaw[key]);
|
||||
var name = localizedName(key);
|
||||
if (name) {
|
||||
introGraph[key].tags.name = name;
|
||||
|
||||
@@ -2,8 +2,8 @@ import * as d3 from 'd3';
|
||||
import { d3combobox } from '../lib/d3.combobox.js';
|
||||
import { t } from '../util/locale';
|
||||
import { actionChangeMember, actionDeleteMember } from '../actions/index';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { modeBrowse, modeSelect } from '../modes/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { uiDisclosure } from './disclosure';
|
||||
import { utilDisplayName } from '../util/index';
|
||||
@@ -81,8 +81,8 @@ export function uiRawMemberEditor(context) {
|
||||
|
||||
var items = list.selectAll('li')
|
||||
.data(memberships, function(d) {
|
||||
return coreEntity.key(d.relation) + ',' + d.index + ',' +
|
||||
(d.member ? coreEntity.key(d.member) : 'incomplete');
|
||||
return osmEntity.key(d.relation) + ',' + d.index + ',' +
|
||||
(d.member ? osmEntity.key(d.member) : 'incomplete');
|
||||
});
|
||||
|
||||
items.exit()
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
actionDeleteMember
|
||||
} from '../actions/index';
|
||||
|
||||
import { coreEntity, coreRelation } from '../core/index';
|
||||
import { modeSelect } from '../modes/index';
|
||||
import { osmEntity, osmRelation } from '../osm/index';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { uiDisclosure } from './disclosure';
|
||||
import { utilDisplayName } from '../util/index';
|
||||
@@ -46,7 +46,7 @@ export function uiRawMembershipEditor(context) {
|
||||
);
|
||||
|
||||
} else {
|
||||
var relation = coreRelation();
|
||||
var relation = osmRelation();
|
||||
context.perform(
|
||||
actionAddEntity(relation),
|
||||
actionAddMember(relation.id, { id: id, type: context.entity(id).type, role: role }),
|
||||
@@ -92,7 +92,7 @@ export function uiRawMembershipEditor(context) {
|
||||
});
|
||||
|
||||
result.sort(function(a, b) {
|
||||
return coreRelation.creationOrder(a.relation, b.relation);
|
||||
return osmRelation.creationOrder(a.relation, b.relation);
|
||||
});
|
||||
|
||||
// Dedupe identical names by appending relation id - see #2891
|
||||
@@ -151,7 +151,7 @@ export function uiRawMembershipEditor(context) {
|
||||
|
||||
var items = list.selectAll('li.member-row-normal')
|
||||
.data(memberships, function(d) {
|
||||
return coreEntity.key(d.relation) + ',' + d.index;
|
||||
return osmEntity.key(d.relation) + ',' + d.index;
|
||||
});
|
||||
|
||||
items.exit()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as d3 from 'd3';
|
||||
import { t } from '../util/locale';
|
||||
import { coreEntity } from '../core/index';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { modeSelect } from '../modes/index';
|
||||
import { osmEntity } from '../osm/index';
|
||||
import { svgIcon } from '../svg/index';
|
||||
import { utilDisplayName } from '../util/index';
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ export function uiSelectionList(context, selectedIDs) {
|
||||
.filter(function(entity) { return entity; });
|
||||
|
||||
var items = list.selectAll('.feature-list-item')
|
||||
.data(entities, coreEntity.key);
|
||||
.data(entities, osmEntity.key);
|
||||
|
||||
items.exit()
|
||||
.remove();
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "iD",
|
||||
"version": "2.0.0-alpha.1",
|
||||
"version": "2.0.0-alpha.2",
|
||||
"description": "A friendly editor for OpenStreetMap",
|
||||
"main": "iD.js",
|
||||
"directories": {
|
||||
|
||||
+6
-6
@@ -28,8 +28,6 @@
|
||||
<script src='spec/spec_helpers.js'></script>
|
||||
|
||||
<!-- include spec files below... -->
|
||||
<script src='spec/id.js'></script>
|
||||
|
||||
<script src='spec/actions/add_entity.js'></script>
|
||||
<script src='spec/actions/add_member.js'></script>
|
||||
<script src='spec/actions/add_midpoint.js'></script>
|
||||
@@ -67,14 +65,11 @@
|
||||
<script src='spec/behavior/lasso.js'></script>
|
||||
|
||||
<script src='spec/core/connection.js'></script>
|
||||
<script src='spec/core/context.js'></script>
|
||||
<script src='spec/core/difference.js'></script>
|
||||
<script src='spec/core/entity.js'></script>
|
||||
<script src='spec/core/graph.js'></script>
|
||||
<script src='spec/core/history.js'></script>
|
||||
<script src='spec/core/node.js'></script>
|
||||
<script src='spec/core/relation.js'></script>
|
||||
<script src='spec/core/tree.js'></script>
|
||||
<script src='spec/core/way.js'></script>
|
||||
|
||||
<script src='spec/geo/extent.js'></script>
|
||||
<script src='spec/geo/geo.js'></script>
|
||||
@@ -88,6 +83,11 @@
|
||||
|
||||
<script src='spec/modes/add_point.js'></script>
|
||||
|
||||
<script src='spec/osm/entity.js'></script>
|
||||
<script src='spec/osm/node.js'></script>
|
||||
<script src='spec/osm/relation.js'></script>
|
||||
<script src='spec/osm/way.js'></script>
|
||||
|
||||
<script src='spec/presets/category.js'></script>
|
||||
<script src='spec/presets/collection.js'></script>
|
||||
<script src='spec/presets/init.js'></script>
|
||||
|
||||
+5
-4
@@ -15,12 +15,13 @@
|
||||
<script src='../js/lib/id/svg.js'></script>
|
||||
<script src='../js/lib/id/util.js'></script>
|
||||
|
||||
<script src='../js/id/core/entity.js'></script>
|
||||
<script src='../js/id/core/graph.js'></script>
|
||||
<script src='../js/id/core/history.js'></script>
|
||||
<script src='../js/id/core/node.js'></script>
|
||||
<script src='../js/id/core/relation.js'></script>
|
||||
<script src='../js/id/core/way.js'></script>
|
||||
|
||||
<script src='../js/id/osm/entity.js'></script>
|
||||
<script src='../js/id/osm/node.js'></script>
|
||||
<script src='../js/id/osm/relation.js'></script>
|
||||
<script src='../js/id/osm/way.js'></script>
|
||||
|
||||
<form style='position: fixed; right: 10px; bottom: 10px'>
|
||||
<input id='background-color' type='range' min='0' max='255' value='255'>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* global locale: true */
|
||||
/* eslint no-console: 0 */
|
||||
describe('iD.actionMergeRemoteChanges', function () {
|
||||
var base = iD.Graph([
|
||||
iD.Node({id: 'a', loc: [1, 1], version: '1', tags: {foo: 'foo'}}),
|
||||
@@ -55,36 +53,8 @@ describe('iD.actionMergeRemoteChanges', function () {
|
||||
nodes: ['s1', 's2', 's3', 's4', 's1'],
|
||||
version: '1',
|
||||
tags: {foo: 'foo_new', area: 'yes'}
|
||||
}),
|
||||
});
|
||||
|
||||
saved, error;
|
||||
|
||||
// setup mock locale object..
|
||||
beforeEach(function() {
|
||||
saved = locale;
|
||||
error = console.error;
|
||||
console.error = function () {};
|
||||
locale = {
|
||||
_current: 'en',
|
||||
en: {
|
||||
'merge_remote_changes': {
|
||||
'annotation': 'Merged remote changes from server.',
|
||||
'conflict': {
|
||||
'deleted': 'This object has been deleted by {user}.',
|
||||
'location': 'This object was moved by both you and {user}.',
|
||||
'nodelist': 'Nodes were changed by both you and {user}.',
|
||||
'memberlist': 'Relation members were changed by both you and {user}.',
|
||||
'tags': 'You changed the <b>{tag}</b> tag to \"{local}\" and {user} changed it to \"{remote}\".'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
locale = saved;
|
||||
console.error = error;
|
||||
});
|
||||
|
||||
function makeGraph(entities) {
|
||||
return _.reduce(entities, function(graph, entity) {
|
||||
@@ -92,6 +62,7 @@ describe('iD.actionMergeRemoteChanges', function () {
|
||||
}, iD.Graph(base));
|
||||
}
|
||||
|
||||
|
||||
describe('non-destuctive merging', function () {
|
||||
describe('tags', function() {
|
||||
it('doesn\'t merge tags if conflict (local change, remote change)', function () {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
describe('iD', function() {
|
||||
describe('iD.Context', function() {
|
||||
var assets = {
|
||||
'iD/img/loader.gif': '/assets/iD/img/loader-b66184b5c4afbccc25f.gif'
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
/* globals chai:false */
|
||||
|
||||
// iD.debug = true;
|
||||
iD.debug = true;
|
||||
|
||||
mocha.setup({
|
||||
ui: 'bdd',
|
||||
|
||||
Reference in New Issue
Block a user