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 ac2744f
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions js/router/BRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,13 @@ L.BRouter = L.Class.extend({
s += this._formatLatLng(circle.getLatLng());
s += L.BRouter.NUMBER_SEPARATOR;
s += Math.round(circle.getRadius());
if (circle.options.nogoWeight) {
var nogoWeight = (
(circle.feature && circle.feature.properties && circle.feature.properties.nogoWeight)
|| circle.options.nogoWeight
);
if (nogoWeight) {
s += L.BRouter.NUMBER_SEPARATOR;
s += circle.options.nogoWeight;
s += nogoWeight;
}
if (i < (nogos.length - 1)) {
s += L.BRouter.GROUP_SEPARATOR;
Expand Down Expand Up @@ -282,9 +286,13 @@ L.BRouter = L.Class.extend({
}
s += this._formatLatLng(vertices[j]);
}
if (polyline.options.nogoWeight) {
var nogoWeight = (
(polyline.feature && polyline.feature.properties && polyline.feature.properties.nogoWeight)
|| polyline.options.nogoWeight
);
if (nogoWeight) {
s += L.BRouter.NUMBER_SEPARATOR;
s += polyline.options.nogoWeight;
s += nogoWeight;
}
if (i < (nogos.length - 1)) {
s += L.BRouter.GROUP_SEPARATOR;
Expand Down Expand Up @@ -333,9 +341,13 @@ L.BRouter = L.Class.extend({
}
s += this._formatLatLng(vertices[j]);
}
if (polygon.options.nogoWeight) {
var nogoWeight = (
(polygon.feature && polygon.feature.properties && polygon.feature.properties.nogoWeight)
|| polygon.options.nogoWeight
);
if (nogoWeight) {
s += L.BRouter.NUMBER_SEPARATOR;
s += polygon.options.nogoWeight;
s += nogoWeight;
}
if (i < (nogos.length - 1)) {
s += L.BRouter.GROUP_SEPARATOR;
Expand Down Expand Up @@ -376,9 +388,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[0], L.BRouter.PRECISION);
s += L.BRouter.NUMBER_SEPARATOR;
s += L.Util.formatNum(latLng.lat, L.BRouter.PRECISION);
s += L.Util.formatNum(latLng.lat || latLng[1], L.BRouter.PRECISION);
return s;
}
});
Expand Down

0 comments on commit ac2744f

Please sign in to comment.