some more fields taken from new osmbuildings doc about server interface
authorMichael 'PoempelFox' Meier <git@mulder.franken.de>
Wed, 5 Aug 2015 07:43:29 +0000 (09:43 +0200)
committerMichael 'PoempelFox' Meier <git@mulder.franken.de>
Wed, 5 Aug 2015 07:43:29 +0000 (09:43 +0200)
scripts/osmbuildings-json-generator.pl

index cc59f15a7af152bfd84360b44e70ceb229e347c5..502f91b3efdebf1c71570bc0b075a0a8ab9822b0 100755 (executable)
@@ -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)) {
This page took 0.073613 seconds and 4 git commands to generate.