svnno****@sourc*****
svnno****@sourc*****
2010年 4月 8日 (木) 19:11:00 JST
Revision: 2 http://sourceforge.jp/projects/osmtools/svn/view?view=rev&revision=2 Author: argrath Date: 2010-04-08 19:10:59 +0900 (Thu, 08 Apr 2010) Log Message: ----------- 空港データ変換スクリプトを追加 Added Paths: ----------- ksj2/extract_airport.pl Added: ksj2/extract_airport.pl =================================================================== --- ksj2/extract_airport.pl (rev 0) +++ ksj2/extract_airport.pl 2010-04-08 10:10:59 UTC (rev 2) @@ -0,0 +1,104 @@ +#! /usr/bin/perl +use strict; +use warnings; +use XML::TreePP; +use Data::Dumper; +use utf8; + +use Geo::KSJ; + +#binmode(STDOUT, ':encoding(shift_jis)'); + +my $x = XML::TreePP->new(); + +#my $h = $x->parsefile('C23-06_30.xml'); +my $h = $x->parsefile('C28-07.xml'); # 空港 + +my $ksj = Geo::KSJ->new($h, { + generator => 'extract_airport.pl', +}); + +my $base = $h->{"ksj:GI"}->{dataset}->{'ksj:object'}->{'ksj:AA01'}->{'ksj:OBJ'}; + +my %point = %{$ksj->point}; +my %curve = %{$ksj->curve}; +my %pointid = %{$ksj->pointid}; +my %pointname = %{$ksj->pointname}; +my $newid = $ksj->newid; + +my %surface; +{ + my $s = $base->{'jps:GM_Surface'}; + +#print Dumper($s); + + for (@$s){ + my $id = $_->{'-id'}; + my $vals = $_->{'jps:GM_Surface.patch'}->{'jps:GM_Polygon'}->{'jps:GM_Polygon.boundary'}-> + {'jps:GM_SurfaceBoundary'}->{'jps:GM_SurfaceBoundary.exterior'}-> + {'jps:GM_Ring'}->{'jps:GM_CompositeCurve.generator'}->{'-idref'}; + + $surface{$id} = $vals; + } +} + +my %terminal; +my %terminalid; + +{ + my $terminal = $base->{'ksj:CF04'}; + for (@$terminal){ + my $idname = $_->{'-id'}; + my $val = $_->{'ksj:POS'}->{'-idref'}; + my $id = $pointname{$val}; + if(!defined $id){ + warn $idname; + next; + } + + $terminal{$idname} = $id; + $terminalid{$id} = $idname; + } +} + +my %airport; + +{ + my $airport = $base->{'ksj:CF02'}; + for (@$airport){ + my $id = $_->{'-id'}; + my $name = $_->{'ksj:NA3'}; + my $s = $_->{'ksj:ARE'}->{'-idref'}; + + $airport{$id} = [$name, $s]; + } +} + +###################################################################### + +my $fw = $ksj->open('airport.osm'); + +sub subs { + my ($x, $params) = @_; + my %ret = (); + + if(defined $params->{$x}){ + $ret{aeroway} = 'terminal'; + } + return %ret; +} + +$ksj->put_point(\&subs, \%terminalid); + +for (sort keys %curve){ + my $id = $_; + my %tag = ( + source => "MLIT, Japan", + 'source:ja' => "国土数値情報(空港データ)平成19年 国土交通省", + source_ref => 'http://nlftp.mlit.go.jp/ksj/jpgis/datalist/KsjTmplt-C28-v1_1.html', + aeroway => 'aerodrome', + ); + $ksj->put_curve_1($id, $newid--, $curve{$id}, \%tag); +} + +$ksj->close;