Skip to content

Commit

Permalink
Fix the osmNote initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
bhousel committed Jun 30, 2018
1 parent d034691 commit fd1d2f0
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions modules/osm/note.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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;
Expand All @@ -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;
},
Expand All @@ -71,4 +60,4 @@ _extend(osmNote.prototype, {
getComments: function() {
return this.comments;
}
});
});

1 comment on commit fd1d2f0

@thomas-hervey
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @bhousel for the cleanup!

Please sign in to comment.