Query by tail number


#1

I’m trying to use SearchBirdseyeInFlight to query a list of specific tail numbers, but the query does not work when using ident_or_reg with tail numbers AND a destination. I completely admit that I may be reading the syntax wrong, if so, please let me know.

For example, this plane is currently active on a flight as NKS292.
flightaware.com/live/flight/N510NK

But these queries return nothing:

$query = “{ident_or_reg {N510NK}}{orig_or_dest {KIAH}}”;
$query = “{ident_or_reg {N510NK}}{= dest KIAH}”;

This query works, but returns all the scheduled flights with that tail number:

$query = “{ident_or_reg {N510NK}}”;

I can filter the object after the fact by destination, but wouldn’t that return all flights, putting a unnecessary load on the server?

Can we add the tail number to the output? The listing I’m trying to make is for special planes, such as Star Alliance, Continental Retro Jet, etc, anything with special paint or significance. Having the tail number on output would allow me to display which plane you’re looking at by looking it up in my own array and not have to memorize the tail numbers (there will be a lot). This is my list so far!

$query = “{ident_or_reg {N75436 B2032 B2035 B2006 B2047 FGZNE FGZNN GYMML GCIVC GCIVI GCIVK GCIVD GCIVL GCIVM GCIVP GCIVZ PHBFT}}”;

Thanks!


#2

You need a space between the terms.

$query = “{ident_or_reg {N510NK}} {orig_or_dest {KIAH}}”;
$query = “{ident_or_reg {N510NK}} {= dest KIAH}”;

Unfortunately, the structure doesn’t allow the reg to be returned at this time.


#3

Thanks for the quick reply!

$query = “{ident_or_reg {N75436 B2032 B2035 B2006 B2047 FGZNE FGZNN GYMML GCIVC GCIVI GCIVK GCIVD GCIVL GCIVM GCIVP GCIVZ PHBFT}} {= dest KIAH}”;

I’ve added a space, and it comes back with these 4 flights. 1 of which is in my list, but 3 aren’t.

In the list and on the way to KIAH
flightaware.com/live/flight/BAW195

G-BYGG, not in the query
flightaware.com/live/flight/BAW197

N13750, not in the query and neither destination nor origin are KIAH
flightaware.com/live/flight/UAL1602

B-2039, not in the query
flightaware.com/live/flight/CCA995

Am I missing something?

Thanks!


#4

You do understand that airlines do not always re-use the same aircraft for the same flight numbers, right?

CCA995 on 2015-02-27 (faFlightID = “CCA995-1424847600-schedule-0168”) was operated by B2006.

BAW197 on 2015-03-09 (faFLightID = “BAW197-1425738600-schedule-0182”) was operated by GCIVC.

UAL1602 on 2015-03-09 (faFlightID = “UAL1602-1425757500-schedule-0240”) was operated by N75436.


#5

Yes I understand that, I’m just trying to get a list of specific tail numbers en route to an airport (and ideally any of these departing as well). I’m not wanting historical data, but rather a live snapshot of anything currently in the system.

Am I going about this the wrong way?


#6

Add “{true inAir}” as another term to your search query if you only want currently flying aircraft.


#7

Thanks, that seems to work.

I just inferred that it would show me the planes in the air based on the name.


#8

I’ve found an inconsistency in the returned data. If I have a query from SearchBirdseyeInFlight that returns only one flight, it doesn’t return an array, but rather just the object.

Only one record:
[aircraft] => stdClass Object

More than one:
[aircraft] => Array

Is this correct or possibly a bug? If it is correct, I would appreciate some insight on how to deal with it in PHP. I know you can’t help with my individual app development, but I’m having trouble trying to detect this programmatically. Just one function or keyword to point me in the right direction would be helpful.

I am able to access output by specifying $flights->aircraft->ident as opposed to just $flights->ident as shown in the examples, but just need to know what to check for with one vs multiple records.

Thanks!

Examples of raw output:

One result:


(
    [SearchBirdseyeInFlightResult] => stdClass Object
        (
            [next_offset] => -1
            [aircraft] => stdClass Object
                (
                    [faFlightID] => NKS216-1425862500-schedule-0005
                    [ident] => NKS216
                    [prefix] => 
                    [type] => A319
                    [suffix] => L
                    [origin] => KLAX
                    [destination] => KIAH
                    ....... more data   .......
                )

        )

)

More than one result:


(
    [SearchBirdseyeInFlightResult] => stdClass Object
        (
            [next_offset] => -1
            [aircraft] => Array
                (
                    [0] => stdClass Object
                        (
                            [faFlightID] => AWE477-1425865800-schedule-0016
                            [ident] => AWE477
                            [prefix] => 
                            [type] => A321
                            [suffix] => L
                            [origin] => KPHX
                            [destination] => KIAH

                            ....... more data   .......
                        )

                    [1] => stdClass Object
                        (
                            [faFlightID] => NKS216-1425862500-schedule-0005
                            [ident] => NKS216
                            [prefix] => 
                            [type] => A319
                            [suffix] => L
                            [origin] => KLAX
                            [destination] => KIAH

                            ....... more data   .......
                        )

                )

        )

)


