From 2c78883cbdd9d538f3d90b69d03cfd3f1c5716b6 Mon Sep 17 00:00:00 2001 From: Michael 'PoempelFox' Meier Date: Wed, 5 Aug 2015 10:06:21 +0200 Subject: [PATCH] fix my double-escape-FAIL --- scripts/osmbuildings-json-generator.pl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/osmbuildings-json-generator.pl b/scripts/osmbuildings-json-generator.pl index 502f91b..6970699 100755 --- a/scripts/osmbuildings-json-generator.pl +++ b/scripts/osmbuildings-json-generator.pl @@ -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); -- 2.25.1