From 6b3575c270a427fa54f4f13827012a182b099b55 Mon Sep 17 00:00:00 2001 From: Michael 'PoempelFox' Meier Date: Wed, 5 Aug 2015 09:43:29 +0200 Subject: [PATCH] some more fields taken from new osmbuildings doc about server interface --- scripts/osmbuildings-json-generator.pl | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/osmbuildings-json-generator.pl b/scripts/osmbuildings-json-generator.pl index cc59f15..502f91b 100755 --- a/scripts/osmbuildings-json-generator.pl +++ b/scripts/osmbuildings-json-generator.pl @@ -18,6 +18,7 @@ $y2 = 49.58; use DBI; use POSIX qw(strftime mktime); use Pg::hstore; +use JSON; # Par. 0: Level on which this gets printed # Par. 1: Text @@ -122,7 +123,7 @@ foreach $a (@ARGV) { if (defined($ENV{'REQUEST_URI'})) { $iscgi = 1; - print("Content-type: application/json\n"); + print("Content-type: application/json; charset=utf-8\n"); print("Access-Control-Allow-Origin: *\n"); print("Cache-Control: public, max-age=3600\n"); print("\n"); @@ -195,6 +196,9 @@ foreach $xtable ('planet_osm_polygon1', 'planet_osm_polygon2', 'planet_osm_line' '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 $shape = fetchlastofhr(undef, $hstoredec, 'building:shape'); + my $material = fetchlastofhr(undef, $hstoredec, + 'building:material', 'building:facade:material', 'building:cladding'); my $wallcolor = fetchlastofhr(undef, $hstoredec, 'building:color', 'building:colour'); my $roofcolor = fetchlastofhr(undef, $hstoredec, 'roof:color', 'roof:colour', 'building:roof:color', 'building:roof:colour'); @@ -249,20 +253,29 @@ foreach $xtable ('planet_osm_polygon1', 'planet_osm_polygon2', 'planet_osm_line' if (defined($minlevel)) { printwows(" \"minLevel\": $minlevel,\n"); } + if (defined($shape)) { + $shape = JSON->new->allow_nonref->encode($shape); + printwows(" \"shape\": $shape,\n"); + } + if (defined($material)) { + $material = JSON->new->allow_nonref->encode($material); + printwows(" \"material\": $material,\n"); + } if (defined($wallcolor)) { + $wallcolor = JSON->new->allow_nonref->encode($wallcolor); printwows(" \"wallColor\": \"$wallcolor\",\n"); } if (defined($roofcolor)) { - $roofcolor =~ s/"//g; + $roofcolor = JSON->new->allow_nonref->encode($roofcolor); printwows(" \"roofColor\": \"$roofcolor\",\n"); } if (defined($roofshape)) { - $roofshape =~ s/"//g; if ($roofshape eq 'pyramidal') { $roofshape = 'pyramid'; } + $roofshape = JSON->new->allow_nonref->encode($roofshape); printwows(" \"roofShape\": \"$roofshape\",\n"); } if (defined($roofmaterial)) { - $roofshape =~ s/"//g; + $roofmaterial = JSON->new->allow_nonref->encode($roofmaterial); printwows(" \"roofMaterial\": \"$roofmaterial\",\n"); } if (defined($roofheight)) { -- 2.25.1