GithubHelp home page GithubHelp logo

alvinyen / find-near-me Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 33 KB

應用新版的node搭配ES6+ async await等語法撰寫完成,對於座標距離各站點的遠近的判斷使用 mongodb的$near運算子來完成,證明自己NoSQL type DB的操作能力。部署於Heroku。

JavaScript 100.00%

find-near-me's Introduction

find-near-me

專案說明

  • 使用者可透過台北市的座標做為參數,查詢最近的2個還有youbike可以借的站點。
  • 查詢結果包含站點名稱、該站youbike剩餘數量等等。
  • 應用新版的node搭配ES6+ async await等語法撰寫完成,對於座標距離各站點的遠近的判斷使用 mongodb的$near運算子來完成,證明自己NoSQL type DB的操作能力。部署於Heroku。
  • 應用Google Maps Geocoding API來判斷使用者傳入的座標參數是否位於台北市。
  • 台北市政府開放資料的youbike data每分鐘更新1次,因此另外設定cron job每分鐘藉由開放資料的api獲取台北市各youbike站點的即時資訊 (例如youbike剩餘數量等等),並進一步更新到mongo db service:mLab。
  • cron jon的部分原本含在本專案中,但部署於heroku後發現超過30分鐘內沒有任何request則包括cron job部分的整個應用就會被閒置,因此將cron job的部分另外抽出為專案:cron-job-fetch-youbike-data-every-min,部署於Digital Ocean。

API SPEC.

  • host: https://find-near-me.herokuapp.com
  • /v1/ubike-station/taipei
    • Request Method: GET
    • Request Parameters:
      • lat: latitude of location
      • lng: longitude of location
    • Spec and Error Handling:
      • 如果座標不在台北市內,則回傳 error code -2。
      • 其他error code說明
        • 1:所有youbike站點都沒有youbike可借
        • 0:OK
        • -1:不正確的經度或緯度
          • 經度範圍:-180 ~ 180
          • 緯度範圍:-90 ~ 90
        • -2:座標不在台北市內
        • -3:系統錯誤
        • 任何非0錯誤代碼必須搭配回傳空的result陣列
        • 回傳的youbike站點的剩餘youbike數量必須不等於0
    • Response
      • Content Type: application/json
      • Body
        {
            "code": $error-code,
            "result": [
                {
                    "station": "$name-of-station", 
                    "num_ubike": $number-of-available-ubike
                },
                {
                    "station": "$name-of-station", 
                    "num_ubike": $number-of-available-ubike
                }
            ]           
        }
        
    • Sample Request
      • GET /v1/ubike-station/taipei?lat=25.034153&lng=121.568509
      • response Content-Type: application/json
        {
            "code": 0,
            "result": [
                {"station": "捷運象山站", "num_ubike": 10},
                {"station": "世貿二館", "num_ubike": 33}
            ]               
        }
        

測資

find-near-me's People

Contributors

alvinyen avatar

Watchers

James Cloos 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.