#!/usr/bin/perl -w
# -*- perl -*-

#
# $Id: smsbbbike,v 1.3 2003/01/08 20:10:42 eserte Exp $
# Author: Slaven Rezic
#
# Copyright (C) 2001 Slaven Rezic. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# Mail: slaven@rezic.de
# WWW:  http://bbbike.sourceforge.net
#

package BBBikeRouting::SMS;
use FindBin;
use lib $FindBin::RealBin;
use BBBikeRouting;
@ISA = 'BBBikeRouting';
use strict;
require 'cmdbbbike'; # for BBBikeRouting::Cmdline

sub sms_input {
    shift->BBBikeRouting::Cmdline::cmdline_input(@_);
}

sub sms_output {
    my $self = shift;

    my $first = 1;
    foreach (@{ $self->RouteInfo }) {
	if ($_->{Street}) {
	    if (defined $_->{Way} && $_->{Way} ne '') {
		print "*" . substr($_->{Way}, -1) . "*";
	    } elsif ($first) {
		$first = 0;
	    } else {
		print ",";
	    }
	    print Strasse::short($_->{Street}, 3);
	} else {
	    print ":" . $_->{Whole} . ".\n";
	}
    }
    # ja, nein?
#XXX
#      if (0 && ($multi_from || $multi_to)) {
#  	print "Route von $from_street ($from_citypart) nach $to_street ($to_citypart)\n";
#      }
}

return 1 if caller() or keys %Devel::Trace::; # XXX Tracer bug

package main;

my $routing = BBBikeRouting->new->init_context;
bless $routing, 'BBBikeRouting::SMS'; # 5.005 compat

$routing->sms_input();
$routing->search();
$routing->sms_output();

__END__
