From fd1d2f006b4d6ab27b4f9a99f6dddaf89630115f Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 29 Jun 2018 22:39:40 -0400 Subject: [PATCH] Fix the osmNote initializer --- modules/osm/note.js | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/modules/osm/note.js b/modules/osm/note.js index c83ce950f..135d7e599 100644 --- a/modules/osm/note.js +++ b/modules/osm/note.js @@ -1,18 +1,25 @@ import _extend from 'lodash-es/extend'; -import { osmEntity } from './entity'; import { geoExtent } from '../geo'; -import { debug } from '../index'; - export function osmNote() { - if (!(this instanceof osmNote)) return; - - this.initialize(arguments); - return this; + if (!(this instanceof osmNote)) { + return (new osmNote()).initialize(arguments); + } else if (arguments.length) { + this.initialize(arguments); + } } + +osmNote.id = function() { + return osmNote.id.next--; +}; + + +osmNote.id.next = -1; + + _extend(osmNote.prototype, { type: 'note', @@ -31,20 +38,8 @@ _extend(osmNote.prototype, { } } - if (!this.id && this.type) { - this.id = osmEntity.id(this.type); - } - if (!this.hasOwnProperty('visible')) { - this.visible = true; - } - - if (debug) { - Object.freeze(this); - Object.freeze(this.tags); - - if (this.loc) Object.freeze(this.loc); - if (this.nodes) Object.freeze(this.nodes); - if (this.members) Object.freeze(this.members); + if (!this.id) { + this.id = osmNote.id(); } return this; @@ -54,12 +49,6 @@ _extend(osmNote.prototype, { return new geoExtent(this.loc); }, - geometry: function(graph) { - return graph.transient(this, 'geometry', function() { - return graph.isPoi(this) ? 'point' : 'vertex'; - }); - }, - getID: function() { return this.id; }, @@ -71,4 +60,4 @@ _extend(osmNote.prototype, { getComments: function() { return this.comments; } -}); \ No newline at end of file +});