osm2navit_LDADD = @NAVIT_LIBS@ @ZLIB_LIBS@
-samplemap: maps/$(SAMPLE_MAP).txt
+samplemap: maps/$(SAMPLE_MAP).bin
-maps/$(SAMPLE_MAP).osm:
+maps/$(SAMPLE_MAP).osm.bz2:
echo "Downloading osm sample map"
mkdir -p maps
- wget -O maps/$(SAMPLE_MAP).osm.tmp http://navit.sourceforge.net/maps/$(SAMPLE_MAP).osm
- mv maps/$(SAMPLE_MAP).osm.tmp maps/$(SAMPLE_MAP).osm
+ wget -O maps/$(SAMPLE_MAP).osm.bz2.tmp http://navit.sourceforge.net/maps/$(SAMPLE_MAP).osm.bz2
+ mv maps/$(SAMPLE_MAP).osm.bz2.tmp maps/$(SAMPLE_MAP).osm.bz2
-maps/$(SAMPLE_MAP).txt: maps/$(SAMPLE_MAP).osm $(top_srcdir)/src/script/osm2navit
+maps/$(SAMPLE_MAP).bin: maps/$(SAMPLE_MAP).osm.bz2 $(top_srcdir)/src/osm2navit
echo "Converting osm sample map"
- $(top_srcdir)/src/script/osm2navit <maps/$(SAMPLE_MAP).osm >maps/$(SAMPLE_MAP).txt.tmp
- mv maps/$(SAMPLE_MAP).txt.tmp maps/$(SAMPLE_MAP).txt
+ bzcat maps/$(SAMPLE_MAP).osm.bz2 | $(top_srcdir)/src/osm2navit >maps/$(SAMPLE_MAP).bin.tmp
+ mv maps/$(SAMPLE_MAP).bin.tmp maps/$(SAMPLE_MAP).bin
distclean-local:
- rm -f maps/$(SAMPLE_MAP).osm maps/$(SAMPLE_MAP).txt
+ rm -f maps/$(SAMPLE_MAP).osm.bz2 maps/$(SAMPLE_MAP).bin
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
+#include <getopt.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
node_hash=g_hash_table_new(NULL, NULL);
node_buffer_to_hash();
}
- } else
- g_hash_table_insert(node_hash, (gpointer)(ni->id), (gpointer)(ni-(struct node_item *)node_buffer.base));
+ } else
+ if (!g_hash_table_lookup(node_hash, (gpointer)(ni->id)))
+ g_hash_table_insert(node_hash, (gpointer)(ni->id), (gpointer)(ni-(struct node_item *)node_buffer.base));
+ else
+ node_buffer.size-=sizeof(struct node_item);
+
}
static int
{
FILE *tmp1,*tmp2;
char *map=g_strdup(attrmap);
+ int c;
+
+ while (1) {
+#if 0
+ int this_option_optind = optind ? optind : 1;
+#endif
+ int option_index = 0;
+ static struct option long_options[] = {
+ {"dedupe-ways", 0, 0, 'w'},
+ {0, 0, 0, 0}
+ };
+ c = getopt_long (argc, argv, "w", long_options, &option_index);
+ if (c == -1)
+ break;
+ switch (c) {
+ case 'w':
+ dedupe_ways_hash=g_hash_table_new(NULL, NULL);
+ break;
+ case '?':
+ exit(1);
+ break;
+ default:
+ printf("c=%d\n", c);
+ }
+
+ }
build_attrmap(map);
+
+
#if 1
tmp1=fopen("tmpfile1","w+");
fprintf(stderr,"PROGRESS: Phase 1: collecting data\n");
+++ /dev/null
-#!/usr/bin/perl
-use Data::Dumper;
-sub deg
-{
- my ($deg, $dir)=(@_);
-
- my ($in,$degi);
-
- $in=$deg;
- $degi=int($deg);
- $deg-=$degi;
- $deg*=60;
- return sprintf("%d%09.6f %s", $degi, $deg, $dir);
-}
-
-sub coord
-{
- my ($id)=(@_);
- return deg($lat{$id}, "N") . " " . deg($lon{$id}, "E");
-}
-
-$types={
- 'amenity'=>{
- },
- 'building'=>{
- },
- 'highway'=>{
- 'cycleway' => 'street_nopass',
- 'footway' => 'street_nopass',
- 'steps' => 'street_nopass',
- 'cyclepath' => 'street_nopass',
- 'track' => 'street_nopass',
- 'service' => 'street_nopass',
- 'pedestrian' => 'street_nopass',
- 'residential' => 'street_1_city',
- 'unclassified' => 'street_1_city',
- 'tertiary' => 'street_2_city',
- 'secondary' => 'street_3_city',
- 'primary' => 'street_4_city',
- 'trunk' => 'street_4_city',
- 'trunk_link' => 'ramp',
- 'motorway' => 'highway_city',
- 'motorway_link' => 'ramp',
- },
- 'landuse'=>{
- 'allotments' => 'wood',
- 'cemetery' => 'cemetery_poly',
- },
- 'leisure'=>{
- 'park' => 'park_poly',
- },
- 'natural'=>{
- 'wood' => 'wood',
- 'water' => 'water_poly',
- },
- 'place'=>{
- 'suburb' => 'town_poly',
- },
- 'railway'=>{
- 'rail' => 'rail',
- 'subway' => 'rail',
- 'tram' => 'rail',
- },
- 'waterway'=>{
- 'canal' => 'water_line',
- 'river' => 'water_line',
- 'weir' => 'water_line',
- 'stream' => 'water_line',
- 'drain' => 'water_line',
- },
-};
-
-while (<>) {
- $line = $_;
- chomp($line);
- if ($line =~ /<(\/[^? ]+)>/) {
- $tag=$1;
- } elsif ($line =~ /<([^? ]+)(.*)/) {
- $tag=$1;
- $line = $2;
- %attr=();
- while ($line =~ / ([^'"=]+)=['"]([^'"]*)['"](.*)/) {
- $attr{$1}=$2;
- $line=$3;
- }
- } else {
- if ($line =~ /<\?xml/) {
- next;
- }
- print STDERR "Unknown $line\n";
- next;
- }
- #print "tag=$tag\n";
- if ($tag eq 'node') {
- $lat{$attr{'id'}} = $attr{'lat'};
- $lon{$attr{'id'}} = $attr{'lon'};
- $creference{$attr{'id'}} = 0;
- %tag=();
- } elsif ($tag eq '/node') {
- } elsif ($tag eq 'segment') {
- $from{$attr{'id'}} = $attr{'from'};
- $to{$attr{'id'}} = $attr{'to'};
- $creference{$attr{'from'}}++;
- $creference{$attr{'to'}}++;
- $reference{$attr{'id'}} = 0;
- %tag=();
- } elsif ($tag eq 'tag') {
- if ($attr{'k'} ne 'created_by' && $attr{'k'} ne 'converted_by') {
- $tag{$attr{'k'}}=$attr{'v'};
- }
- } elsif ($tag eq 'way') {
- %tag=();
- $coords="";
- $in_way=1;
- $way_id=$attr{'id'};
- $start='';
- $end='';
- } elsif ($tag eq 'seg') {
- if ($in_way) {
- $from=coord($from{$attr{'id'}});
- $to=coord($to{$attr{'id'}});
- $reference{$attr{'id'}}++;
- if ($start eq '') {
- $start=$from;
- $end=$to;
- $coords="$start\n$end\n";
- #$start="dummy";
- #$end="dummy";
- } else {
- if ($creference{$from{$attr{'id'}}} > 2 || $creference{$from{$attr{'id'}}} > 2) {
- $start="dummy";
- $end="dummy";
- }
- if ($start eq $from) {
- $coords="$to\n" . $coords;
- $start=$to;
- } elsif ($start eq $to) {
- $coords="$from\n" . $coords;
- $start=$from;
- } elsif ($end eq $from) {
- $coords.=$to . "\n";
- $end=$to;
- } elsif ($end eq $to) {
- $coords.=$from . "\n";
- $end=$from;
- } else {
- push(@coords,$coords);
- #print STDERR "not connected from=$from to=$to start=$start end=$end\n";
- $start=$from;
- $end=$to;
- $coords="$start\n$end\n";
- #$start="dummy";
- #$end="dummy";
- #exit(0);
- }
- }
- }
- } elsif ($tag eq '/node') {
- if (%tag) {
- #print STDERR Dumper(\%tag);
- }
- } elsif ($tag eq '/segment') {
- if (%tag) {
- #print STDERR Dumper(\%tag);
- }
- } elsif ($tag eq '/way') {
- $type='';
- while (($key, $value) = each %$types) {
- if ($tag{$key} ne '') {
- $tagval=$tag{$key};
- $newtype=$types->{$key}->{$tagval};
- if ($newtype eq '') {
- $types->{$key}->{$tagval}='street_unkn';
- print STDERR "Unknown $key $tagval\n";
- $newtype='street_unkn';
- }
- if ($type ne '') {
- print STDERR "conflict way $way_id\n";
- #print STDERR Dumper(\%tag);
- }
- $type=$newtype;
- }
- }
- if ($type eq '') {
- print STDERR "Unknown way type:\n";
- print STDERR Dumper(\%tag);
- $type='street_unkn';
- }
- $oline="type=$type";
- if ($tag{'name'} ne '') {
- $oline.=' label="' . $tag{'name'} . '"';
- }
- if ($tag{'oneway'} eq 'true' || $tag{'oneway'} eq 'yes') {
- $oline.=' limit=1';
- }
- $oline .= ' debug="way_id=' . $way_id . ' ';
- while (($key,$value)=each(%tag)) {
- $oline .= "$key='$value' ";
- }
- $oline .= "\"\n";
- if ($coords ne "") {
- push(@coords,$coords);
- }
- foreach $coords (@coords) {
- print $oline;
- print $coords;
- }
- @coords=();
- } elsif ($tag ne 'osm' && $tag ne '/osm' && $tag ne 'bound') {
- print STDERR "Unknown $tag\n";
- }
-}
-#print STDERR Dumper($types);
-
-#while (($key,$value)=each(%reference)) {
-# if ($value != 1) {
-# print STDERR "$key $value\n";
-# }
-#}
-