#!/usr/bin/env python # -*- coding: utf-8 -*- # $Id: gpsopt.py 120 2007-06-15 09:06:17Z alex $ ################################################################################ # # Copyright (C) 2007 Alexander König # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed 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. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ################################################################################ import sys,math lastplot = None mindelta = float(sys.argv[2]) for line in open(sys.argv[1]): if line.startswith('B'): try: (x,y,h) = (line[7:14], line[15:23], line[31:35]) plot = (float(x), float(y), float(h)) if lastplot != None: (dx, dy, dh) = (lastplot[0]-plot[0],lastplot[1]-plot[1],lastplot[2]-plot[2]) delta = math.sqrt(dx*dx+dy*dy+dh*dh) if delta > mindelta: print line, lastplot = plot else: print line, lastplot = plot pass except: print 'error: ', line else: print line,