mapnik/mapnik — pull request #1021 by springmeyer (2012-01-12 04:14:14+00:00)
Title: Add Geometry type descriptor

The only precise way to determine geometry type for a given datasource is to parse all features, but this is expensive. TileMill, and potentially other calling applications in the future, need an easy, fast, and cheap way of asking a datasource its best estimate of what type of geometries it holds. Currently TileMill manages this by querying `ds.features` and parsing the first features geometry type. The enormous problem with this is for postgis tables where getting access to this first feature triggers a full query as TileMill does not have api access to set a `LIMIT`.

The implements this feature ideally across all datasources by adding a `geometry_type` description that datasources can optionally provide. By default it will be an empty string. A modest effort is made to report collections if possible (at most by looking at the first few features using a highly refined query).

The descriptor reports geometry type as either `point`, `polygon`, `line`, or `collection`. Because this overall reporting is different, and should not be confused with the `mapnik::eGeomType` that reports/stores geometry type of a given features geometries I chose to use strings instead of to extend `mapnik::eGeomType` to list collections.