use DBI;
use POSIX qw(strftime mktime);
use Pg::hstore;
+use JSON;
# Par. 0: Level on which this gets printed
# Par. 1: Text
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");
'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');
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)) {