Difference between revisions of "User:DBsooner/Bookmarklets"

From Wazeopedia
(Page)
 
(No difference)

Latest revision as of 14:29, 23 October 2017

Set segment locks in area

This script will set the lock rank on various segment types in the visible area of the WME. Note that the script uses levels one lower than the level will be applied, e.g., if the script says "fwy_lvl=4" then the Freeway will be locked at 5. Current configuration as listed in this script:

  • It will only update up to 150 segments
  • It only modifies what can be modified by the user's current rank and area
    • If the user's current rank is lower than the defined lock level, it will lock the roads at the user's rank
  • It will not lower a rank less than it is currently set
  • Freeways are set to 5
  • Ramps are set to 4
  • Major Highways are set to 4
  • Minor Highways are set to 3
  • Primary Streets are set to 2
  • Private Roads are set to 2
  • Railroads are set to 2
  • Ferries are set to 5
javascript: (function() { /* 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 = 4; var rmp_lvl = 3; var maj_lvl = 3; var min_lvl = 2; var pri_lvl = 1; var prv_lvl = 1; var rr_lvl = 1; var fer_lvl = 4; var absolute = false; var count = 0; var thisUser = Waze.loginManager.user; if (thisUser === null) return; var usrRank = thisUser.normalizedLevel; var UpdateObject; if (typeof(require) !== "undefined") { UpdateObject = require("Waze/Action/UpdateObject"); } else { UpdateObject = Waze.Action.UpdateObject; } if (fwy_lvl > (usrRank - 1)) fwy_lvl = usrRank - 1; if (rmp_lvl > (usrRank - 1)) rmp_lvl = usrRank - 1; if (maj_lvl > (usrRank - 1)) maj_lvl = usrRank - 1; if (min_lvl > (usrRank - 1)) min_lvl = usrRank - 1; if (pri_lvl > (usrRank - 1)) pri_lvl = usrRank - 1; if (prv_lvl > (usrRank - 1)) pri_lvl = usrRank - 1; 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 && 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 UpdateObject(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 UpdateObject(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 UpdateObject(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 UpdateObject(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 UpdateObject(v, { lockRank: pri_lvl })); } /* railroad */ if (v.attributes.roadType == 18 && (v.attributes.lockRank < rr_lvl || (absolute && v.attributes.lockRank != rr_lvl))) { count++; W.model.actionManager.add(new UpdateObject(v, { lockRank: rr_lvl })); } /* ferry */ if (v.attributes.roadType == 14 && (v.attributes.lockRank < fer_lvl || (absolute && v.attributes.lockRank != fer_lvl))) { count++; W.model.actionManager.add(new UpdateObject(v, { lockRank: fer_lvl })); } /* private road */ if (v.attributes.roadType == 17 && (v.attributes.lockRank < prv_lvl || (absolute && v.attributes.lockRank != prv_lvl))) { count++; W.model.actionManager.add(new UpdateObject(v, { lockRank: prv_lvl })); } } }); })();