Skip to content

Commit

Permalink
Fix for a few errors when loading nogos with weight
Browse files Browse the repository at this point in the history
* Nogo weight was not set when loading nogos with a default weight
value.
* The URL would show up "NaN" values upon reloading the web interface
after having loaded some nogos.

Fix nrenner#174.
  • Loading branch information
Phyks committed May 9, 2019
1 parent 5f89287 commit faaca27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@

var geoJSON = L.geoJson(turf.featureCollection(cleanedGeoJSONFeatures), {
onEachFeature: function (feature, layer) {
if (!feature.properties.nogoWeight) {
feature.properties.nogoWeight = nogoWeight;
if (!feature.properties.nogoWeight && nogoWeight != -1) {
layer.options.nogoWeight = feature.properties.nogoWeight || nogoWeight;
}
}
});
Expand Down
10 changes: 5 additions & 5 deletions js/router/BRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ L.BRouter = L.Class.extend({
s += this._formatLatLng(circle.getLatLng());
s += L.BRouter.NUMBER_SEPARATOR;
s += Math.round(circle.getRadius());
if (circle.options.nogoWeight) {
if (circle.options.nogoWeight != null) {
s += L.BRouter.NUMBER_SEPARATOR;
s += circle.options.nogoWeight;
}
Expand Down Expand Up @@ -282,7 +282,7 @@ L.BRouter = L.Class.extend({
}
s += this._formatLatLng(vertices[j]);
}
if (polyline.options.nogoWeight) {
if (polyline.options.nogoWeight != null) {
s += L.BRouter.NUMBER_SEPARATOR;
s += polyline.options.nogoWeight;
}
Expand Down Expand Up @@ -333,7 +333,7 @@ L.BRouter = L.Class.extend({
}
s += this._formatLatLng(vertices[j]);
}
if (polygon.options.nogoWeight) {
if (polygon.options.nogoWeight != null) {
s += L.BRouter.NUMBER_SEPARATOR;
s += polygon.options.nogoWeight;
}
Expand Down Expand Up @@ -376,9 +376,9 @@ L.BRouter = L.Class.extend({
// formats L.LatLng object as lng,lat string
_formatLatLng: function(latLng) {
var s = '';
s += L.Util.formatNum(latLng.lng, L.BRouter.PRECISION);
s += L.Util.formatNum(latLng.lng || latLng[1], L.BRouter.PRECISION);
s += L.BRouter.NUMBER_SEPARATOR;
s += L.Util.formatNum(latLng.lat, L.BRouter.PRECISION);
s += L.Util.formatNum(latLng.lat || latLng[0], L.BRouter.PRECISION);
return s;
}
});
Expand Down

0 comments on commit faaca27

Please sign in to comment.