#!/usr/bin/perl

# Copyright (C) 2005  Sylvain Beucler
# This work is distributed under the W3C(R) Software License [1] in
# the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231

# This script will cleanup the original airport.rdf file. It takes
# advantage of its structure in paragraphs, and removes all airports
# without location information.

use strict;

open(FH, "< airports.rdf");

my $paragraph;
while (<FH>) {
    $paragraph .= $_;
    if (/^\n$/) {
	if ($paragraph =~ /<apt:Airport.*?\/apt:Airport>\n\n/s) {
	    if ($paragraph =~ /latitude/) {
		print $paragraph;
	    }
	}
	undef $paragraph;
    }
}
