ICompactPositionReportingGlobalDecode Method |
Namespace: VirtualRadar.Interface.Adsb
GlobalCoordinate GlobalDecode( CompactPositionReportingCoordinate earlyCpr, CompactPositionReportingCoordinate laterCpr, GlobalCoordinate receiverLocation )
Surface position coordinates (19-bit format) always decode to two possible latitudes and four possible longitudes. It is impossible to unambiguously determine which of those eight locations is the correct one, so the one closest to 'receiverLocation' is always chosen. If the receiver location is unknown then null is returned for 19-bit formats. The receiver location is ignored for all other formats.
The spec suggests that two messages are only globally decoded if they arrive within a certain time frame (10 seconds for airborne position messages, 25 to 50 seconds for surface position messages). This method does not police those time frames, it's up to the caller to determine whether two messages are suitable for global decoding. This is important to note. The algorithm does NOT give the right result if the distance between the two locations at which the messages were transmitted is larger than 3 nautical miles (about 5.5km) for 17 bit messages or 0.25 nmi (about 1.38km) for 19 bit messages. I learnt this the hard way when I stared at the code until my eyes bled when a unit test that was decoding 19-bit messages 5km apart was failing. In the test the j value was consistently out by 1. I would recommend following the rules for testing the reasonableness of a globally decoded location as laid out in the ICAO documentation.