• R/O
  • SSH
  • HTTPS

osmtools: Commit


Commit MetaInfo

Revision11 (tree)
Time2010-04-26 17:44:59
Authorargrath

Log Message

リファクタリング

Change Summary

Incremental Difference

--- ksj2/extract_lake.pl (revision 10)
+++ ksj2/extract_lake.pl (revision 11)
@@ -13,61 +13,28 @@
1313 });
1414
1515 my $x = XML::TreePP->new();
16-$x->set( force_array => [ 'jps:GM_Surface.patch', 'jps:GM_SurfaceBoundary.exterior', 'jps:GM_SurfaceBoundary.interior' ] );
16+$x->set( force_array => [
17+ 'jps:GM_Surface.patch',
18+ 'jps:GM_SurfaceBoundary.exterior',
19+ 'jps:GM_SurfaceBoundary.interior',
20+ ] );
1721 $x->set( utf8_flag => 1 );
1822 my $h = $x->parse($ksj->xml);
1923
2024 my $base = $h->{"ksj:GI"}->{dataset}->{'ksj:object'}->{'ksj:AA01'}->{'ksj:OBJ'};
2125
22-my %point = %{$ksj->point};
2326 my %curve = %{$ksj->curve};
24-my %pointid = %{$ksj->pointid};
25-my %pointname = %{$ksj->pointname};
2627 my $newid = $ksj->newid;
2728
2829 ######################################################################
2930
30-my %orientable_curve;
31-{
32- my $s = $base->{'jps:GM_OrientableCurve'};
31+$ksj->parse_orientable_curve($base);
3332
34-#print Dumper($s);
33+$ksj->parse_surface($base);
3534
36- for (@$s){
37- my $id = $_->{'-id'};
38- my $vals = $_->{'jps:GM_OrientablePrimitive.primitive'}->{'-idref'};
35+my %surface = %{$ksj->surface};
3936
40- $orientable_curve{$id} = $vals;
41- }
42-}
43-
44-my %surface;
4537 {
46- my $s = $base->{'jps:GM_Surface'};
47-
48- for (@$s){
49- my %s;
50- my @inner = ();
51- my @outer = ();
52- my $id = $_->{'-id'};
53- for (@{$_->{'jps:GM_Surface.patch'}}){
54- my $v1 = $_->{'jps:GM_Polygon'}->{'jps:GM_Polygon.boundary'}->
55- {'jps:GM_SurfaceBoundary'};
56- for (@{$v1->{'jps:GM_SurfaceBoundary.exterior'}}){
57- push @outer, $orientable_curve{$_->{'jps:GM_Ring'}->{'jps:GM_CompositeCurve.generator'}->{'-idref'}};
58- }
59- for (@{$v1->{'jps:GM_SurfaceBoundary.interior'}}){
60- push @inner, $orientable_curve{$_->{'jps:GM_Ring'}->{'jps:GM_CompositeCurve.generator'}->{'-idref'}};
61- }
62- }
63- $s{outer} = \@outer;
64- $s{inner} = \@inner;
65- $surface{$id} = \%s;
66- }
67-}
68-
69-#my %lake_name;
70-{
7138 my $s = $base->{'ksj:GC01'};
7239
7340 for (@$s){
@@ -109,7 +76,6 @@
10976
11077 my $id;
11178
112-
11379 for (@{$s->{outer}}){
11480 $id = $_;
11581 my %tag = %tagbase;
--- ksj2/extract_forest.pl (revision 10)
+++ ksj2/extract_forest.pl (revision 11)
@@ -13,44 +13,26 @@
1313 });
1414
1515 my $x = XML::TreePP::KSJ->new();
16-$x->set( force_array => [ 'jps:GM_SurfaceBoundary.interior' ] );
16+#$x->set( force_array => [ 'jps:GM_SurfaceBoundary.interior' ] );
17+$x->set( force_array => [
18+ 'jps:GM_Surface.patch',
19+ 'jps:GM_SurfaceBoundary.exterior',
20+ 'jps:GM_SurfaceBoundary.interior',
21+ ] );
1722 $x->set( utf8_flag => 1 );
1823 my $h = $x->parse($ksj->xml);
1924
2025 my $base = $h->{"ksj:GI"}->{dataset}->{'ksj:object'}->{'ksj:AA01'}->{'ksj:OBJ'};
2126
22-my %point = %{$ksj->point};
2327 my %curve = %{$ksj->curve};
24-my %pointid = %{$ksj->pointid};
25-my %pointname = %{$ksj->pointname};
2628 my $newid = $ksj->newid;
2729
2830 ######################################################################
2931
30-my %surface;
31-{
32- my $s = $base->{'jps:GM_Surface'};
32+$ksj->parse_surface($base);
3333
34- for (@$s){
35- my %s;
36- my @inner = ();
37- my $id = $_->{'-id'};
38-# my $v1 = $_->{'jps:GM_Surface.patch'}->{'jps:GM_Polygon'}->{'jps:GM_Polygon.boundary'}->
39-# {'jps:GM_SurfaceBoundary'}->{'jps:GM_SurfaceBoundary.exterior'}->
40-# {'jps:GM_Ring'}->{'jps:GM_CompositeCurve.generator'}->{'-idref'};
41- my $v1 = $_->{'jps:GM_Surface.patch'}->{'jps:GM_Polygon'}->{'jps:GM_Polygon.boundary'}->
42- {'jps:GM_SurfaceBoundary'};
43- $s{outer} = [$v1->{'jps:GM_SurfaceBoundary.exterior'}->
44- {'jps:GM_Ring'}->{'jps:GM_CompositeCurve.generator'}->{'-idref'}];
34+my %surface = %{$ksj->surface};
4535
46- for (@{$v1->{'jps:GM_SurfaceBoundary.interior'}}){
47- push @inner, $_->{'jps:GM_Ring'}->{'jps:GM_CompositeCurve.generator'}->{'-idref'};
48- }
49- $s{inner} = \@inner;
50- $surface{$id} = \%s;
51- }
52-}
53-
5436 my %used_curve;
5537 {
5638 my $s = $base->{'ksj:BF01'};
--- ksj2/Geo/KSJ.pm (revision 10)
+++ ksj2/Geo/KSJ.pm (revision 11)
@@ -219,6 +219,67 @@
219219 return $self->{fh};
220220 }
221221
222+sub surface {
223+ my $self = shift;
224+ return $self->{surface};
225+}
226+
227+sub parse_orientable_curve {
228+ my ($self, $base) = @_;
229+
230+ my %orientable_curve;
231+
232+ my $s = $base->{'jps:GM_OrientableCurve'};
233+
234+ for (@$s){
235+ my $id = $_->{'-id'};
236+ my $vals = $_->{'jps:GM_OrientablePrimitive.primitive'}->{'-idref'};
237+
238+ $orientable_curve{$id} = $vals;
239+ }
240+
241+ $self->{orientable_curve} = \%orientable_curve;
242+}
243+
244+sub parse_surface {
245+ my ($self, $base) = @_;
246+
247+ my %surface;
248+ my $orientable_curve = $self->{orientable_curve};
249+
250+ my $s = $base->{'jps:GM_Surface'};
251+
252+ for (@$s){
253+ my %s;
254+ my @inner = ();
255+ my @outer = ();
256+ my $id = $_->{'-id'};
257+ for (@{$_->{'jps:GM_Surface.patch'}}){
258+ my $v1 = $_->{'jps:GM_Polygon'}->{'jps:GM_Polygon.boundary'}->
259+ {'jps:GM_SurfaceBoundary'};
260+ for (@{$v1->{'jps:GM_SurfaceBoundary.exterior'}}){
261+ my $cid = $_->{'jps:GM_Ring'}->{'jps:GM_CompositeCurve.generator'}->{'-idref'};
262+ if(defined $orientable_curve){
263+ $cid = $$orientable_curve{$cid};
264+ }
265+ push @outer, $cid;
266+ }
267+ for (@{$v1->{'jps:GM_SurfaceBoundary.interior'}}){
268+ my $cid = $_->{'jps:GM_Ring'}->{'jps:GM_CompositeCurve.generator'}->{'-idref'};
269+ if(defined $orientable_curve){
270+ $cid = $$orientable_curve{$cid};
271+ }
272+ push @inner, $cid;
273+ }
274+ }
275+ $s{outer} = \@outer;
276+ $s{inner} = \@inner;
277+ $surface{$id} = \%s;
278+ }
279+
280+ $self->{surface} = \%surface;
281+}
282+
222283 sub filter_curve {
223284 my ($self, $used) = @_;
224285
Show on old repository browser