[Script] Street Vector Layer

V. 2.0 -> Coming Soon!
Many complained about labels placement. Have a look at the screenshot!
labels.png

1 Like

What a big tease, bedo!! :slight_smile: :slight_smile:

Is this “Waze soon” or soon soon??

Thanks so much for figuring out how to fix the labels!

Version 2.0 is out! :mrgreen:

  • More arrows on one way streets with few geometry nodes
  • Names follow the direction of the street (heads will turn :smiley: ).

Let me know if something doesn’t work as you’d expect.

Enjoy!

Awesome !!!
Thank you for this update. :stuck_out_tongue:

In town the speed display can be hidden by the name of the next segment.

  • Is it possible to display the speed above the segment ?
  • And expand the numbers a bit of speed ?

Small update, 2.1
As the street name on short street might cover them completely, the street name on one-way streets contains now two arrows too. In this way it’s also possible to see the direction of important streets when the zoom is not close enough to draw the arrows.

Can i ask for a way to increase the font of a segment name? Just a wish, not a demand.

Hi,

can you remove this please:

console.debug = function(){}; //Comment it out for production mode

It breaks this useful function for other scripts :mrgreen:

thx!

d2

And at the same time it would probably be best to wrap the whole script inside a function to prevent a collision of function names or variables with other scripts (which seems very likely due to the very generic function names). It’s not that hard to do as it won’t impact your script:

(function() { // All function and variable declarations go in here as they are now })();

For the console issue, I personally use a different function for that:

function log(obj) { if (localStorage.svlDebug) { // just a suggestion, feel free to do something else console.log(obj); } }

Also, there is a global variable svlAttempts that could be put as a var at the top of the script as it is not useful anywhere else (inside the function declaration I showed in this post). The risk of a collision with other scripts is very minimal though.

Just trying to make your script even better :slight_smile:

This is one of those times I wish there was an option to favorite a post so I can come back to it later when I need it. :smiley: I suppose a bookmark should suffice.

Exactly, I have several bookmarks to validator posts as well for things like the complete list of checks, and typeRank lists

Sent from Android using Tapatalk

Version 2.3 is out.

  • Non validated speed limits are shown with a question mark after their street name.
  • Variable/methods names should not collide with other scripts anymore (thanks Glodenox)
    If you want to show unverified speed limits with a dashed style, you can manually change line 941
    from:
strokeDashstyle: "solid",//(attributes.fwdMaxSpeedUnverified|attributes.revMaxSpeedUnverified ? "dash":"solid"),

to:

strokeDashstyle: (attributes.fwdMaxSpeedUnverified|attributes.revMaxSpeedUnverified ? "dash":"solid"),

bedo2991, thank you so much, Vector is awesome!

I have two bugfixes, and I also made some customizations that USA editors may like, as it is geared towards common USA speeds, and also tweaks the label visibility a bit.

Line 254, I replace the getColorSpeed() function with one that uses a tweaked color scale so roads that speed up / slow down only 10 mph have more visual distinction between the colors used:

function getColorSpeed(speed) { if(W.prefs.attributes.isImperial) // adjust scale for Imperial { // speeds 15 to 75 mph (7 increments) are tuned to HSL 95 to 395 (35) for easy visual speed differentiation at common speeds return ((speed / 1.609344 * 5) + 20) %360 } else { return (speed * 3) %360; // :150 * 450 } }

Lines 377-379 (now lines 385-387 if you replaced the above function; I will put future line # changes in () as well, for those adopting all changes), there’s a typo in “isImperial”. The calls to getColorSpeed() for mph also won’t have the right colors returned (in both the original and updated function), as it expects to be passed kph. Replace lines 377-379 (385-387) with these 5 to pass kph values in all cases, and to adjust the scale when using mph:

for(var k=W.prefs.attributes.isImperial?9:15; k>1; k--){ if (W.prefs.attributes.isImperial) { $speedLimits.append($('<span style="color:hsl('+getColorSpeed((k*10-5)*1.609344)+',100%,50%)">'+(k*10-5)+' </span>')); } else { $speedLimits.append($('<span style="color:hsl('+getColorSpeed(k*10)+',100%,50%)">'+k*10+' </span>')); } }

Line 666 (676): I make the fonts bigger for my old man eyes :slight_smile:

labelFontSize = farZoom?"14px":"16px";

Line 1232 (1242): Insert a new line after “if(speed)” to add in a visual separator between the street name and the speed limits (as you’ll see with the remaining changes, I make the speed limits larger in size)

speedPart += ": ";

Lines 1234, 1239, and 1247 (now 1245, 1250, and 1258):
Change all “=” to be “+=”

Starting at Line 1308 (1319).
Comment out all “number.replace” lines by placing // at the front of each line. Be sure to leave the “number.toString” line alone

Results showing 25 through 65mph colors:

Will this work for us in the UK as well?
We use imperial units too, and would benefit from a larger separation of colours for limits that are only 10 mph different. However, common speed limits here are all multiples of 10, i.e. 20, 30, 40, 50, etc.

Yes, my modifications should work without any further changes. If you’d like to adjust the reference scale to be on the “10s” instead of the “5s”, in this section:

for(var k=W.prefs.attributes.isImperial?9:15; k>1; k--){ if (W.prefs.attributes.isImperial) { $speedLimits.append($('<span style="color:hsl('+getColorSpeed((k*10-5)*1.609344)+',100%,50%)">'+(k*10-5)+' </span>')); } else { $speedLimits.append($('<span style="color:hsl('+getColorSpeed(k*10)+',100%,50%)">'+k*10+' </span>')); } }
change the longest line to be instead the following (drop both “minus 5” bits):

        { $speedLimits.append($('<span style="color:hsl('+getColorSpeed((k*10)*1.609344)+',100%,50%)">'+(k*10)+' </span>')); }

Later today I’ll create a github project, then everybody can collaborare and I don’t have to merge changes manually :).

Inviato dal mio PLK-L01 utilizzando Tapatalk

Quickly created one here: https://github.com/bedo2991/svl
Here is a list of issues: https://github.com/bedo2991/svl/issues (you need a Github account to create new ones).
Here is how to fork a repository: https://help.github.com/articles/fork-a-repo/

Now fixed in version 2.4

Awesome! I’ve merged in my color changes for imperial units since that’s just a universal fix. I’ll see about re-implementing some of the other changes I proposed as user options, since they’re a significant deviation from your existing representation of speed limit text (unless you’d rather they be the new default format…)

Imperial fix uploaded to production -> V. 2.5 is out.

As of Firefox version 44 (currently in beta) it is not allowed to assign a value to unsafeWindow (as it is an undefined constant for some reason). I’m currently checking some of the scripts in the forum to make sure they won’t break once Firefox 44 goes live (January 26). I’ve checked your userscript and it uses unsafeWindow a bit, so you may run into problems. Either way, the code below won’t do anything useful any more as this way of retrieving the unsafeWindow has been removed. I’ve seen other scripts just using unsafeWindow without that check and they seem to run fine.

[code] var bGreasemonkeyServiceDefined = false;

try {
    bGreasemonkeyServiceDefined = (typeof Components.interfaces.gmIGreasemonkeyService === "object");
} catch (err) { /* Ignore */ }

if (typeof unsafeWindow === "undefined" || !bGreasemonkeyServiceDefined) {
    unsafeWindow = (function() {
        var dummyElem = document.createElement('p');
        dummyElem.setAttribute('onclick', 'return window;');
        return dummyElem.onclick();
    })();
}[/code]