cartodb-postgresql/doc/cartodbfy-requirements.rst

64 lines
3.2 KiB
ReStructuredText
Raw Normal View History

2016-03-09 22:47:26 +08:00
CartoDBfy Requirements
======================
Introduction
2016-03-09 22:47:26 +08:00
------------
2016-03-09 22:47:26 +08:00
This document aims at describing what the CartoDBfication is and what its formal requirements are, with the following goals in mind:
2016-03-09 22:47:26 +08:00
- Clarify what are the expectations of the "cartodbfycation process".
- Define an important part of what should be a stable, public API
- Allow for better testing, which should in turn...
- ...ease modifications and increase quality of the code
2016-03-09 22:47:26 +08:00
What is the CartoDBfycation
---------------------------
2016-03-09 22:47:26 +08:00
The CartoDBfycation is the process of converting an arbitrary postgres table into a valid CartoDB table, and register it in the system so that it can be used in the CartoDB editor and platform to generate maps and analysis.
2016-03-09 22:47:26 +08:00
It is performed by running the function ``CDB_CartodbfyTable(reloid REGCLASS)`` over a target table.
Valid CartoDB tables
2016-03-09 22:47:26 +08:00
--------------------
A valid CartoDB table shall meet the following conditions:
2016-03-15 23:39:39 +08:00
- Have a ``cartodb_id`` column with integer, unique, non-zero and non-null values as primary key with a sequence as default value
- Have a ``the_geom`` column of type ``Geometry`` with SRID 4326
- Have a ``the_geom_webmercator`` column of type ``Geometry`` with SRID 3857
2016-03-09 22:47:26 +08:00
- The columns ``the_geom`` and ``the_geom_webmercator`` shall be in sync (task of the ``update_the_geom_webmercator`` trigger)
Additionally, a CartoDB table can contain other columns.
2016-03-09 22:48:33 +08:00
See the `CartoDB User Table documentation`_
.. _CartoDB User Table documentation: https://github.com/CartoDB/cartodb-postgresql/blob/master/doc/CartoDB-user-table.rst
2016-03-09 22:48:33 +08:00
for further information.
High level requirements
2016-03-09 22:47:26 +08:00
-----------------------
Here is a list of high level requirments for the public function ``CDB_CartodbfyTable()``:
2016-03-09 22:47:26 +08:00
- A call to the function shall modify/rewrite the table and produce a valid CartoDB table with the same name.
- A call to the function shall cause the registration of the table into the platform.
- It shall be idempotent, meaning that successive calls to the function shall not produce any visible effect in the system.
- If there's a column containing a geometry, it shall be used to generate ``the_geom`` and the ``the_geom_webmercator`` columns.
- Exporting and re-importing the same table in CartoDB shall produce equivalent tables, with the same features associated to the same ``cartodb_id``'s.
2016-03-09 22:47:26 +08:00
Note that there should be only one geometry per row in the source table. If there's more than one, then which one is used for ``the_geom`` and ``the_geom_webmercator`` fields is not determined.
Low-level requirements
2016-03-09 22:47:26 +08:00
----------------------
2016-03-15 23:39:39 +08:00
- If the original table contains a valid (integer, unique, non-zero and not null) ``cartodb_id`` column, it shall be used
2016-03-09 22:47:26 +08:00
- If the original table contains a ``the_geom`` column or a ``the_geom_webmercator`` geometric column in the expected projection (EPSG 4326 and EPSG 3857, respectively) they shall be used.
- A modification of a cartodbfy'ed table shall insert or update a row in ``CDB_TableMetadata``
- A cartodbfy'ed table shall have a ``btree`` index on ``cartodb_id``
- A cartodbfy'ed table shall have ``gist`` indices on ``the_geom`` and ``the_geom_webmercator``
2016-03-09 22:47:26 +08:00
- Cartodbfy shall deal with text columns for imports, regarding CartoDB columns (``cartodb_id``, ``the_geom``, ``the_geom_webmercator``)