Creating a shape resource

As an example we are going to open up a shape file from dati.gov.it. First download the latest beta (tar.bz2 | zip) release of The DataTank and install it by following the installation instructions

Requirements

Enable the php-dbase extension.

 

Getting the shape source location:

  1. Browse to the dati.gov.it website and click ‘Cerco i dati’. (not sure what it means but hey it got me to the data sets)

  2. Click on the Shapefile format:

  3. Click on the first link ‘Biblioteche – Comune di Firenze’:

  4. Click on the link under ‘URL pagina dataset: ‘

  5. Download and unzip the shapefile in a folder:



 

Create the resource:

You can create new resources through our RESTful API, in this example we are going to use the REST Console extension in Google Chrome.

  1. Check the required parameters by checking http://hostname/TDTInfo/Admin, here you can see the SHP part:

    [SHP] => stdClass Object
    	(
    		[doc] => When your file is structured according to SHP, you can perform a PUT request and load this file in this DataTank
    		[parameters] => Array
    			(
    				[resource_type] => The type of the resource.
    				[generic_type] => The type of the generic resource.
    				[documentation] => Some descriptional documentation about the generic resource.
    				[url] => The path to the shape file (can be a url).
    				[columns] => The columns that are to be published.
    				[PK] => The primary key for each row.
    			)
    
    		[requiredparameters] => Array
    			(
    				[0] => resource_type
    				[1] => documentation
    				[2] => generic_type
    				[3] => url
    			)
    
    	)
    
  2. Build the request uri, a valid uri is of the form: http://hostname/package/resource:

  3. As authorization we are going to use basic authorization, as credentials you need to use the username and password you configured in the $API_USER and $API_PASSWD parameters in Config.class.php:

  4. As request parameters you need to use the ones described in the first step of this list:

  5. Send the request
  6. Point your browser to the created resource:

  7. Check the Requesting a resource page for more information.