Permalink
Browse files

cleaning up

  • Loading branch information...
1 parent 0741b6b commit 398ee14b667f6bafeb50b2907ae2568b5fb64591 James Michael DuPont committed Nov 27, 2011
View
@@ -1,30 +0,0 @@
-# This is the main configuration file of your Dancer app
-# env-related settings should go to environments/$env.yml
-# all the settings in this file will be loaded at Dancer's startup.
-
-# Your application's name
-appname: "OSM::API::Proxy"
-
-# The default layout to use for your application (located in
-# views/layouts/main.tt)
-layout: "main"
-
-# when the charset is set to UTF-8 Dancer will handle for you
-# all the magic of encoding and decoding. You should not care
-# about unicode within your app when this setting is set (recommended).
-charset: "UTF-8"
-
-# template engine
-# simple: default and very basic template engine
-# template_toolkit: TT
-
-#template: "simple"
-
-template: "template_toolkit"
-
-engines:
- template_toolkit:
- encoding: 'utf8'
- start_tag: '[%'
- end_tag: '%]'
-
@@ -1,215 +0,0 @@
-package OSM::API::OsmHistory::SaxHandler;
-use OSM::API::OsmObjects;
-use strict;
-use warnings;
-# borrowed from SAXOsmHandler - Osmrender implementation
-# http://svn.openstreetmap.org/applications/rendering/osmarender/orp/SAXOsmHandler.pm
-use YAML;
-sub new
-{
- my $class=shift;
- my $partno =shift;
-
- my $self={
- partno => $partno
- };
-
- return bless $self,$class;
-}
-use base qw(XML::SAX::Base);
-
-sub finish_current
-{
- my $self=shift;
- if (exists($self->{current}))
- {
- if ($self->{current})
- {
- my $type = ref $self->{current};
-# warn "check type $type";
- if ($type ne "HASH")
- {
- $self->{current}->Split();
-# warn Dump($self->{current}) if (keys %{$self->{current}{tags}});
- }
- delete $self->{current};
- $self->{current} = undef;
- }
- }
-
-}
-
-sub tagstats
-{
- my $self = shift;
- my $element = shift;
- my $name=$element->{Name};
-# warn "got $name\n";
- $self->{stats}{$name}++;# count the stats
-}
-sub tagstatsdump
-{
- my $self = shift;
- warn Dump($self->{stats});
-}
-
-sub start_element {
- my $self = shift;
- my $element = shift;
-# warn "Got element " . Dump($element);
- $self->tagstats($element);# count the stats
- if ($element->{Name} eq 'node')
- {
-
- my $n = OSM::API::OsmObjects::Node->new(
- {
- partno => $self->{partno},
- id => $element->{'Attributes'}{'{}id'}{"Value"},
- lat => $element->{'Attributes'}{'{}lat'}{"Value"},
- lon => $element->{'Attributes'}{'{}lon'}{"Value"},
- changeset => $element->{'Attributes'}{'{}changeset'}{"Value"},
- version => $element->{'Attributes'}{'{}version'}{"Value"},
- visible => $element->{'Attributes'}{'{}visible'}{"Value"},
- timestamp => $element->{'Attributes'}{'{}timestamp'}{"Value"}
- }
- );
- $n->Hash();
- $self->finish_current();# finish the last one
- $self->{current}=$n;
- }
- elsif ($element->{Name} eq 'tag')
- {
- $self->{current}{tags}{$element->{Attributes}{'{}k'}{Value}}= $element->{Attributes}{'{}v'}{Value};
- }
-
- elsif ($element->{Name} eq 'changeset')
- {
- my $n = OSM::API::OsmObjects::ChangeSet->new(
- {
- partno => $self->{partno},
- id => $element->{'Attributes'}{'{}id'}{"Value"},
- created_at => $element->{'Attributes'}{'{}created_at'}{"Value"},
- closed_at => $element->{'Attributes'}{'{}closed_at'}{"Value"},
- max_lon => $element->{'Attributes'}{'{}max_lon'}{"Value"},
- max_lat => $element->{'Attributes'}{'{}max_lat'}{"Value"},
- min_lon => $element->{'Attributes'}{'{}min_lon'}{"Value"},
- min_lat => $element->{'Attributes'}{'{}min_lat'}{"Value"},
- user => $element->{'Attributes'}{'{}user'}{"Value"},
- uid => $element->{'Attributes'}{'{}uid'}{"Value"},
- open => $element->{'Attributes'}{'{}open'}{"Value"}
- }
- );
- $n->Hash();
- $self->finish_current();# finish the last one
- $self->{current}=$n;
- }
- elsif ($element->{Name} eq 'way')
- {
- my $n = OSM::API::OsmObjects::Way->new(
- {
- partno => $self->{partno},
- id => $element->{'Attributes'}{'{}id'}{"Value"},
- changeset => $element->{'Attributes'}{'{}changeset'}{"Value"},
- version => $element->{'Attributes'}{'{}version'}{"Value"},
- visible => $element->{'Attributes'}{'{}visible'}{"Value"},
- timestamp => $element->{'Attributes'}{'{}timestamp'}{"Value"}
- }
- );
- $self->finish_current();# finish the last one
- $self->{current}=$n;
- }
- elsif ($element->{Name} eq 'relation')
- {
-
- my $n = OSM::API::OsmObjects::Relation->new(
- {
- partno => $self->{partno},
- id => $element->{'Attributes'}{'{}id'}{"Value"},
- changeset => $element->{'Attributes'}{'{}changeset'}{"Value"},
- version => $element->{'Attributes'}{'{}version'}{"Value"},
- visible => $element->{'Attributes'}{'{}visible'}{"Value"},
- timestamp => $element->{'Attributes'}{'{}timestamp'}{"Value"},
- user => $element->{'Attributes'}{'{}user'}{"Value"},
- uid => $element->{'Attributes'}{'{}uid'}{"Value"}
- }
- );
- $self->finish_current();# finish the last one
- $self->{current}=$n;
-
-# undef $self->{current};
-# return if defined $element->{'Attributes'}{'action'}
-# && $element->{'Attributes'}{'action'} eq 'delete';
-
-# my $id = $element->{'Attributes'}{'id'};
-# # $self->{relation}{$id} =
-# # $self->{current} = {id => $id,
-# # user => $element->{'Attributes'}{'user'},
-# # timestamp => $element->{'Attributes'}{'timestamp'},
-# # members => [],
-# # relations => [] };
-# bless $self->{current}, 'relation';
- }
- elsif ($element->{Name} eq 'nd')
- {
-# warn Dump()
- push(@{$self->{current}{'nodes'}},
- $element->{'Attributes'}->{'{}ref'}{Value});
-# $self->{node}{
- }
- elsif (($element->{Name} eq 'member') )
- {
-# warn Dump($element);
-# Attributes:
-# '{}ref':
-# Value: 8662500
-# '{}role':
-# Name: role
-# Value: ''
-# '{}type':
-# Value: way
- push(
- @{
-
- $self->{current}{'members'}
- {
- $element->{'Attributes'}->{'{}type'}{Value}
- }
- {
- $element->{'Attributes'}->{'{}role'}{Value}
- }
-
- },
- $element->{'Attributes'}->{'{}ref'}{Value}
- );
-
- # relation members are temporarily stored as symbolic references (e.g. a
- # string that contains "way:1234") and only later replaced by proper
- # references.
-# push(@{$self->{current}{'members'}},
-# [ $element->{Attributes}{role},
-# $element->{Attributes}{type}.':'.
-# $element->{Attributes}{ref } ]);
- }
- elsif ($element->{Name} eq 'bounds')
- {
- # my $b = $self->{bounds}; # Just a shortcut
- # my $minlat = $element->{Attributes}{minlat};
- # my $minlon = $element->{Attributes}{minlon};
- # my $maxlat = $element->{Attributes}{maxlat};
- # my $maxlon = $element->{Attributes}{maxlon};
-
- # $b->{minlat} = $minlat if !defined($b->{minlat}) || $minlat < $b->{minlat};
- # $b->{minlon} = $minlon if !defined($b->{minlon}) || $minlon < $b->{minlon};
- # $b->{maxlat} = $maxlat if !defined($b->{maxlat}) || $maxlat > $b->{maxlat};
- # $b->{maxlon} = $maxlon if !defined($b->{maxlon}) || $maxlon > $b->{maxlon};
- }
- else
- {
- # ignore for now
- }
-
- # do something
- #$self->{Handler}->start_element($data); # BAD
- }
-
-1;
@@ -1,108 +0,0 @@
-package OSM::API::OsmObjects::Relation;
-use strict;
-use warnings;
-use File::Path qw(make_path remove_tree);
-use YAML;
-
-our @ISA = qw[OSM::API::OsmObjects::BaseGeo];
-BEGIN
-{
- open RPT, ">data/debugreportrelation.txt";
-}
-
-END
-{
- close RPT;
-}
-
-sub new
-{
- my $class=shift;
- my $self =shift;
- $self->{tags}= $self->{tags} ||{}; # create an empty hash of the tags
- $self->{nodes}= $self->{nodes} ||[]; # create an empty array of the nodes
- return bless $self,$class;
-}
-sub hash
-{
- my $self=shift;
- $self->{hash}="todo12";
-}
-
-sub Split
-{
- my $self =shift;
- #write this node to the right file
- my $hash = $self->hash();
- my @path = split (//, $hash);
-
- my $split = 5;
- my $len = scalar(@path);
- if ($len <= $split)
- {
- $split = $len -2; # 1
- }
-
- my @dirs = @path[0 .. $split];
- my @name = @path[$split+1 .. scalar(@path) -1];
-# my $test= join ("/",@path);
- my $out= "output/" . join ("/",@dirs);
- my $out_file= join ("",@name);
- make_path($out);
-
- print RPT $self->SUPER::BasicInfoStr("$hash is split to $out and $out_file");
- my $file = $out. "/nodes_" . ${out_file} . "_p" . $self->{partno} . ".osm";
- open OUT,">>$file";
- binmode OUT, ":utf8";
-#<relation id="2284" version="9" timestamp="2008-12-16T17:03:15Z" changeset="419694" user="Cerritus" uid="12919" visible="true"><member type="node" ref="41847021" role="stop_5"/><member type="node" ref="46932840" role="stop_9"/><
- my $str = "<relation " . join (" ",
- map {
- if ($self->{$_})
- {
- $_ . "='" . $self->{$_} . "'"
- }
- else
- {
- ""
- }
- } ('id', 'uid', 'user', 'visible', 'version', 'changeset')
- ) ;
- $str .= ">"; # end of node start
- # emit the tags, very cheap
- $str .= join (" ", map {
- my $k = $_;
- my $v = $self->{tags}{$k};
- "<tag k='$k' v='$v' />"
- } (keys %{$self->{tags}})) ;
-
-
- my @types = (keys %{$self->{members}});
- $str .= join (" ", map
- {
- my $type = $_;
- map {
- my $role = $_;
- map {
- my $ref=$_;
- "<member type=$type role=$role ref=$ref/>";
- } (@{$self->{members}{$type}{$role}});
- } (keys %{$self->{members}{$type}});
- } @types
- );
- $str .= "</relation>\n;";
-
- print OUT $str;
- close OUT;
-}
-
-sub addMember
-{
- my $self=shift;
- my $type=shift;
- my $role=shift;
- my $ret=shift;
-
- push(@{$self->{'members'}{$type}{$role}},$ref);
-
-}
-1;
Oops, something went wrong.

0 comments on commit 398ee14

Please sign in to comment.