"Species"

Is Virtual Radar Server not behaving itself? If so then please report it here.
egpd1701
Posts: 46
Joined: Fri Nov 08, 2013 3:39 pm

Re: "Species"

Post by egpd1701 » Sun Nov 27, 2016 11:13 am

HI

You need to use some custom content if you wish to not break the species.

If you use e.g. HKS as your operator flag and s92 as your ICAOTypeCode and then have a silhouette call S92-HKS.bmp and your Operator flag HKS.bmp then you can get what your looking for and it doesn't break the species field.

That way you don't have to go through all your a/c and change any of your data, the custom content does it for you.

batrakiu
Posts: 11
Joined: Sat Oct 15, 2016 10:14 pm

Re: "Species"

Post by batrakiu » Sun Nov 27, 2016 11:34 am

Theoretically, I understood it.
But I truly can't reverse engineering the custom content that I saw. :?
It's too much for me... ahah
But I'll try to follow your assumption. Thanks!

DeWoert
Posts: 41
Joined: Mon Feb 29, 2016 9:36 pm

Re: "Species"

Post by DeWoert » Sun Nov 27, 2016 11:45 am

Same here :o
Trying to understand, and get it to work with things i would like it to do, but no results yet.
( viewtopic.php?f=5&p=6242#p6242)

egpd1701
Posts: 46
Joined: Fri Nov 08, 2013 3:39 pm

Re: "Species"

Post by egpd1701 » Sun Nov 27, 2016 11:56 am

Create an html file called e.g. ChangeLogos.html

Add the code below

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            if(VRS.renderPropertyHandlers) {
                // Overwrite the standard operator flag renderer with a custom one.
                // THIS MIGHT NEED TO BE MODIFIED WHEN NEW VERSIONS OF VRS ARE RELEASED
                VRS.renderPropertyHandlers[VRS.RenderProperty.Silhouette] = new VRS.RenderPropertyHandler({
                    property:               VRS.RenderProperty.Silhouette,
                    surfaces:               VRS.RenderSurface.List + VRS.RenderSurface.DetailHead + VRS.RenderSurface.InfoWindow,
                    headingKey:             'ListOperator',
                    labelKey:               'Operator',
                    sortableField:          VRS.AircraftListSortableField.OperatorIcao,
                    headingAlignment:       VRS.Alignment.Centre,
                    suppressLabelCallback:  function() { return true; },
                    fixedWidth:             function() { return VRS.globalOptions.aircraftOperatorFlagSize.width.toString() + 'px'; },
                    // Changed the following line to redraw the flag if the manufacturer changes...
                    hasChangedCallback:     function(aircraft) { return aircraft.modelIcao.chg || aircraft.icao.chg || aircraft.registration.chg || aircraft.manufacturer.chg; },
                    // And changed this line to call our custom function to build the <img> tag instead of the standard one...
                    renderCallback:         function(aircraft) { return customFormatTypeIcaoImageHtml(aircraft); },
                    tooltipChangedCallback: function(aircraft) { return aircraft.modelIcao.chg || aircraft.operator.chg; },
                    tooltipCallback:        function(aircraft) { return aircraft.formatModelIcaoNameAndDetail(); }
                });
                
            }
        });
    }
    
    function customFormatTypeIcaoImageHtml(aircraft)
    {
        var codeToUse = '';
		codeToUse = customPipeSeparatedCode(codeToUse, aircraft.modelIcao.val + '-' + aircraft.operatorIcao.val);
		codeToUse = customPipeSeparatedCode(codeToUse, aircraft.modelIcao.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.manufacturer.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.operatorIcao.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.registration.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.icao.val);
		

        
        // The rest of this was copied from format.js operatorIcaoImageHtml()
        var size = VRS.globalOptions.aircraftOperatorFlagSize;
		
		
        var result = '<img src="images/File-' + encodeURIComponent(codeToUse)
        if(VRS.browserHelper.isHighDpi()) result += '/HiDpi';
        result += '/Type.png"' +
            ' width="' + size.width.toString() + 'px"' +
            ' height="' + size.height.toString() + 'px"' +
            ' />';

        return result;

    }
    
    function customPipeSeparatedCode(text, code)
    {
        var result = text;
        
        if(code && code.length) {
            if(result.length) result += '|';
            result += code;
        }

        return result;
    }
</script>
add the custom content file info

Enabled - Yes
Inject - ChangeLogos.html
At - Head
Of - End
Address - /desktop.html

Change your site root folder and Resource image folder to where your custom files are

batrakiu
Posts: 11
Joined: Sat Oct 15, 2016 10:14 pm

Re: "Species"

Post by batrakiu » Sun Nov 27, 2016 12:44 pm

It's done... 8-)
You were sweet..! ahah

Just had to change the code to my own case.

Code: Select all

codeToUse = customPipeSeparatedCode(codeToUse, aircraft.operatorIcao.val + '' + aircraft.modelIcao.val);
No dash and change the order.

A big "thank you" to you!

Image

skaw
Posts: 22
Joined: Sun Jun 05, 2016 9:57 am

Re: "Species"

Post by skaw » Sun Aug 19, 2018 6:48 pm

I am trying to understand all of this, but its pretty difficult...

This last script here won't help me with the following situation, will it?

I created a new non ICAO conform Silhouette BMP for the Airbus Helicopters H145. The ICAO conform Model Code would be EC45 but since earlier EC45 Models did not have the Fenestron i decided to create a new one which matches the actual Silhouette. Of course i can place this new Silhouette BMP in the corresponding folder, set the Model Code to H145 and it takes the correct BMP file, BUT this kills the species and does not show a helicopter marker on the map anymore..

Will the script above work for this case since the model code change does not affect the operator or anything else? What would i have to call the BMPs to let every H145 use the H145 Silhouette for display but EC45 for defining the Species? and what database changes would be needed for that?

Or:

could this somehow work if " matches: function (aircraft) { return aircraft.species.val === VRS.Species.Helicopter && aircraft.isMilitary.val; }" is somehow determined by the model code?

Code: Select all

new VRS.AircraftMarker({
            normalFileName: 'gHelicopter.png',
            selectedFileName: 'Helicopter-Selected.png',
            size: { width: 32, height: 32 },
            matches: function (aircraft) { return aircraft.species.val === VRS.Species.Helicopter && aircraft.isMilitary.val; }
        }),

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

Re: "Species"

Post by agw » Wed Aug 22, 2018 9:29 pm

The script you're looking at sets up conditions for showing different aircraft markers. Presumably you want to have H145 as the model ICAO and still have it show a helicopter marker? You could do that by changing the aircraft marker scripts, however H145 will still not be recognised as a helicopter species.

When VRS looks for a silhouette it looks first for a file named after the aircraft's ICAO, then it's registration and finally the model type ICAO. If there are a manageably small number of these aircraft then you could just create multiple copies of the silhouette and name them after the registration, e.g. G-ABCD.bmp. You could then leave the model type as the proper ICAO code.

skaw
Posts: 22
Joined: Sun Jun 05, 2016 9:57 am

Re: "Species"

Post by skaw » Sat Aug 25, 2018 3:23 pm

Okay, will need to use the ICAO since it does not work with the registration for some reason. Thanks for the tip!

Post Reply