Giter Club home page Giter Club logo

queries's Introduction

Cars Polygons Query REST API

REST endpoint that allows to query cars and polygons with specific features.

Run with

Run: queries > mvn spring-boot:run

Tech Stack

Java 8
Spring Boot
Spring Data JPA
Spring Scheduler
Hibernate
H2 in memory db
Maven
Google Gson
springfox-swagger2
Hystrix
Docker

Database Tables

create table city_vehicle (id integer not null, fuel double, latitude double, longitude double, model varchar(255), number_plate varchar(255), vin varchar(255), primary key (id))
create table point (id bigint not null, latitude double, longitude double, polygon_id varchar(255), primary key (id))
create table polygon (id varchar(255) not null, name varchar(255), primary key (id))

Database Tables Definitions

city_vehicle = Stores car details information fetched from http://localhost:3000/vehicles/Stuttgart
polygon = Stores polygon information fetched from https://gist.githubusercontent.com/codeofsumit/6540cdb245bd14c33b486b7981981b7b/raw/73ebda86c32923e203b2a8e61615da3e5f1695a2/polygons.json
point = Join table for point-polygon pairs

Prerequisites

  • Before running this Spring Boot application it is required to pull and run the docker image listed below :

  • docker pull car2godeveloper/api-for-coding-challenge

  • docker run -d -p 3000:3000 car2godeveloper/api-for-coding-challenge

Rest Api Design Decisions

Requirements

  • Query cars with polygon id they are in. Note : found single polygon id is returned.
  • Query polygons include the VIN of cars currently in them. Note : All the cars inside current polygon is returned.

Query cars

Method : HTTP.GET
URL : http://localhost:8080/cars/retrieveCars

Input Test Data : No input just fire the request. "polygonId" field contains the id of current car's polygon.

Request :

{
}

Response :

HTTP response code 200

[
  {
    "id": 1,
    "locationId": null,
    "vin": "1GCGK34J9YD4JVCFW",
    "numberPlate": "S-IQ7213",
    "position": {
      "latitude": 48.75430489282382,
      "longitude": 9.256467604055967
    },
    "fuel": 0.1,
    "model": "SMART_42_ELECTRIC",
    "polygonId": "58a58bd185979b5415f39d78"
  }
]

Query polygons

Method : HTTP.GET
URL : http://localhost:8080/polygons/retrievePolygons

Input Test Data : No input just fire the request. "vinsOfCars" field contains car vin information for the specific polygon.

Request :

{
}

Response :

HTTP response code 200

[
 {
    "id": "58a58c05766d51540f779bc4",
    "updatedAt": null,
    "createdAt": null,
    "v": null,
    "name": "111",
    "cityId": null,
    "legacyId": null,
    "type": null,
    "geoFeatures": null,
    "timedOptions": null,
    "geometry": {
      "type": null,
      "coordinates": [
        [
          [
            48.7173283425,
            9.1506641217
          ],
          [
            48.7180471865,
            9.15531458734
          ],
          [
            48.7207196233,
            9.15331317462
          ],
          [
            48.7243944113,
            9.15322734393
          ],
          [
            48.7225447239,
            9.16249720636
          ],
          [
            48.721600962,
            9.16829092591
          ],
          [
            48.7211384938,
            9.1709087619
          ],
          [
            48.721671688,
            9.17230351059
          ],
          [
            48.7215253911,
            9.1727541217
          ],
          [
            48.718313,
            9.170581
          ],
          [
            48.7162806971,
            9.16904237036
          ],
          [
            48.7168328373,
            9.16346075528
          ],
          [
            48.7166771061,
            9.1548750661
          ],
          [
            48.7173283425,
            9.1506641217
          ]
        ]
      ]
    },
    "version": null,
    "vinsOfCars": [
      "1B3LB28C198UXF3XS",
      "1GAZGYCL8BNS2VAA2"
    ]
  }
]

queries's People

Contributors

tufangorel 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.