Skip to content
Caio Abreu Ribeiro edited this page Nov 24, 2023 · 1 revision

The TAIS project's API, is a Flask-based application designed to handle maritime traffic data. This document provides an overview of its key components and functionalities.

Overview

  • Framework: The API is built using Flask, a lightweight WSGI web application framework in Python.
  • Cross-Origin Resource Sharing: Flask-Cors is used for handling Cross-Origin Resource Sharing (CORS), allowing the frontend to interact with the API.
  • Database Interaction: SQLAlchemy is utilized for database operations, with PostgreSQL as the database system.
  • Data Processing: Pandas and Numpy are used for data manipulation and calculations.

Key Components

Flask Application Setup (app_test.py)

  • Initializes the Flask app and configures CORS.
  • Sets up the database connection using SQLAlchemy.
  • Defines the AISData model for database interaction.

API Endpoints

  • /api/data: Fetches maritime traffic data based on time filters.
  • /api/heatmap: Provides data for heatmap visualization, including calculating vessel density and grid-based data aggregation.

Data Processing Functions

  • calculate_heatmap_data: Processes data for heatmap visualization, including grid creation and density calculation.
  • km_to_degrees: Converts kilometers to degrees based on latitude, aiding in grid size calculations for the heatmap.

Database Model (AISData)

  • Represents the structure of maritime traffic data in the database, including fields like ship_id, latitude, longitude, ship_name, and time_utc.

Dependencies

  • The requirements.txt file lists all the necessary Python packages, including Flask, SQLAlchemy, Pandas, and others required for the API's functionality.

Additional Information

  • Testing and Debugging: The API is set up with debug mode enabled for easier testing and development.
  • Deployment: Instructions for deployment are not directly provided in the API directory but can be inferred from the Flask and Python environment setup.

This API serves as a backend for the TAIS web application, handling data retrieval, processing, and serving it in a format suitable for frontend consumption, particularly for data visualization like heatmaps.