Skip to content

Commit e43f883

Browse files
PeterNerlichBuckarooBanzay
authored andcommitted
fix metadata access and pos processing
1 parent 315cb79 commit e43f883

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

mapobject/train.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ func (this *TrainBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock)
1616
o.Attributes["index"] = md["index"]
1717
o.Attributes["owner"] = md["owner"]
1818
o.Attributes["color"] = md["color"]
19+
o.Attributes["rail_pos"] = md["rail_pos"]
20+
o.Attributes["linepath_from_prv"] = md["linepath_from_prv"]
1921

2022
return o
2123
}

public/js/map/overlays/TrainlineOverlay.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var string_to_pos = function(str){
55
if (typeof(str) == "string" && str.length > 0 &&
66
str[0] == '(' && str[str.length-1] == ')') {
77
var a = str.slice(1, -1).split(',');
8+
a = a.map(parseFloat);
89
if (a.length == 3 && a.indexOf(NaN) < 0) {
910
return {
1011
x: a[0],
@@ -114,7 +115,7 @@ export default AbstractGeoJsonOverlay.extend({
114115
if (pos == null) {
115116
console.warn("[Trainlines][linepath_from_prv]", "line "+linename, "block "+pos_to_string(entry), "index "+entry.attributes.index, "Invalid point:", p);
116117
} else {
117-
feat.coords.push([p.x, p.z]);
118+
feat.coords.push([pos.x, pos.z]);
118119
}
119120
});
120121
} else if (rail_pos) {
@@ -134,7 +135,7 @@ export default AbstractGeoJsonOverlay.extend({
134135
},
135136
"geometry": {
136137
"type": "Point",
137-
"coordinates": [entry.x, entry.z]
138+
"coordinates": feat.coords[feat.coords.length-1]
138139
}
139140
});
140141
}

0 commit comments

Comments
 (0)