The TJS-Server prototype was developed to explore the potential of utilizing vector tile caches as framework data for a Table Joining Service (TJS) API based on OGC standards. This project builds upon the MSC thesis by Sharon Chawanji, which can be found on this link.
We are currently in the process of developing comprehensive documentation on how to use the API. You can visit the demo page here for a preview of its functionality. Please also visit the Git repository for an OpenLayers application to view the joined data.
The TJS-Server API is built using Flask, a Python web framework for creating web apps and web services. Below, we describe the Flask route joindata
, which provides the functionality to join GeoJSON and CSV data. To learn more about the OGC Table Joining Service, please follow the link.
This Flask-based API provides a simple way to join GeoJSON and CSV data based on user-provided parameters. It takes GeoJSON data from a specified URL, combines it with CSV data from another URL, and returns the merged data as a GeoJSON response. The merging is performed based on specified keys in the GeoJSON and CSV data.
Endpoint URL: /tjs/api/joindata
HTTP Method: GET
- FrameworkURI: URL of the GeoJSON data to be used as the framework for joining.
- GetDataURL: URL of the CSV data to be joined with the GeoJSON data.
- FrameworkKey: The key in the GeoJSON data that will be used for merging.
- AttributeKey: The key in the CSV data that corresponds to the
FrameworkKey
for merging.
You can make a GET request to the /tjs/api/joindata
endpoint by specifying the required parameters in the query string of the URL. Here's an example of how to make an HTTP request:
GET /tjs/api/joindata?FrameworkURI=<GeoJSON_URL>&GetDataURL=<CSV_URL>&FrameworkKey=<GeoJSON_Key>&AttributeKey=<CSV_Key>
Replace the placeholders with the actual values:
<GeoJSON_URL>
: URL of the GeoJSON data to be used as the framework.<CSV_URL>
: URL of the CSV data to be joined.<GeoJSON_Key>
: The key in the GeoJSON data for merging.<CSV_Key>
: The corresponding key in the CSV data for merging.
- If the request is successful and data is successfully merged, the API will respond with a GeoJSON representation of the merged data.
- If there is an issue with fetching the data or merging it, an error message with an appropriate HTTP status code will be returned.
GET /tjs/api/joindata?FrameworkURI=https://example.com/geojson_data.geojson&GetDataURL=https://example.com/csv_data.csv&FrameworkKey=geo_id&AttributeKey=id
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Location A",
"value": 100
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [126.7, 11.2]
},
"properties": {
"name": "Location B",
"value": 200
}
}
]
}
- If a required parameter is missing, the API will respond with an error message and a 400 Bad Request status code.
- If there are issues with fetching or merging data, the API will respond with an error message and a 500 Internal Server Error status code.
This guide will walk you through setting up the TJS-Server project on a Linux-based system. Follow these steps to get the server up and running.
Before you begin, make sure you have the following installed on your Linux machine:
-
Clone the Repository:
Use
git clone
to clone the TJS-Server repository to your local machine:git clone https://github.com/schawanji/TJS-Server.git
-
Create a Python Virtual Environment:
Navigate to the project directory and create a Python virtual environment called
myenv
:cd TJS-Server python3 -m venv myenv
-
Activate the Virtual Environment:
Activate the virtual environment using the following command:
source myenv/bin/activate
-
Install Project Dependencies:
Use
pip
to install the required Python packages listed inrequirements.txt
:pip install -U -r requirements.txt
Now that you have set up the project and installed the dependencies, you can start the server by running the following command:
gunicorn main:app
The server should start, and you will see a message indicating that it's running on http://127.0.0.1:8000
.
You can access the server by opening a web browser and navigating to the following URL:
http://127.0.0.1:8000
This is the local address where the server is running. If you want to access it from other devices on the same network, replace 127.0.0.1
with your Linux machine's IP address.
You have successfully set up and run the TJS-Server project on your Linux system. You can now use and test the server as needed. If you encounter any issues or have questions, feel free to reach out for assistance.