# AmigoCloud

(GDAL/OGR >= 2.1)

This driver can connect to the services implementing the AmigoCloud API. GDAL/OGR must be built with Curl support in order for the AmigoCloud driver to be compiled.

The driver supports read and write operations.

## Dataset name syntax

The minimal syntax to open a AmigoCloud datasource is :

    AmigoCloud:[project_id]

Additionnal optional parameters can be specified after the ':' sign. Currently the following one is supported :

- tables=dataset_id1[,dataset_id2]*: A list of AmigoCloud dataset IDs. This is necessary when you need to access a particular AmigoCloud datasets.

If several parameters are specified, they must be separated by a space.

## Configuration options

The following configuration options are available :

- AMIGOCLOUD_API_URL: defaults to https://www.amigocloud.com/api/v1. Can be used to point to another server.
- AMIGOCLOUD_HTTPS: can be set to NO to use http:// protocol instead of https:// (only if AMIGOCLOUD_API_URL is not defined).
- AMIGOCLOUD_API_KEY: see following paragraph.

## Authentication

All the access permissions are defined by AmigoCloud backend.

Authenticated access is obtained by specifying the API key given in the AmigoCloud dashboard web interface. It is specified with the AMIGOCLOUD_API_KEY configuration option.

## Geometry

The OGR driver will report as many geometry fields as available in the layer, following RFC 41.

## Filtering

The driver will forward any spatial filter set with SetSpatialFilter() to the server. It also makes the same for attribute filters set with SetAttributeFilter().

## Paging

Features are retrieved from the server by chunks of 500 by default. This number can be altered with the AMIGOCLOUD_PAGE_SIZE configuration option.

## Write support

Dataset creation and deletion is possible.

Write support is only enabled when the datasource is opened in update mode.

The mapping between the operations of the AmigoCloud service and the OGR concepts is the following :

- OGRFeature::CreateFeature() <==> INSERT operation
- OGRFeature::SetFeature() <==> UPDATE operation
- OGRFeature::DeleteFeature() <==> DELETE operation
- OGRDataSource::CreateLayer() <==> CREATE TABLE operation
- OGRDataSource::DeleteLayer() <==> DROP TABLE operation

When inserting a new feature with CreateFeature(), and if the command is successful, OGR will fetch the returned amigo_id (GUID) and use hash value of it as the OGR FID.

The above operations are by default issued to the server synchronously with the OGR API call. This however can cause performance penalties when issuing a lot of commands due to many client/server exchanges.

## Layer creation options

The following layer creation options are available:

- OVERWRITE=YES/NO: Whether to overwrite an existing table with the layer name to be created. Defaults to NO.
- GEOMETRY_NULLABLE=YES/NO: Whether the values of the geometry column can be NULL. Defaults to YES.

## Examples

- Acceccing data from a public table:

      ogrinfo -ro "AmigoCloud:1234 tables=1234,1235"

- Creating and populating a table from a shapefile:

      ogr2ogr --config AMIGOCLOUD_API_KEY abcdefghijklmnopqrstuvw -f "AmigoCloud" AmigoCloud:"1234" myshapefile.shp

  ## See Also

  - AmigoCloud API Token management

  - AmigoCloud API Browser