Move Entity subclasses to separate files

This commit is contained in:
John Firebaugh
2012-12-28 22:17:09 -08:00
parent 31502c6214
commit f7dfda46b2
6 changed files with 41 additions and 36 deletions

View File

@@ -85,6 +85,10 @@
<script src='js/id/graph/entity.js'></script>
<script src='js/id/graph/graph.js'></script>
<script src='js/id/graph/history.js'></script>
<script src='js/id/graph/node.js'></script>
<script src='js/id/graph/relation.js'></script>
<script src='js/id/graph/way.js'></script>
<script src='js/id/connection.js'></script>
</head>
<body>

View File

@@ -119,39 +119,3 @@ iD.Entity.extend = function(properties) {
return Subclass;
};
iD.Node = iD.Entity.extend({
type: "node"
});
iD.Way = iD.Entity.extend({
type: "way",
nodes: [],
isOneWay: function() {
return this.tags.oneway === 'yes';
},
isClosed: function() {
return this.nodes.length > 0 && this.nodes[this.nodes.length - 1] === this.nodes[0];
},
// a way is an area if:
//
// - area=yes
// - closed and
// - doesn't have area=no
// - doesn't have highway tag
isArea: function() {
return this.tags.area === 'yes' ||
(this.isClosed() &&
this.tags.area !== 'no' &&
!this.tags.highway &&
!this.tags.barrier);
}
});
iD.Relation = iD.Entity.extend({
type: "relation",
members: []
});

3
js/id/graph/node.js Normal file
View File

@@ -0,0 +1,3 @@
iD.Node = iD.Entity.extend({
type: "node"
});

4
js/id/graph/relation.js Normal file
View File

@@ -0,0 +1,4 @@
iD.Relation = iD.Entity.extend({
type: "relation",
members: []
});

26
js/id/graph/way.js Normal file
View File

@@ -0,0 +1,26 @@
iD.Way = iD.Entity.extend({
type: "way",
nodes: [],
isOneWay: function() {
return this.tags.oneway === 'yes';
},
isClosed: function() {
return this.nodes.length > 0 && this.nodes[this.nodes.length - 1] === this.nodes[0];
},
// a way is an area if:
//
// - area=yes
// - closed and
// - doesn't have area=no
// - doesn't have highway tag
isArea: function() {
return this.tags.area === 'yes' ||
(this.isClosed() &&
this.tags.area !== 'no' &&
!this.tags.highway &&
!this.tags.barrier);
}
});

View File

@@ -84,6 +84,10 @@
<script src='../js/id/graph/entity.js'></script>
<script src='../js/id/graph/graph.js'></script>
<script src='../js/id/graph/history.js'></script>
<script src='../js/id/graph/node.js'></script>
<script src='../js/id/graph/relation.js'></script>
<script src='../js/id/graph/way.js'></script>
<script src='../js/id/connection.js'></script>
<script>