The Problem
Comparing population with CartoCSS
in my TileMill
project doesn't work unless I specifically cast population to a numeric type in my Postgres
query. The problem with that, is that it is not stable. I can do this without problems for The Netherlands, but there apparently is a population tag as 27 813
in Germany. This leads to Postgis Plugin: ERROR: invalid input syntax for type double precision: "27 813"
.
This lead me to believe that population is a string/text type in the Postgres
database. Looking at the default osm2pgsql
style file that I used during import confirms my suspicion that it is returned as a string.
The Postgresql Query
( SELECT way, place AS type, name, z_order, population
FROM planet_osm_point
WHERE place in ('country', 'state', 'city', 'town', 'village', 'hamlet', 'suburb', 'neighbourhood', 'locality', 'isolated_dwelling','city_block','borough','islet','island')
ORDER BY population DESC NULLS LAST
) AS data
A snippet from the CartoCSS
Question
Is there a right way to compare the population, without casting it or getting casting problems? Is casting it the right way to do it?