1
0
forked from MTSR/mapserver

fix metadata access and pos processing

This commit is contained in:
Peter Nerlich 2022-01-16 04:01:52 +01:00 committed by Buckaroo Banzai
parent 315cb79d4e
commit e43f883f7d
2 changed files with 5 additions and 2 deletions

View File

@ -16,6 +16,8 @@ func (this *TrainBlock) onMapObject(x, y, z int, block *mapblockparser.MapBlock)
o.Attributes["index"] = md["index"] o.Attributes["index"] = md["index"]
o.Attributes["owner"] = md["owner"] o.Attributes["owner"] = md["owner"]
o.Attributes["color"] = md["color"] o.Attributes["color"] = md["color"]
o.Attributes["rail_pos"] = md["rail_pos"]
o.Attributes["linepath_from_prv"] = md["linepath_from_prv"]
return o return o
} }

View File

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