mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 01:09:22 +02:00
Documentation, and move validation type up to top of each file
This commit is contained in:
@@ -166,6 +166,15 @@ export function coreValidator(context) {
|
||||
|
||||
|
||||
export function validationIssue(attrs) {
|
||||
this.type = attrs.type; // required
|
||||
this.severity = attrs.severity; // required - 'warning' or 'error'
|
||||
this.message = attrs.message; // required - localized string
|
||||
this.tooltip = attrs.tooltip; // required - localized string
|
||||
this.entities = attrs.entities; // optional - array of entities
|
||||
this.coordinates = attrs.coordinates; // optional - expect a [lon, lat] array
|
||||
this.info = attrs.info; // optional - object containing arbitrary extra information
|
||||
this.fixes = attrs.fixes; // optional - array of validationIssueFix objects
|
||||
this.hash = attrs.hash; // optional - string to further differentiate the issue
|
||||
|
||||
// A unique, deterministic string hash.
|
||||
// Issues with identical id values are considered identical.
|
||||
@@ -189,15 +198,6 @@ export function validationIssue(attrs) {
|
||||
return id;
|
||||
};
|
||||
|
||||
this.type = attrs.type;
|
||||
this.severity = attrs.severity;
|
||||
this.message = attrs.message;
|
||||
this.tooltip = attrs.tooltip;
|
||||
this.entities = attrs.entities; // expect an array of entities
|
||||
this.coordinates = attrs.coordinates; // expect a [lon, lat] array
|
||||
this.info = attrs.info; // an object containing arbitrary extra information
|
||||
this.fixes = attrs.fixes; // expect an array of functions for possible fixes
|
||||
this.hash = attrs.hash; // an optional string to further differentiate the issue
|
||||
|
||||
this.loc = function() {
|
||||
if (this.coordinates && Array.isArray(this.coordinates) && this.coordinates.length === 2) {
|
||||
@@ -210,9 +210,8 @@ export function validationIssue(attrs) {
|
||||
}*/
|
||||
};
|
||||
|
||||
if (this.fixes) {
|
||||
if (this.fixes) { // add a reference in the fixes to the issue for use in fix actions
|
||||
for (var i = 0; i < this.fixes.length; i++) {
|
||||
// add a reference in the fix to the issue for use in fix actions
|
||||
this.fixes[i].issue = this;
|
||||
}
|
||||
}
|
||||
@@ -222,10 +221,6 @@ export function validationIssue(attrs) {
|
||||
export function validationIssueFix(attrs) {
|
||||
this.title = attrs.title;
|
||||
this.onClick = attrs.onClick;
|
||||
|
||||
// IDs of fix-specific entities. Used for hover-higlighting.
|
||||
this.entityIds = attrs.entityIds || [];
|
||||
|
||||
// the issue this fix is for
|
||||
this.issue = null;
|
||||
this.entityIds = attrs.entityIds || []; // Used for hover-higlighting.
|
||||
this.issue = null; // the issue this fix is for
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import { validationIssue, validationIssueFix } from '../core/validator';
|
||||
* Look for roads that can be connected to other roads with a short extension
|
||||
*/
|
||||
export function validationAlmostJunction() {
|
||||
var type = 'almost_junction';
|
||||
|
||||
|
||||
function isHighway(entity) {
|
||||
return entity.type === 'way' && entity.tags.highway && entity.tags.highway !== 'no';
|
||||
@@ -120,9 +122,6 @@ export function validationAlmostJunction() {
|
||||
}
|
||||
|
||||
|
||||
var type = 'almost_junction';
|
||||
|
||||
|
||||
var validation = function(endHighway, context) {
|
||||
if (!isHighway(endHighway)) return [];
|
||||
|
||||
@@ -167,7 +166,7 @@ export function validationAlmostJunction() {
|
||||
onClick: function() {
|
||||
var nodeID = this.issue.entities[1].id;
|
||||
context.perform(
|
||||
actionChangeTags(nodeID, {noexit: 'yes'}),
|
||||
actionChangeTags(nodeID, { noexit: 'yes' }),
|
||||
t('issues.fix.tag_as_disconnected.annotation')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ import { validationIssue, validationIssueFix } from '../core/validator';
|
||||
|
||||
|
||||
export function validationCrossingWays() {
|
||||
var type = 'crossing_ways';
|
||||
|
||||
|
||||
// Check if the edge going from n1 to n2 crosses (without a connection node)
|
||||
// any edge on way. Return the cross point if so.
|
||||
function findEdgeToWayCrossCoords(n1, n2, way, graph) {
|
||||
@@ -271,8 +274,6 @@ export function validationCrossingWays() {
|
||||
return edgeCrossInfos;
|
||||
}
|
||||
|
||||
var type = 'crossing_ways';
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var graph = context.graph();
|
||||
@@ -412,5 +413,6 @@ export function validationCrossingWays() {
|
||||
|
||||
validation.type = type;
|
||||
|
||||
|
||||
return validation;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import { utilDisplayLabel, utilTagText } from '../util';
|
||||
import { validationIssue, validationIssueFix } from '../core/validator';
|
||||
|
||||
export function validationDeprecatedTag() {
|
||||
|
||||
var type = 'deprecated_tag';
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var issues = [];
|
||||
var deprecatedTagsArray = entity.deprecatedTags();
|
||||
|
||||
@@ -6,6 +6,8 @@ import { validationIssue, validationIssueFix } from '../core/validator';
|
||||
|
||||
|
||||
export function validationDisconnectedWay() {
|
||||
var type = 'disconnected_way';
|
||||
|
||||
|
||||
function isDisconnectedHighway(entity, graph) {
|
||||
if (!entity.tags.highway) return false;
|
||||
@@ -25,7 +27,6 @@ export function validationDisconnectedWay() {
|
||||
});
|
||||
}
|
||||
|
||||
var type = 'disconnected_way';
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var issues = [];
|
||||
|
||||
@@ -7,6 +7,8 @@ import { discardNames } from '../../node_modules/name-suggestion-index/config/fi
|
||||
|
||||
|
||||
export function validationGenericName(context) {
|
||||
var type = 'generic_name';
|
||||
|
||||
|
||||
function isGenericName(entity) {
|
||||
var name = entity.tags.name;
|
||||
@@ -34,7 +36,6 @@ export function validationGenericName(context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var type = 'generic_name';
|
||||
|
||||
var validation = function(entity) {
|
||||
var issues = [];
|
||||
|
||||
@@ -2,6 +2,9 @@ import { services } from '../services';
|
||||
|
||||
|
||||
export function validationMaprules() {
|
||||
validation.type = 'maprules';
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
if (!services.maprules) return [];
|
||||
|
||||
@@ -18,7 +21,6 @@ export function validationMaprules() {
|
||||
return issues;
|
||||
};
|
||||
|
||||
validation.type = 'maprules';
|
||||
|
||||
return validation;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import { validationIssue, validationIssueFix } from '../core/validator';
|
||||
|
||||
|
||||
export function validationMissingTag() {
|
||||
var type = 'missing_tag';
|
||||
|
||||
|
||||
function hasDescriptiveTags(entity) {
|
||||
var keys = _without(Object.keys(entity.tags), 'area', 'name').filter(osmIsInterestingTag);
|
||||
@@ -18,7 +20,6 @@ export function validationMissingTag() {
|
||||
return keys.length > 0;
|
||||
}
|
||||
|
||||
var type = 'missing_tag';
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var graph = context.graph();
|
||||
@@ -52,7 +53,7 @@ export function validationMissingTag() {
|
||||
type: type,
|
||||
// error if created or modified, else warning
|
||||
severity: !entity.version || entity.v ? 'error' : 'warning',
|
||||
message: t('issues.missing_tag.'+missingTagType+'.message', messageObj),
|
||||
message: t('issues.missing_tag.' + missingTagType + '.message', messageObj),
|
||||
tooltip: t('issues.missing_tag.tip'),
|
||||
entities: [entity],
|
||||
fixes: [
|
||||
|
||||
@@ -10,6 +10,7 @@ import { validationIssue, validationIssueFix } from '../core/validator';
|
||||
export function validationTagSuggestsArea() {
|
||||
var type = 'tag_suggests_area';
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
if (entity.type !== 'way') return [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user