Giter Site home page Giter Site logo

mkeller3 / fastgeotable Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 0.0 20 KB

FastGeoTable is a PostGIS geospatial api to enable creating/editing geographical tables within a spatial database.

License: MIT License

Dockerfile 1.96% Python 98.04%
asyncpg fastapi geometry geospatial postgis postgres postgresql python

fastgeotable's Introduction

FastGeoTable

FastGeoTable is a geospatial api to edit tables with geospatial data. FastGeoTable is written in Python using the FastAPI web framework.


Source Code: https://github.com/mkeller3/FastGeoTable


Requirements

FastGeoTable requires PostGIS >= 2.4.0.

Configuration

In order for the api to work you will need to edit the config.py file with your database connections.

Example

DATABASES = {
    "data": {
        "host": "localhost", # Hostname of the server
        "database": "data", # Name of the database
        "username": "postgres", # Name of the user, ideally only SELECT rights
        "password": "postgres", # Password of the user
        "port": 5432, # Port number for PostgreSQL
    }
}

Usage

Running Locally

To run the app locally uvicorn main:app --reload

Production

Build Dockerfile into a docker image to deploy to the cloud.

API

Method URL Description
PUT /api/v1/tables/edit_row_attributes Edit Row Attributes
PUT /api/v1/tables/edit_row_geometry Edit Row Geometry
POST /api/v1/tables/add_column Add Column
DELETE /api/v1/tables/delete_column Delete Column
POST /api/v1/tables/add_row Add Row
DELETE /api/v1/tables/delete_row Delete Row
DELETE /api/v1/tables/delete_table Delete Table
POST /api/v1/tables/create_table Create Table
GET /api/v1/health_check Server health check: returns 200 OK

Endpoint Description's

Edit Row Attributes

Description

Edit Row Attributes endpoint allows you to edit one/all atrributes for a row at a time. In the example below we are changing the objectid and last_name columns for the row with a gid of 1.

Example:

Example Input

{
    "database": "data",
    "table": "mclean_county_parcels",
    "gid": 1,
    "values": {
        "objectid": "1",
        "last_name": "sample"
    }
}

Example Output

{
    "status": true
}

Edit Row Geometry

Description

Edit Row Geometry endpoint allows you to change the geometry for each feature in a table by passing in geojson geometry in SRID 4326. In the example below, we are updating the table called zip_centroids with the gid of 1 for a new lat lng of [-88.23456,40.12345].

Example:

Example Input

{
    "database": "data",
    "table": "zip_centroids",
    "gid": 1,
    "geojson": {
        "type": "Point",
        "coordinates": [
            -88.23456,
            40.12345
        ]
    }
}

Example Output

{
    "status": true
}

Add Column

Description

The add column endpoints allows you to add a new column to an existing table in the database.

Example: In the example below, we are adding a column called test that is text for the table zip_centroids.

Example Input

{
    "database": "data",
    "table": "zip_centroids",
    "column_name": "test",
    "column_type": "text"
}

Example Output

{
    "status": true
}

Delete Column

Description

The delete column endpoint allows you to delete a column in an existing table in the database.

Example: In the example below, we are deleting a column called test from the table zip_centroids.

Example Input

{
    "database": "data",
    "table": "zip_centroids",
    "column_name": "test"
}

Example Output

{
    "status": true
}

Add Row

Description

The add row endpoint allows you to add a new to an existing table within the database. You can pass in one or all columns for this endpoint. If you do not pass in a column the value will be null.

Example: In the example below, we are adding a a new row to the zip_centroids table and only adding the postalcode column with the geometry.

Example Input

{
    "database": "data",
    "table": "zip_centroids",
    "columns": [
        {
            "column_name": "postalcode",
            "value": "55555"
        }
    ],
    "geojson": {
        "type": "Point",
        "coordinates": [
            -88.23456,
            40.12345
        ]
    }
}

Example Output

{
    "status": true,
    "gid": 7821
}

Delete Row

Description

The delete row endpoint allows you to delete a row for a table that exists in the database.

Example: In the example below, we are deleting the column with a gid of 1 in the table zip_centroids.

Example Input

{
    "database": "data",
    "table": "zip_centroids",
    "gid": 1
}

Example Output

{
    "status": true
}

Create Table

Description

The create table endpoints allow you to create a new table inside of a database.

Example: In the example below, we are creating a new table called zip_centroids_new. We are adding one column in the table called postalcode, and setting the table to have POINT geometry.

Example Input

{
    "database": "data",
    "table": "zip_centroids_new",
    "columns": [
        {
            "column_name": "postalcode",
            "column_type": "text"
        }
    ],
    "geometry_type": "POINT"
}

Example Output

{
    "status": true
}

Delete Table

Description

The delete table endpoint allows you to delete a table within the database.

Example: In the example below, we are deleting a table called zip_centroids.

Example Input

{
    "database": "data",
    "table": "zip_centroids"
}

Example Output

{
    "status": true
}

fastgeotable's People

Contributors

mkeller3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.