All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: Java FlightXML Program Print Altitudes
PostPosted: Mon Aug 03, 2015 12:51 pm 
Offline
RSonecha - FlightAware user avatar

Joined: Thu Jul 30, 2015 4:35 pm
Posts: 13
I am using the Netbeans version of the Flight XML Java code. I was wondering if there is a way to print out all the altitudes and timings for a flight, given the airline and flight number. Does anyone have any code that does this, or any tips on what methods and classes to use?
Thanks for the help!


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Tue Aug 04, 2015 4:39 pm 
Offline
RSonecha - FlightAware user avatar

Joined: Thu Jul 30, 2015 4:35 pm
Posts: 13
I found this: http://flightxml.flightaware.com/soap/FlightXML2/doc#op_GetFlightID (the getHistoricalTrackInformation operator)

Now the problem is that I don't know where to find the faFlightID. I would use the getFlightID operation, but I don't have an enterprise membership, thus I do not have access to the ident. Is there a workaround for this?

Thanks!


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Wed Aug 05, 2015 2:24 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1423
Location: FlightAware WHQ
FlightInfoEx includes the faFlightID of each flight that it returned.


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Wed Aug 05, 2015 5:32 pm 
Offline
RSonecha - FlightAware user avatar

Joined: Thu Jul 30, 2015 4:35 pm
Posts: 13
Can you show me an example of how to use that to get the data I need?

Given a specific flight I'm looking for something along the lines of:

Time Alt
3:34 1000 ft
3:40 15,000 ft
etc.


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Wed Aug 05, 2015 6:00 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1423
Location: FlightAware WHQ
Call FlightInfoEx with the ident of the flight you are interested in (such as the most recent one that has arrived), then call GetHistoricalTrack to get the position data for it. Here's some pseudocode:

Code:
flights = FlightInfoEx(ident => "UAL5",  howMany => 10, offset => 0);
foreach (flight in flights) {
   if (flight.actualdeparturetime > 0 && flight.actualarrivaltime > 0) {
       track = GetHistoricalTrack(faFlightID => flight.faFlightId);
       foreach (pos in track.data) {
          println EpochToHuman(pos.timestamp), pos.altitude
       }
       break
   }
}


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Thu Aug 06, 2015 11:59 am 
Offline
RSonecha - FlightAware user avatar

Joined: Thu Jul 30, 2015 4:35 pm
Posts: 13
Thank you!


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Thu Aug 06, 2015 4:21 pm 
Offline
RSonecha - FlightAware user avatar

Joined: Thu Jul 30, 2015 4:35 pm
Posts: 13
FlightInfoExRequest flight_req = new FlightInfoExRequest();
flight_req.setHowMany(1);
flight_req.setIdent("UAL468");
flight_req.setOffset(0);
FlightInfoExResult flight = df.FlightInfoEx(flight_req);
if (flight.actualDepartureTime > 0 && flight.actualarrivaltime > 0){
GetHistoricalTrackRequest track = new GetHistoricalTrackRequest();
track.setFaFlightID(flight.faFlightID);
for(pos:track.data){
System.out.println(EpochToHuman(pos.timestamp) "\t" pos.altitude);


}
}

Here is my code so far. The parts in red are where I am getting errors. Can you tell me what is wrong?


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Thu Aug 06, 2015 4:31 pm 
Offline
RSonecha - FlightAware user avatar

