Changes

From Wazeopedia

Talk:Bookmarklets

299 bytes added, 5 years ago
Set segment locks in area: Update code
/* value used is -1 from rank visible in WME */
/* fwy_lvl = 3 would appear locked at 4 in WME */
/* can set locks to be null, which will use the auto-lock */
var fwy_lvl = 3;
var rmp_lvl = 3;
var absolute = false;
var count = 0;
var UpdateObject;
if (typeof(require) !== "undefined") {
UpdateObject = require("Waze/Action/UpdateObject");
} else {
UpdateObject = Waze.Action.UpdateObject;
}
 
function onScreen(obj) {
if (obj.geometry) {
return(W.map.getExtent().intersectsBounds(obj.geometry.getBounds()));
}
return(false);
}
Object.forEach(W.model.segments.objects, function(k, v) {
if (count < 150 && v.onScreen(v) && v.isGeometryEditable()) { /* fwy */
if (v.attributes.roadType == 3 && (v.attributes.lockRank < fwy_lvl || (absolute && v.attributes.lockRank != fwy_lvl))) {
count++;
W.model.actionManager.add(new Waze.Action.UpdateSegmentDetailsUpdateObject(v, {lockRank: fwy_lvl}));
}
/* ramp */
if (v.attributes.roadType == 4 && (v.attributes.lockRank < rmp_lvl || (absolute && v.attributes.lockRank != rmp_lvl))) {
count++;
W.model.actionManager.add(new Waze.Action.UpdateSegmentDetailsUpdateObject(v, {lockRank: rmp_lvl}));
}
/* MH */
if (v.attributes.roadType == 6 && (v.attributes.lockRank < maj_lvl || (absolute && v.attributes.lockRank != maj_lvl))) {
count++;
W.model.actionManager.add(new Waze.Action.UpdateSegmentDetailsUpdateObject(v, {lockRank: maj_lvl}));
}
/* mH */
if (v.attributes.roadType == 7 && (v.attributes.lockRank < min_lvl || (absolute && v.attributes.lockRank != min_lvl))) {
count++;
W.model.actionManager.add(new Waze.Action.UpdateSegmentDetailsUpdateObject(v, {lockRank: min_lvl}));
}
/* primary */
if (v.attributes.roadType == 2 && (v.attributes.lockRank < pri_lvl || (absolute && v.attributes.lockRank != pri_lvl))) {
count++;
W.model.actionManager.add(new Waze.Action.UpdateSegmentDetailsUpdateObject(v, {lockRank: pri_lvl}));
}
}
})();
</nowiki>}}
 
==== Extraneous node remover ====
249
edits