we now have DBI::Pg >3, so we can properly handle utf8.
[osmrrze.git] / scripts / osmbuildings-json-generator.pl
index a9b28f42efcde8bc13c3f976b1b802cd80c12b37..d0f5a986fb11289194f974420dd2b396b5305aff 100755 (executable)
@@ -143,11 +143,11 @@ $tx2 = $dbh->selectrow_array("select ST_X(ST_transform(ST_GeomFromText('POINT($x
 $ty2 = $dbh->selectrow_array("select ST_Y(ST_transform(ST_GeomFromText('POINT($x2 $y2)', 4326), 900913))");
 # Why do crappy perl libraries always insist on using an "Object Oriented" interface
 # for things where this does not make any sense at all?
-my $crappyjsonoo = JSON->new()->latin1(); # Note: has to be latin1 instead of utf8
-# for now, because the strings we get from the DB are WTF8, but are not marked
-# as such. Therefore, we must not tell the JSON module to do utf8(), because
-# otherwise it would encode the WTF8 twice.
-# This will change with DBI::Pg modules >3 where UTF8 is properly handled.
+my $crappyjsonoo = JSON->new()->utf8(); # Note: This has to be latin1 instead of
+# utf8 for DBI::Pg modules with version <3, because in that case, the strings we
+# get from the DB are WTF8, but are not marked as such. Therefore, we must not
+# tell the JSON module to do utf8(), because otherwise it would encode the WTF8
+# twice.
 if ($verblev > 0) {
   $crappyjsonoo = $crappyjsonoo->pretty();
 }
@@ -177,7 +177,7 @@ foreach $xtable ('planet_osm_polygon1', 'planet_osm_polygon2', 'planet_osm_line'
     exit(1);
   }
   my $sth2 = $dbh->prepare("select ST_X(points) as x, ST_Y(points) as y"
-                         . " from (select ST_astext((ST_dumppoints(ST_transform(?, 4326))).geom) as points) as points");
+                         . " from (select ST_astext((ST_dumppoints(ST_transform(geometry(?), 4326))).geom) as points) as points");
   my $sth4 = $dbh->prepare("select (ST_dumprings(?)).geom as rings");
   while ($row = $sth->fetchrow_hashref()) {
     if ($xtable eq 'planet_osm_polygon1') {
This page took 0.04414 seconds and 4 git commands to generate.