Joined: Thu Jul 30, 2015 4:35 pm
Posts: 13
Also, how can I tweak the code to give me the altitude data for a specific flight. For example the UAL468 flight on April 9th from SEA to SFO at 7:41am (http://flightaware.com/live/flight/UAL468/history/20150409/1425Z/KSEA/KSFO). Is there an ID for that specific flight, and if so, where do I find it and how do I incorporate it into my code?


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Fri Aug 07, 2015 12:04 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1423
Location: FlightAware WHQ
RSonecha wrote:
FlightInfoExRequest flight_req = new FlightInfoExRequest();
flight_req.setHowMany(1);
flight_req.setIdent("UAL468");
flight_req.setOffset(0);
FlightInfoExResult flight = df.FlightInfoEx(flight_req);
if (flight.actualDepartureTime > 0 && flight.actualarrivaltime > 0){
GetHistoricalTrackRequest track = new GetHistoricalTrackRequest();
track.setFaFlightID(flight.faFlightID);
for(pos:track.data){
System.out.println(EpochToHuman(pos.timestamp) "\t" pos.altitude);


}
}

Here is my code so far. The parts in red are where I am getting errors. Can you tell me what is wrong?


Do not use howMany of 1. You will only get one flight (and that is probably not the one flight you want, since it is likely to be a future flight that hasn't occurred yet). FlightInfoEx will be returning an array of flights, even if it is an array of 1 element.

For the Java, you will need to actually look at the auto-generated interface bindings that were produced by the Axis command-line program, in order to figure out the names of the classes and methods. Most of the structure members are accessed using accessors, rather than directly, I think. (For example actualDepartureTime and actualarrivaltime)

The function "EpochToHuman" does not actually exist, since my example was pseudo-code. You will need to find the appropriate conversion for Java, or implement your own. Additionally, I think Java will require you to combine those strings using "+" at least.


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Fri Aug 07, 2015 12:19 pm 
Offline
RSonecha - FlightAware user avatar

Joined: Thu Jul 30, 2015 4:35 pm
Posts: 13
I'm sorry, I'm not sure I understand what you mean by "Most of the structure members are accessed using accessors". How would you suggest I change my code? I'm pretty new to Java, so I need a little more help, please. Thanks!


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Fri Aug 07, 2015 1:18 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1423
Location: FlightAware WHQ
Did you run the wsdl2java.sh utility yet, as shown in the example? You need to do that before attempting to develop against any of these interfaces. Once you've done that, you will be able to explore the generated java interface file and see what the automatically generated names of the structures and methods are, and how they are nested.

In Java, an "accessor" is a method to get or set a member variable. For example, "setHowMany()" is a setter method for the "howMany" variable, which you would not simply access directly.

If you are unfamiliar with Java development and encountering syntax errors during compilation, you may want to seek other programming books/references first, as I am not prepared to teach programming fundamentals.


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Thu Feb 23, 2017 11:35 am 
Offline
Staf12 - FlightAware user avatar

Joined: Thu Jun 23, 2016 3:59 am
Posts: 6
bovineone wrote:
Call FlightInfoEx with the ident of the flight you are interested in (such as the most recent one that has arrived), then call GetHistoricalTrack to get the position data for it. Here's some pseudocode:

Code:
flights = FlightInfoEx(ident => "UAL5",  howMany => 10, offset => 0);
foreach (flight in flights) {
   if (flight.actualdeparturetime > 0 && flight.actualarrivaltime > 0) {
       track = GetHistoricalTrack(faFlightID => flight.faFlightId);
       foreach (pos in track.data) {
          println EpochToHuman(pos.timestamp), pos.altitude
       }
       break
   }
}


is there any other condition (except departure and arrival times) which can filter out useless flight IDs? for example, I am trying to get tracks of BAW2653, so I called
Code:
https://flightxml.flightaware.com/json/FlightXML2/FlightInfoEx?ident=baw2653&howmany=1&offset=0

to get flight IDs for future use with GetHistoricalTrack. it returned 15 (I dont know why when I set howMany to 1) results, including
Code:
{"faFlightID":"BAW2653-1487571930-airline-0283:0","ident":"BAW2653","aircrafttype":"A320","filed_ete":"01:54:00","filed_time":1487681960,"filed_departuretime":1487757900,"filed_airspeed_kts":332,"filed_airspeed_mach":"","filed_altitude":0,"route":"","actualdeparturetime":1487758080,"estimatedarrivaltime":1487764500,"actualarrivaltime":1487764511,"diverted":"","origin":"LOWS","destination":"EGKK","originName":"Salzburg (W. A. Mozart)","originCity":"Salzburg, Salzburg","destinationName":"London Gatwick","destinationCity":"London, England"}
and when I use this one in a call
Code:
https://flightxml.flightaware.com/json/FlightXML2/GetHistoricalTrack?faFlightID=BAW2653-1487571930-airline-0283:0

the result is "{"error":"no data available"}"


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Tue Feb 28, 2017 11:30 am 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1423
Location: FlightAware WHQ
You are calling it with "howmany" not "howMany" (case sensitive), so the argument was ignored.

In any case, you do not want to pass 1 for howMany.. You definitely want more than one so that your application can pick which flight it wants. The first one is almost always not the one most people actually want, since that is one furthest in the future that we are tracking.

That also explains why GetHistoricalTrack is failing for that flight. It is so far in the future that it has not occurred yet and we do not have a track for it yet.


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Wed Mar 01, 2017 9:12 am 
Offline
Staf12 - FlightAware user avatar

Joined: Thu Jun 23, 2016 3:59 am
Posts: 6
thanks! it was my mistake with the case sensitivity :roll:

the second explanation, maybe my calculator is wrong, but I think it wasn't about future. based on the timestamp that flight occurred before my call/post (flightID: 1487571930 = Monday, February 20, actual duration of the flight: Feb 22 from 11:09AM to 12:54 PM, my call: Thu Feb 23, 2017). Now, with the same call I get a valid result.


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Wed Mar 01, 2017 10:49 am 
Offline
FlightAware Staff
obj - FlightAware user avatar

Joined: Tue Sep 30, 2014 7:14 pm
Posts: 3327
Staf12 wrote:
flightID: 1487571930 = Monday, February 20

The number in the flight ID has nothing to do with the time of the flight. Flight IDs are opaque identifiers, you shouldn't try to interpret them.


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Thu Mar 02, 2017 3:31 am 
Offline
Staf12 - FlightAware user avatar

Joined: Thu Jun 23, 2016 3:59 am
Posts: 6
that's exactly why I emphasized also that the flight itself occurred a day before my query


Top
 Profile  
 
 Post subject: Re: Java FlightXML Program Print Altitudes
PostPosted: Thu Mar 02, 2017 12:23 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1423
Location: FlightAware WHQ
GetHistoricalTrack is generally intended only for past flights that have already arrived. (There may also be a slight database replication delay of a few minutes between when a flight arrives and when it is available from GetHistoricalTrack.)

If the flight is still the most recent flight then GetLastTrack can still be used.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to: