developmentseed / tipg

Simple and Fast Geospatial OGC Features and Tiles API for PostGIS.
https://developmentseed.org/tipg/
MIT License
153 stars 23 forks source link

Geom-column default #109

Closed jonaraphael closed 1 year ago

jonaraphael commented 1 year ago

The old behavior of tipg [a435d30db9aefd8094ece134681e9c562a6f696a] automatically returned any type:geometry/geography column named "geometry" as the default displayed result.

The new behavior of tipg [0.4] appears to return the first column of type type:geometry, after sorting alphabetically by name.

The old behavior is much preferred, as the alphabetic ordering is often meaningless, and the choice of the column name "geometry" is quite deliberate.

Note This may be related to another apparent change: from returning columns in the order they are stored in the database to returning columns alphabetically. This new behavior is also undesirable, as the deliberate ordering is much more useful than the random sort by first letter.

bitner commented 1 year ago

@jonaraphael TiPG tries to strike the balance between being able to run with zero configuration and to be able to have flexible settings for customization.

Various ingest tools will use column names like 'wkb_geom', 'wkb_geometry', 'geom', 'geometry', 'geog', 'geography', so I am not sure that I am inclined to single out 'geometry' as the default. If anything, I would tend towards using the ogr default of 'wkb_geometry', but as multiple geometry columns is (in my experience, I stand to be corrected) relatively uncommon, I definitely lean towards requiring a user to be explicit through settings if you need a certain column to be the default geometry column.

If you have multiple geometry fields, it is likely best if you are explicit with which field that you want to use. Setting the environment variable TIPG_TABLE_CONFIG__public_mytable__GEOMCOL=geometry will allow you to be explicit about which column you would like to use. https://developmentseed.org/tipg/user_guide/configuration/.

jonaraphael commented 1 year ago

Thank you for the reference. Will certainly make use of that config parameter--apologies for not finding it before posting this issue!