Page 1 of 3

Icons in preview version

Posted: Wed Aug 12, 2015 10:56 am
by Bhaal
Hi agw,

Just wondering if you have an icon for medium twin turbo yet? And light variations that maybe just didn't make it in?

I've had a qick squiz at the JS for this and looks easy to add icons do, can this be done in the custom plugin or would I have to edit the existing JS?

I'd like to make and add icons for these types, if you have vector files for existing icons I could use as a base then once I get them done I can send them back to you as well?


Re: Icons in preview version

Posted: Thu Aug 13, 2015 2:05 am
by agw
I'll move this to the preview forum as this will go out of date once the next version is released. The icons that are in there are just proof of concept, I need to tart them up a bit and - like you say - add a bunch more.

As with everything in the preview version things could well change before release. However I'm fairly happy with the way things are now, I don't think this will change very much before release. Just bear in mind that you might need to redo it a bit when the next release comes out.

You can add your own icons or modify the ones that are there. You will need to use the custom content plugin. The icons are represented by an object called VRS.AircraftMarker, you have one instance for each pair of selected / normal markers. The VRS.AircraftMarker objects are added to an array called VRS.globalOptions.aircraftMarkers in aircraftPlotter.js. The order in which the marker objects appear in the array is important, the marker object exposes a function called matches and the first object that returns true for the aircraft passed into it is the marker that gets used... so you need to insert your new markers to the start of the array, not the end (use unshift to add objects to the array, not push).

You will need to create a folder called Web somewhere on your computer and tell the custom content plugin that you want to use that as the site root. Then under your Web folder create another folder called images, under there create a folder called markers and stick your new marker icons in there. You don't need to add any other site files to the Web folder, you are just supplying new files and overrides (but avoid putting overrides in there, it makes it more likely that things will break when VRS is updated).

The marker icons should show the aircraft pointing north. They will be rotated by the program. You can switch rotation off by setting canRotate: false in the AircraftMarker declaration.

You need to leave a transparent border around your marker that is just wide enough to allow the marker to be rotated through 360° without clipping. I think from memory I use a border of 45% of the marker width, so if the aircraft is 30 pixels wide then the rotation border will be 30 *.45 = 13.5 pixels, so I'd leave about 7 pixels transparent all the way around.

To get the marker icons loaded into VRS you need to create a script file (e.g. "MyMarkers.html") and add that to end of the head of every page using the custom content plugin (specify * for the page). This example script adds one marker for the images "MyNewPlane.png" and "MyNewPlane-Selected.png" which is 60x60 pixels and is only to be used when the registration is "G-VFAB" (this is all untested so it might not work :) But you get the idea):

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: 'MyNewPlane.png',
                    selectedFileName: 'MyNewPlane-Selected.png',
                    size: { width: 60, height: 60 },
                    matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.reg.val === 'G-VFAB'; }

Re: Icons in preview version

Posted: Thu Aug 13, 2015 2:55 am
by Bhaal
Ahhh, I was originally writing this in here, and now I cannot even remember why I decided to move, maybe I thought it was the wrong place :)

So when I took a look at aircraftPlotter.js before posting the question I was very impressed with your solution to the problem! I am guessing pretty much anything in the basestation database can be matched? Using the column names?

Also, can we maybe use different coloured icons based on whether the plane is plotted by ads-b or mlat?

Also where in the array order will that example code place the plane icon? To me it looks like it will be tacked to the end..? EDIT: Don't answer, I saw the unshift.. Whoops :)

Thanks so much for all your hard work agw! It's very much appreciated!

Re: Icons in preview version

Posted: Thu Aug 13, 2015 11:53 am
by jonfear
A different colour for MLAT would be very nice! ;-)

Sorry Andrew!


Re: Icons in preview version

Posted: Fri Aug 14, 2015 7:57 am
by Bhaal
Alright, so I have it working for a number of plane configurations, now I am wondering if there could be a future where we might be able to say "This array of plane models, use this icon" ? EDIT: so I can make this work, but guess it would work best coming from the database... That could be said for all the planes though, but would be harder for a user to edit..

As for MLAT I've tried a number of different things including adding to objects in aircraftRender.js etc, but to no avail :/ ... I have the images made up for some of the icons which are coloured differently so just need to find the right code. :)

Re: Icons in preview version

Posted: Tue Aug 18, 2015 8:47 am
by agw
I can see where you're probably going with the "use this icon for this range of model types" thing, I imagine you want to indicate things like engine arrangement, general body shapes etc. Things that VRS doesn't know anything about :) Until such a time as they can come from a database I would probably have those in JavaScript.

