Refactor Entity, Node, Relation, Tags, Way from core to osm

This commit is contained in:
Bryan Housel
2016-10-11 22:41:24 -04:00
parent fd742518c6
commit 07fa5fcc34
52 changed files with 215 additions and 239 deletions
+2 -2
View File
@@ -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('_', ' '),
+2 -2
View File
@@ -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 -2
View File
@@ -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) {
+3 -2
View File
@@ -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;
+3 -3
View File
@@ -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()
+4 -4
View File
@@ -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()
+3 -3
View File
@@ -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();