fix my double-escape-FAIL
authorMichael 'PoempelFox' Meier <git@mulder.franken.de>
Wed, 5 Aug 2015 08:06:21 +0000 (10:06 +0200)
committerMichael 'PoempelFox' Meier <git@mulder.franken.de>
Wed, 5 Aug 2015 08:06:21 +0000 (10:06 +0200)
scripts/osmbuildings-json-generator.pl

index 502f91b3efdebf1c71570bc0b075a0a8ab9822b0..6970699dcd23c09258168a243cf4f31d37414521 100755 (executable)
@@ -190,12 +190,16 @@ foreach $xtable ('planet_osm_polygon1', 'planet_osm_polygon2', 'planet_osm_line'
       $hstoredec = Pg::hstore::decode($row->{'tags'});
     }
     my $levels = fetchlastofhr(1, $hstoredec, 'levels', 'building:levels');
-    my $height = fetchlastofhr($height, $hstoredec, 'height', 'building:height');
-    unless ($height =~ m/^[0-9.]+$/) { undef($height); }
+    my $height = fetchlastofhr(undef, $hstoredec, 'height', 'building:height');
+    unless ((defined($height)) && ($height =~ m/^[0-9.]+$/)) {
+      undef($height);
+    }
     my $minlevel = fetchlastofhr(0, $hstoredec,
                                  'min_levels', 'building:min_levels', 'min_level', 'building:min_level');
-    my $minheight = fetchlastofhr($minheight, $hstoredec, 'min_height', 'building:min_height');
-    unless ($minheight =~ m/^[0-9.]+$/) { undef($minheight); }
+    my $minheight = fetchlastofhr(undef, $hstoredec, 'min_height', 'building:min_height');
+    unless ((defined($minheight)) && ($minheight =~ m/^[0-9.]+$/)) {
+      undef($minheight);
+    }
     my $shape = fetchlastofhr(undef, $hstoredec, 'building:shape');
     my $material = fetchlastofhr(undef, $hstoredec,
                                  'building:material', 'building:facade:material', 'building:cladding');
@@ -263,20 +267,20 @@ foreach $xtable ('planet_osm_polygon1', 'planet_osm_polygon2', 'planet_osm_line'
     }
     if (defined($wallcolor)) {
       $wallcolor = JSON->new->allow_nonref->encode($wallcolor);
-      printwows("       \"wallColor\": \"$wallcolor\",\n");
+      printwows("       \"wallColor\": $wallcolor,\n");
     }
     if (defined($roofcolor)) {
       $roofcolor = JSON->new->allow_nonref->encode($roofcolor);
-      printwows("       \"roofColor\": \"$roofcolor\",\n");
+      printwows("       \"roofColor\": $roofcolor,\n");
     }
     if (defined($roofshape)) {
       if ($roofshape eq 'pyramidal') { $roofshape = 'pyramid'; }
       $roofshape = JSON->new->allow_nonref->encode($roofshape);
-      printwows("       \"roofShape\": \"$roofshape\",\n");
+      printwows("       \"roofShape\": $roofshape,\n");
     }
     if (defined($roofmaterial)) {
       $roofmaterial = JSON->new->allow_nonref->encode($roofmaterial);
-      printwows("       \"roofMaterial\": \"$roofmaterial\",\n");
+      printwows("       \"roofMaterial\": $roofmaterial,\n");
     }
     if (defined($roofheight)) {
       $roofheight = sprintf("%.1f", $roofheight);
This page took 0.052703 seconds and 4 git commands to generate.