Skip to content

Commit

Permalink
fix metadata access and pos processing
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterNerlich authored and BuckarooBanzay committed Jan 21, 2022
1 parent 315cb79 commit e43f883
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions mapobject/train.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func (this *TrainBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock)
o.Attributes["index"] = md["index"]
o.Attributes["owner"] = md["owner"]
o.Attributes["color"] = md["color"]
o.Attributes["rail_pos"] = md["rail_pos"]
o.Attributes["linepath_from_prv"] = md["linepath_from_prv"]

return o
}
5 changes: 3 additions & 2 deletions public/js/map/overlays/TrainlineOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var string_to_pos = function(str){
if (typeof(str) == "string" && str.length > 0 &&
str[0] == '(' && str[str.length-1] == ')') {
var a = str.slice(1, -1).split(',');
a = a.map(parseFloat);
if (a.length == 3 && a.indexOf(NaN) < 0) {
return {
x: a[0],
Expand Down Expand Up @@ -114,7 +115,7 @@ export default AbstractGeoJsonOverlay.extend({
if (pos == null) {
console.warn("[Trainlines][linepath_from_prv]", "line "+linename, "block "+pos_to_string(entry), "index "+entry.attributes.index, "Invalid point:", p);
} else {
feat.coords.push([p.x, p.z]);
feat.coords.push([pos.x, pos.z]);
}
});
} else if (rail_pos) {
Expand All @@ -134,7 +135,7 @@ export default AbstractGeoJsonOverlay.extend({
},
"geometry": {
"type": "Point",
"coordinates": [entry.x, entry.z]
"coordinates": feat.coords[feat.coords.length-1]
}
});
}
Expand Down

0 comments on commit e43f883

Please sign in to comment.