avnoor-488 / intersection-api

Checkout the doc for more info

Home Page:https://docs.google.com/document/d/1R-xM6Fge_OxF95lLU-ei_C8g4d6lczix7Qz-zrgju7c/edit?usp=sharing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Intersection API

This project provides an API for detecting intersections between line strings in GeoJSON format.

Requirements

  • Node.js (v16.18.1 or later)
  • NPM (v9.3.1 or later)

Dependencies:

  • express
  • rbush
  • @turf/turf
  • jsonwebtoken
  • express-jwt
  • body-parser

Installation

First, clone the repository and navigate into the project directory:

git clone <repository-url>

Next, install the dependencies:

npm install

Usage

Start the server:

npm run dev

The server will run on port 3000.

The API provides two endpoints:

  1. POST /token - Generate a JWT token. This does not require any input. The token is returned in the response body.

  2. POST /intersections - Detect intersections between line strings. This requires a JWT token in the Authorization header and a JSON body containing a long line string and an array of 50 other line strings.

Example request body for /intersections:

{
    "longLine": {
        "type": "LineString",
        "coordinates": [[0,0], [10,10]]
    },
    "lines": [
        {
            "type": "LineString",
            "coordinates": [[0,0], [5,5]]
        },
        // 49 more line strings...
    ]
}

The response will be a JSON object containing details of the intersections.

About

Checkout the doc for more info

https://docs.google.com/document/d/1R-xM6Fge_OxF95lLU-ei_C8g4d6lczix7Qz-zrgju7c/edit?usp=sharing


Languages

Language:JavaScript 100.0%