Giter Site home page Giter Site logo

vesselproject's Introduction

VesselAPI

VesselAPi project has the main focus to provide an webservice that returns the name of the timezone and the current local time for any given lon and lat.

Requirements considered

  • The timezone information needs to be stored in a postgresql/postgis database. The timezones are stored as polygons and for each time zone there is some additional information (name, UTC offset etc.)

  • The Application runs standalone using the Spring Boot Framework

Spring Boot http://projects.spring.io/spring-boot/

Spring Data REST http://projects.spring.io/spring-data-rest/ http://projects.spring.io/spring-data/

AngularJS https://angularjs.org/

PostgreSQL http://www.postgresql.org/

PostGis - Install with App http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgis_tut01

Architecture

architeture

database application properties connection

properties

API returns

  1. Sucessful - when the user informs a valid lgn & lat
{
    "status": "Done",
    "data": {
        "id": 67,
        "timeZoneName": "Côte d'Ivoire, Ghana, Senegal, Morocco, Portugal (continental and Madeira), Spain (Canary Islands)",
        "offSetText": "UTC±00:00",
        "offSet": 0,
        "currentLocalTime": "15/08/2017 11:36:55",
        "currentUTCTime": "15/08/2017 11:36:55"
    }
}
  1. Not Found - when the user informs a valid lgn & lat but doens't exists
{
    "status": "Not Found",
    "data": {
        "id": null,
        "timeZoneName": null,
        "offSetText": null,
        "offSet": null,
        "currentLocalTime": null,
        "currentUTCTime": null
    }
}
  1. Fail - when the user informs an invalid lgn & lat
{
    "status": "Fail",
    "data": {
        "id": null,
        "timeZoneName": null,
        "offSetText": null,
        "offSet": null,
        "currentLocalTime": null,
        "currentUTCTime": null
    }
}

Query to get data

I used the function ST_Intersects which checks if a given piece of geometry (our point) shares any space with another piece.

get data

More details about PostGis and Timezone can find in this site http://shisaa.jp/postset/postgis-and-postgresql-in-action-timezones.html

Initially, I was considering to use a custom query on LocaleRepository.java that extends Repository spring. This strategy is good to save time for many methods that don't need to be coded again (findById, getId, etc) and in my case, brings the possibility to write a custom query. But I faced some problems due a complex query that uses some postgis extension.

Commented code about custon query repository

Due this problem I decided to use the 'brute force' and get data using the JDBC query (the same query) controller

Tests

Was coded three tests scenarios using JUnit framework:

1- location Found Success that bring a valid position using the following data: lat=53.5&lng=10.4

2- location Not Found Not Found location position using the following data: lat=1055&lng=115555

3- location Error Failed that bring a Invalid position, with lat=AAAA&lng=BBBB

tests

Important note: the VesselAPITest.java was moved out of the project due Maven compilation issues. If you need to run the tests, please return the file VesselAPITest.java to the folder /src/main/java/com/vessel/api and run using JUnit plugin on the eclipse

#Install

Clone the project from gitHub and create a projet on eclipse. Run the application Boot.java

If you prefer you can run the maven command bellow

mvn spring-boot:run

How to test

result Hit the URL on webbrowser informing the latitude and longitude http://localhost:8080/timeForLatLng?lat=53.5&lng=10.4

  • Calling API some postservice (PostMan) result

vesselproject's People

Contributors

franciscosouza avatar

Watchers

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