Aircraft whose positions are coming from an MLAT source will have isMlat.val set to true. That does not necessarily mean that every aircraft on an MLAT receiver will have isMlat.val set to true, it only sets it to true if:

1. The aircraft is on a feed coming from an MLAT source and the MLAT source is identifying the messages that it generates for positions by means of a magic number (FF 00 4D 4C 41 54) in the timestamp or a BaseStation message type of MLAT.

2. An MLAT receiver supplied the current position for the aircraft in a merged feed.

Re: Icons in preview version

Posted: Tue Aug 18, 2015 9:33 am
by Bhaal
I can do the JS thing, but does make the whole experience rather chunky, can you add to to do list to add an additional field in StandingData for icon type? :)

Hmmmm, I am trying a bunch of permutations for the MLAT thing, but I cannot seem to get it to pop-up, this for instance:

Code: Select all

VRS.globalOptions.aircraftMarkers.unshift(new VRS.AircraftMarker({
                    normalFileName: 'WTC-Light-2-Turbo-MLAT.png',
                    selectedFileName: 'WTC-Light-2-Turbo-MLAT-Selected.png',
                    size: { width: 27, height: 27 },
                    matches: function(/** VRS.Aircraft */ aircraft) { return aircraft.wakeTurbulenceCat.val === VRS.WakeTurbulenceCategory.Light && aircraft.countEngines.val === '2' && aircraft.engineType.val === VRS.EngineType.Turbo && aircraft.species.val === VRS.Species.LandPlane && aircraft.isMlat.val === 'True'; }
I've also tried with: aircraft.isMlat.val === True;
and: aircraft.isMlat.val === true;
and: aircraft.isMlat.val === 1;

None work..

My MLAT data comes off FlightAwares new PiAware MLAT data, I have PiAware listening on a port with the Basestation format, I have tried using a "Merge" only feed as well as a Normal feed, the normal feed with 'MLAT' turned on and off in the Merged Feeds section of the config.. None work... HALP!

PS. I had tried all this before you came back with a reply, I've pawed over all the JS code looking for the right variable to search for and isMlat is what I settled on... At least I got that right..

Re: Icons in preview version

Posted: Tue Aug 18, 2015 9:56 am
by Bhaal
So when I turn 'MLAT' off for my MLAT feed in the "Merged Feeds" section the MLAT positions stop appearing. If it was a true MLAT feed, would the positions continue to be shown or does turning that switch off tell MLAT to ignore the feed as MLAT?

If MLAT positions should continue from a true MLAT feed then I guess the PiAware MLAT feed is not a true feed :(

But if I put the "MLAT" flag into the aircraft list, it says "Yes" for MLAT flights (when the MLAT switch in "Merged Feeds" turned on)..

Re: Icons in preview version

Posted: Wed Aug 19, 2015 8:07 am
by agw
aircraft.isMlat.val is a bool so you don't need an explicit test for it - for example "if(aircraft.isMlat.val) { /* DO SOMETHING WHEN TRUE */ }" would work, and if you wanted to test if it was false then you just need "!aircraft.isMlat.val". However if you do want to explicitly test the bool then it's "<variable> == true" or "<variable> == false" (or === if you know for a fact that you're testing a bool and you want to avoid the overhead of an implicit cast to bool).

The preview has a new field called MLAT in the aircraft detail and aircraft list. I would add that to the list panel, the aircraft that have "YES" for MLAT will have an aircraft.isMlat.val value of true.

Bear in mind that you are unshifting to the start of the array, so the order of precedence is reversed. If you do this:


Then the MLAT version will never be used. The non-MLAT version will appear in the array before the MLAT version so it will always match first. You'd need to either reverse the order in which you unshift the elements into the array or you'll need to test for the same properties in both entries (i.e. add a test for !MLAT) in the second.

Ticking MLAT for a feed in a merged feed tells VRS to always take positions and headings from that feed, even if the feed is not the nominated feed for the aircraft. However, if the nominated feed for the aircraft is supplying positions then the MLAT feed gets ignored, its positions are superfluous. The isMlat.val field gets set to true when either the aircraft's current position came off an MLAT feed and not the nominated feed or when the nominated feed is an MLAT feed and the position was calculated by the MLAT server.

Re: Icons in preview version

Posted: Wed Aug 19, 2015 9:45 am
by Bhaal
*hangs head in shame* I completely forgot I was unshifting, but I did know it was a bool, but was testing everything I could think of to be sure.. When all I needed was to put the MLAT last in the list... These are the consequences when decreasing caffeine intake, Watch out people! It could happen to you as well!

So.... YAY!! I now have MLAT planes showing up as a different colour at long last! agw, You are a legend!

Now back to making more planes...