Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Want to post something that doesn't quite fit into the other forums? This is the place for that.
pafckenny
Posts: 1
Joined: Wed Oct 21, 2015 9:54 am

Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by pafckenny » Tue Feb 09, 2016 9:16 am

Hi.

I am just wondering if someone can tell me if it's possible to have different colour icons for Military and Civil Aircraft? If so how can I go about this? I'm not that great with scripting as I think that'll be the way to go.

Also is it possible to feed data from certain receivers at certain flight levels? I.E, We are a South-West UK VR and I have one particular feeder who has coverage over London and the Midlands, Is there any way to filter his traffic to say FL100 as this was would give the coverage we would need.

Kenny

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

Re: Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by agw » Sat Feb 13, 2016 9:07 pm

You can't change the colour of the icons but you can replace the icons, or add your own. The procedure is outlined here (it's for a preview version but it's still the same for the current release): http://forum.virtualradarserver.co.uk/v ... =805#p4019

Basically you need to create a folder somewhere on your drive called Web, in there create a folder called images and in there a folder called markers. In markers you create two images, one for military aircraft and another for selected military aircraft. Let's say you call them Military.png and Military-Selected.png. You can see examples of existing marker images in the VRS install folder (usually c:\program files (x86)\VirtualRadar), under the Web\images\markers folder. Note that you need to leave enough transparent space around the marker for rotation.

Somewhere above the Web folder create a file called AddMarkers.html and put this in it (change the normalFileName, selectedFilename and size entry to match your images):

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            if(VRS.globalOptions && VRS.globalOptions.aircraftMarkers) {
                VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'Military.png',
                    selectedFileName: 'Military-Selected.png',
                    size: { width: 60, height: 60 },
                    matches: function(aircraft) { return aircraft.isMilitary.val; }
                }));
            }
        });
    }
</script>
Then you install the custom content plugin. Click NEW and add your AddMarkers.html as a new script, tell it to inject it to the END of HEAD. Change the address to * so that it gets inserted into every web page. Down the bottom of the options page click the "..." button next to Site Root Folder and choose your Web folder. That should be about it.

Regarding filtering based on flight level - no, there's no way to do that. However you shouldn't need to, just merge his feed in with the others. If he has better reception for some aircraft then he's going to end up being the nominated receiver for them.

T-EGJA1
Posts: 107
Joined: Sun Sep 08, 2013 12:11 am
Location: Mid-Devon, UK

Re: Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by T-EGJA1 » Thu Feb 18, 2016 8:28 pm

I've tried the above, Andrew, but I must be missing something ...... whatever I try, (matching against isMilitary or modelICAO === <xxxx>) as soon as there's a match, all a/c icons disappear from the map!
Terry

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

Re: Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by agw » Sat Feb 20, 2016 4:17 pm

I imagine you've got a bug in the "matches" function.

F12 with the script enabled and then reload the page. You should get a bunch of console errors coming up, probably the same one repeated many times. What's the message that you're getting and what have you for your "matches" function?

T-EGJA1
Posts: 107
Joined: Sun Sep 08, 2013 12:11 am
Location: Mid-Devon, UK

Re: Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by T-EGJA1 » Sun Feb 21, 2016 12:56 am

Many thanks for the reply, Andrew - I've now managed to get it working :D

Enabling the browser console showed 404 'not found' errors .... I eventually tracked it down to where I'd specified the 'Site root folder' - sorted that and it fixed the problem; so now I'm looking forward to creating a bunch of new, type-specific icons :)

Losing all the icons was a red herring - I realised later that I had 'military' set as a filter; hence I lost all military icons - sorry if it misled you.

Thanks again for your help.
Terry

T-EGJA1
Posts: 107
Joined: Sun Sep 08, 2013 12:11 am
Location: Mid-Devon, UK

Re: Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by T-EGJA1 » Wed Feb 24, 2016 4:11 pm

Hi Andrew,
Since setting up a few custom icons, I've had the following error pop up on a couple of occasions - I'm assuming it's connected with the changes I've made, but there don't appear to be any adverse effects on the VRS display.
Image

I'd be grateful if you could shed any light on this.
Terry

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

Re: Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by agw » Sun Feb 28, 2016 1:54 am

Unfortunately the .NET Image class throws out of memory exceptions for a lot of problems that are nothing to do with running out of memory. The documentation (https://msdn.microsoft.com/en-us/librar ... s.90).aspx) gives two possibilities:

1. The file does not have a valid image format or
2. GDI+ doesn't support the pixel format of the file.

Unfortunately the exception message doesn't tell you the file that it can't load :)

I have a web page that will dump out all of the aircraft markers that have been registered. It's not released with the program but it is under source control, you can get it from here:

http://vrs.codeplex.com/SourceControl/l ... sheet.html

If you stick that in your site root, make sure that the custom content plugin is injecting your aircraft marker script into all HTML files and then load that page in a browser then you should see all of your aircraft markers in the order that they'll be evaluated by the site. Hopefully you'll also see a bunch of those exceptions on the server when you view the page. The marker that has a title but no images is the one that's going to be the problem.

T-EGJA1
Posts: 107
Joined: Sun Sep 08, 2013 12:11 am
Location: Mid-Devon, UK

Re: Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by T-EGJA1 » Mon Feb 29, 2016 1:44 pm

Thanks for the reply, Andrew.

I've tried your suggestion, but unfortunately I can't get it to work - maybe I've misunderstood your instructions.

I put a copy of your 'Marker Contact Sheet' script into the folder that I have designated as 'Site Root' in the Custom Content Options. My AddMarkers script is running (address: *) and displaying my custom icons on the map, however when I open the 'Marker Contact Sheet' html in a new browser tab, I just get a blank page.

On the other hand, I tried injecting 'Marker Contact Sheet' via the Custom Content plugin and by doing so, the 'http://127.0.0.1/VirtualRadar/desktop.html' page displays the icon contact sheet with all of "your" icons, but whatever I try, I cannot get the contact sheet to display my custom icons.

Grateful for any further help you can offer.
Terry

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

Re: Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by agw » Tue Mar 01, 2016 1:12 am

All you need to do is save the zz-norel-marker-contact-sheet.html file, which you'll need to copy from Codeplex, into the folder that you've specified as the site root in the custom content plugin. Then from the browser go to http://127.0.0.1/VirtualRadar/zz-norel- ... sheet.html and it should bring it up.

If you get a blank page then press F12 and check for JavaScript errors in the console.

T-EGJA1
Posts: 107
Joined: Sun Sep 08, 2013 12:11 am
Location: Mid-Devon, UK

Re: Different Colour Icons for Military and Civil Aircraft & Flight Level Filtering.

Post by T-EGJA1 » Tue Mar 01, 2016 11:08 pm

Hi Andrew,

Thanks to your clarification, I'm making some progress - my mistake was trying to load the zz-norel-marker-contact-sheet.html directly into the browser, i.e. as "file:///C:/Radar/VirtualRadar/Plugins/CustomContent/Web/zz-norel-marker-contact-sheet.html" ....... this was what resulted in the blank page.

Anyhow, using the address "http://127.0.0.1/VirtualRadar/zz-norel- ... sheet.html" displays icons, but still only "your" icons - not my custom ones.

My custom AddMarkers.html script is running, the zz-norel-marker-contact-sheet.html is located in C:\Radar\VirtualRadar\Plugins\CustomContent\Web and this is the folder that I have designated as "Site Root" in the Custom Content Options dialogue box.

Any further help you can offer would be appreciated.
Terry

Post Reply