Git Product home page Git Product logo

zap-map-locations's Introduction

Laravel Logo

Build Status Total Downloads Latest Stable Version License

Zap-Map Technical Challenge

Develop a single restful API endpoint which should return Location points for a region on a map.

  • Create a database and migrate the data from that file
  • There only needs to be a single endpoint.
  • That endpoint should accept three parameters:
    • latitude
    • longitude
    • radius
  • It should return a response of all Locations that fall within that radius.

This simple project is running in php8.2

Setup

  1. Pull the main branch
  2. Run composer install
  3. Make sure you set up your database in .env file
  4. Run the migration php artisan migrate (database/migrations/2023_04_06_101801_create_locations_table.php)
  5. Run the seeder: php artisan db:seed --class=LocationSeeder which is located in database/seeders/LocationSeeder.php
  6. Voilà! you are all set.

How to use the endpoint?

This contains a single endpoint, below is the detail. Make sure that you will change the domain according to your setup.

GET https://laraboxe.local/api/locations?lat=51.475603934275675&lon=-2.3807167145198114&radius=6

You can also use the postman collection for your reference: https://api.postman.com/collections/20811097-f78e1f61-9fd2-4f12-8207-ae1e0988fbd7?access_key=PMAT-01GXGTW846JX0XK75XPBWZMWME

Endpoint name: locations

Required Parameters:

  • lat (51.475603934275675)
  • lon (-2.3807167145198114)
  • radius (10)

Successful Response:

{
    "locations": [
        {
            "id": 1,
            "name": "Toyota Taunton",
            "latitude": "51.47560393",
            "longitude": "-2.38071671",
            "distance": 0
        },
        {
            "id": 194,
            "name": "Balnellan Road Car Park",
            "latitude": "51.49157162",
            "longitude": "-2.45921125",
            "distance": 5.718032674693054
        },
        {
            "id": 45,
            "name": "Warwick Avenue (North Bound)",
            "latitude": "51.51463999",
            "longitude": "-2.46010010",
            "distance": 7.002991765705255
        },
        {
            "id": 103,
            "name": "Greenstone Pub & Restaurant",
            "latitude": "51.53201065",
            "longitude": "-2.29918018",
            "distance": 8.437364043107253
        },
        {
            "id": 55,
            "name": "Etchinghill Golf Club",
            "latitude": "51.48544745",
            "longitude": "-2.25066393",
            "distance": 9.072428033163439
        },
        {
            "id": 128,
            "name": "1 Clifton Avenue",
            "latitude": "51.51574403",
            "longitude": "-2.25564252",
            "distance": 9.741231115390512
        }
    ],
    "status": "success",
    "title": "Success",
    "success": true
}

Validated Response:

{
    "title": "Error",
    "success": false,
    "message": "Validation errors",
    "data": {
        "lat": [
            "The latitude field is required"
        ],
        "lon": [
            "The longitude field is required"
        ],
        "radius": [
            "The radius field is required."
        ]
    }
}

I created a simple test in (tests/Feature/LocationTest.php). Please run php artisan test to run it.

zap-map-locations's People

Contributors

taylorotwell avatar driesvints avatar grahamcampbell avatar daylerees avatar franzliedke avatar jasonlewis avatar sparksp avatar cviebrock avatar nunomaduro avatar tobsn avatar crynobone avatar jeffreyway avatar barryvdh avatar tillkruss avatar josephsilber avatar themsaid avatar laurencei avatar timacdonald avatar bencorlett avatar ericlbarnes avatar neoascetic avatar browner12 avatar jesseobrien avatar jakobud avatar mikelbring avatar sjorso avatar codler avatar kapv89 avatar kbanman avatar roberto-aguilar avatar

Watchers

Genil Montilde 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.