Range strokes color

The "to-do" list for Virtual Radar Server is as long as my arm, but if you want to pile more work onto it then this is for you.
Lector
Posts: 39
Joined: Sat Jan 18, 2014 1:02 pm

Range strokes color

Post by Lector » Sun Apr 13, 2014 2:36 pm

It would be really nice if each stroke for the corresponding altitude range will have the same color as its filling has.
Since several overlayed plots with non-transparent fillings looks a bit messy, pure outlines, but colored differently will do picture more "watchable".
I've put a screenshot from GE with the KML plotes made by SBSPlotter for better understanding how it may look.
This is the case for two recievers with different locations. But, surely, you've got a point :)
Probably, line's thickness could be made adjustable too, like it's done for range circles.
Thanks!
Attachments
ranges.jpg
ranges.jpg (114.19 KiB) Viewed 5280 times

agw
Posts: 2249
Joined: Fri Feb 17, 2012 3:20 am

Re: Range strokes color

Post by agw » Mon Apr 14, 2014 1:58 am

I did experiment with having the stroke colour the same as the fill colour but there was a problem with light-coloured fills on light maps, the plot was hard to see. The black stroke was a compromise.

You can use the custom content plugin to set the stroke colour to be the same as the fill colour, but it's not as straight-forward as most custom content plugin configuration changes. This script would set the stroke width to 4 pixels and give it the same colour as the fill:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            var _PageSettings = null;
            bootStrap.hookInitialised(function(pageSettings) {
                _PageSettings = pageSettings;
            });
            
            VRS.globalOptions.polarPlotStrokeWeight = 4;
            
            VRS.globalOptions.polarPlotStrokeColourCallback = function(feedId, lowAlt, highAlt) {
                var result = undefined;
                var polarPlotter = _PageSettings ? _PageSettings.polarPlotter : null;
                if(polarPlotter) result = polarPlotter.getSliceRangeColour(lowAlt, highAlt);
                
                return result ? result : VRS.globalOptions.polarPlotStrokeColour;
            };
        });
    }
</script>
If you just wanted to change the stroke width then it's a lot more straight-forward:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            VRS.globalOptions.polarPlotStrokeWeight = 4;
        });
    }
</script>

Lector
Posts: 39
Joined: Sat Jan 18, 2014 1:02 pm

Re: Range strokes color

Post by Lector » Wed Apr 16, 2014 4:52 pm

Thanks a lot Andrew, that worked for me just fine!
Besides the tweak you've suggested above, I tried to manage the same result by editing the "polarPlotter.js" according to discription in documentation regarding VRS.globalOptions settings:
"polarPlotStrokeColour #000000 The CSS colour to use for the outline of the plot. If this is an empty string then the plot is outlined in the fill colour.
So, if I got it clearly, the line "VRS.globalOptions.polarPlotStrokeColour = VRS.globalOptions.polarPlotStrokeColour !== undefined ? VRS.globalOptions.polarPlotStrokeColour : '#000000'; // The colour of the polar plot stroke." has to be edited appropriately.
Nontheless, neither value '#000000' deleting nor commenting that line or even remowing it did not give a desired result. The only one effect I got - module does not loading at all.
Probably I did some manipulations wrong. Anyway, taking the oroginal js-file back restors the module functioning.
May I try to use that way generally or not?

agw
Posts: 2249
Joined: Fri Feb 17, 2012 3:20 am

Re: Range strokes color

Post by agw » Thu Apr 17, 2014 12:27 am

If you override polarPlotter.js with your own copy then you'll need to reapply your changes every time I change polarPlotter.js. If you really wanted to do it in polarPlotter.js then you need to change line 563 to be "var strokeColour = fillColour;". You can't edit the installed copy of polarPlotter.js, the site won't serve it - you'll need to use the custom content plugin to serve a separate copy in place of the standard polarPlotter.js file.

However, looking at the code it's actually easier to set the stroke colour to the fill colour than I thought it was - you just need this for your script:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            VRS.globalOptions.polarPlotStrokeWeight = 4;
            VRS.globalOptions.polarPlotStrokeColour = undefined;
        });
    }
</script>
If it's undefined then it uses the fill colour instead.

Lector
Posts: 39
Joined: Sat Jan 18, 2014 1:02 pm

Re: Range strokes color

Post by Lector » Thu Apr 17, 2014 5:46 am

The last one is just as perfect as laconic :) That's what I'll happy to use.
Thanks again for simple solution and great software!

jonfear
Posts: 365
Joined: Sat Feb 09, 2013 12:15 pm
Location: Wick St Lawrence
Contact:

Re: Range strokes color

Post by jonfear » Thu Apr 17, 2014 4:48 pm

Andrew

More devils advocate....

Can I set a global colour for all levels per receiver? That way people can easily differentiate their feed. For instance green for Astronet, Black for WSLWx etc?

Jon
http://www.360radar.co.uk, the new name for MLAT Radar in the UK and Western Europe.

Former PP feeder Bm. No longer feeding. I do not have time to sort out imaginary problems with NTP
when it has been working fine for 2+ Years.

agw
Posts: 2249
Joined: Fri Feb 17, 2012 3:20 am

Re: Range strokes color

Post by agw » Fri Apr 18, 2014 2:12 am

You'd have to use the more complicated script for that :) This one sets the fill colour for the "Receiver" feed to black and the fill colour for the "Example Feed" to blue:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            var _PageSettings = null;
            bootStrap.hookInitialised(function(pageSettings) {
                _PageSettings = pageSettings;
            });
            
            VRS.globalOptions.polarPlotFillColourCallback = function(feedId, lowAlt, highAlt) {
                var result = '#FFFFFF';
                var feed = _PageSettings && _PageSettings.aircraftListFetcher ? _PageSettings.aircraftListFetcher.getFeed(feedId) : null;
                if(feed) {
                    switch(feed.name.toUpperCase()) {
                        case "RECEIVER":        result = '#000000'; break;
                        case "EXAMPLE FEED":    result = '#0000FF'; break;
                    }
                }
                
                return result;
            };
        });
    }
</script>
You just need to change the lines that start with case to suit the receivers that you've got set up. The colour strings are in CSS # notation - #000000 is black, #FF0000 is full red, #00FF00 is full green and #0000FF is full blue. If you add feeds or change their names then you'll need to revise the script accordingly.

Lector
Posts: 39
Joined: Sat Jan 18, 2014 1:02 pm

Re: Range strokes color

Post by Lector » Fri Apr 18, 2014 1:16 pm

Can we have it to be plotted for the merged feeds?
And what is the max distance from the receiver's location to the aircraft for which plot may have drawn?

matthys70
Posts: 21
Joined: Thu Mar 13, 2014 9:24 am

Re: Range strokes color

Post by matthys70 » Fri Apr 18, 2014 3:21 pm

I find this very interesting.

I tried your first script suggestion with the custom content plug-in but didn't see any output on the map screen (desktop.html).
Also not sure where to inject, I have now at the END of HEAD but tried other options as well.

A little more details about how to do this would be appreciated ;-)

Lector
Posts: 39
Joined: Sat Jan 18, 2014 1:02 pm

Re: Range strokes color

Post by Lector » Fri Apr 18, 2014 4:13 pm

Hi matthys70,
take a look on the picture below. Hope, this will help you.
Attachments
options.jpg
options.jpg (75.8 KiB) Viewed 5211 times

Post Reply