#9

I’ve not heard reports of that behavior with singleton arrays from anyone else, so I suspect it might be PHP’s SOAP library on your side automatically simplifying responses?


#10

Is there something I can look for in phpinfo to help investigate?


#11

Worst case, you can do something like:



$flightAry = (is_array($flights->aircraft) ? $flights->aircraft : array($flights->aircraft));



#12

I started to write something like that last night but wanted to make sure this wasn’t a bug before I did that.

I’ll create my own LAMP stack and try it there.


#13

It is possible that it may vary depending on which SOAP library for PHP you are using (SoapClient vs nusoap), and that there may be an option that is configurable for that library.


#14

This is the only section in phpinfo that says anything about SOAP. Is there something else to look for?


#15

php.net/manual/en/soapclient.soapclient.php indicates that the constructor takes an options argument that allows you to specify SOAP_SINGLE_ELEMENT_ARRAYS, which sounds like what you want.


#16

You’re awesome!

That fixed it, added the line in red below.

THANKS!

$options = array(
‘trace’ => true,
‘exceptions’ => 0,
‘login’ => ‘nnnnnn’,
‘password’ => ‘nnnnnn’,
‘features’ => SOAP_SINGLE_ELEMENT_ARRAYS
);


#17

Found something odd… Several random tail numbers don’t show up in the SearchBirdsEyeInFlight query: N776SK, N35204 for example.

They’re all currently flying and on their way to KIAH

I get no results from this query:
{ident_or_reg {N35204 N776SK}} {true inAir} {= dest KIAH}

This one gets one result, from FFT1358:
{ident_or_reg {N35204 N776SK FFT1358}} {true inAir} {= dest KIAH}

Even dropping the other parameters like this returns no results:
{ident_or_reg {N35204 N776SK}}

Am I missing something?

Thanks!


#18

Still getting weird responses from SearchBirdseyeInFlight.

This query:



http://flightxml.flightaware.com/json/FlightXML2/SearchBirdseyeInFlight?query={ident_or_reg {N27724 N574FE N28529}} {true inAir} {= dest KIAH}

Produces this output, 1 result, but all 3 planes are currently in the air and on their way to KIAH.



{"SearchBirdseyeInFlightResult":{"next_offset":-1,"aircraft":{"faFlightID":"FDX527-1433701021-212-1","ident":"FDX527","prefix":"H","type":"MD11","suffix":"L","origin":"KMEM","destination":"KIAH","timeout":"0","timestamp":1433713918,"departureTime":1433711820,"firstPositionTime":1433711893,"arrivalTime":0,"longitude":-92.656419999999997117,"latitude":32.116830000000000211,"lowLongitude":-92.646529999999998495,"lowLatitude":32.144970000000000709,"highLongitude":-89.986609999999998877,"highLatitude":35.008310000000001594,"groundspeed":483,"altitude":353,"heading":189,"altitudeStatus":"C","updateType":"A","altitudeChange":"","waypoints":"35.033 -89.967 35.133 -90.033 35.133 -90.133 35.1 -90.233 34.967 -90.55 34.9 -90.717 34.883 -90.8 34.883 -90.817 34.9 -90.95 34.933 -91.05 34.9 -91.083 34.717 -91.25 34.533 -91.417 34.5 -91.433 34.483 -91.483 34.467 -91.6 34.433 -91.617 33.867 -92.05 33.583 -92.267 33.417 -92.383 33.383 -92.417 32.817 -92.517 32.667 -92.55 32.133 -92.633 31.967 -92.667 31.45 -93.333 31.317 -93.5 31.25 -93.583 31.033 -93.85 31.017 -93.883 30.983 -93.917 30.967 -93.95 30.833 -94.117 30.8 -94.15 30.75 -94.217 30.667 -94.317 30.55 -94.483 30.533 -94.483 30.533 -94.5 30.35 -94.633 30.283 -94.65 30.117 -94.7 30.05 -94.717 30.033 -94.717 30 -94.767 30 -94.85 29.983 -95.05 29.983 -95.083 29.983 -95.15 29.983 -95.25 29.983 -95.333"}]}}

What am I missing?

Thanks!


#19

Can you try explicitly specifying “&howMany=15” on your URL? I think it might be defaulting to 1 if you omit it.


#20

No dice. It didn’t make a difference when I added the howMany parameter.

I tried it with just one flight and got the same thing.


http://flightxml.flightaware.com/json/FlightXML2/SearchBirdseyeInFlight?query={ident_or_reg {N444YX}} {true inAir} {= dest KIAH}&howMany=15


{"error":"no results"}

I don’t think it makes a difference, but I tried it with specifying the howMany parameter first, then the query, but got the same result, no results.


http://flightxml.flightaware.com/json/FlightXML2/SearchBirdseyeInFlight?howMany=15&query={ident_or_reg {N444YX}} {true inAir} {= dest KIAH}

This flight:

flightaware.com/live/flight/RPA4371 Is currently on its way to IAH.

Thanks