MobilityDB 1.3
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
04_ais_store.c File Reference

A simple program that reads AIS data from a CSV file, converts them into temporal values, and stores them in MobilityDB. More...

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <libpq-fe.h>
#include <meos.h>
#include <meos_geo.h>

Data Structures

struct  AIS_record
 

Macros

#define MAX_LENGTH_HEADER   1024
 
#define MAX_LENGTH_SQL   16384
 
#define NO_BULK_INSERT   20
 
#define NO_INSTANTS_BATCH   10000
 

Functions

static int exec_sql (PGconn *conn, const char *sql, ExecStatusType status)
 Function that sends a SQL query to the database. More...
 
int main (int argc, char **argv)
 

Detailed Description

A simple program that reads AIS data from a CSV file, converts them into temporal values, and stores them in MobilityDB.

This program uses the libpq library https://www.postgresql.org/docs/current/libpq.html for connecting to a PostgreSQL database that has the MobilityDB extension. For this, it is required that libpq-dev is installed in your system. For example, in Ubuntu you can install this library as follows

sudo apt-get install libpq-dev

You should configure PostgreSQL to accept all incoming connections by setting in the pg_hba.conf file

host all all 0.0.0.0/0 md5

Also, make sure that PostgreSQL allows incoming connections on all available IP interfaces by setting in the postgresql.conf file

listen_addresses = '*'

This program is based on the libpq example programs https://www.postgresql.org/docs/current/libpq-example.html Please read the assumptions made about the input file in the file 02_ais_read.c in the same directory.

The program can be build as follows

gcc -Wall -g -I/usr/local/include -I/usr/include/postgresql -o 04_ais_store 04_ais_store.c -L/usr/local/lib -lmeos -lpq