Blog Detail

10

Oct
Execute Geographical Calculation with Algorithms in Laravel cover image

arrow_back Execute Geographical Calculation with Algorithms in Laravel

Geographical Calculator was developed for laravel 5.8+ to help you implement geographical calculation, with several algorithms that help you deal with coordinates.

Installation

1 - Dependency

The first step is using composer to install the package and automatically update your composer.json file, you can do this by running:

composer require kmlaravel/laravel-geographical-calculator

2 - Copy the package providers to your local config with the publish command, this will publish the config:

php artisan geo:install

Features

  • Get the distance between one or more points
  • Get the center between a set of points
  • Get the closest point to the specific point
  • Get the farthest point to the specific point
  • Check if a given point is located in a given area
  • Get a ranking of points by the nearest neighbor algorithm
  • Get all package features

Config options

    /*
    |--------------------------------------------------------------------------
    | units values
    |--------------------------------------------------------------------------
    | your custom units, the initial units its convert from a mile to any value
    | (1.609344) is the conversion factor from a mile to a kilometer
    */
    'units' => [
        'mile' => 1,
        'km' => 1.609344,
        'm' => (1.609344 * 1000),
        'cm' => (1.609344 * 100),
        'mm' => (1.609344 * 1000 * 1000),
    ],

    /*
    |--------------------------------------------------------------------------
    | distance_key_prefix
    |--------------------------------------------------------------------------
    | if you declared more than tow points to resolve their distance,
    | you will see the result in the following format:
    | "1-2" => ["km" => "some result"],
    | "2-3" => ["km" => "some result"],
    | "3-4" => ["km" => "some result"],
    | and if you want to set any prefix before each index
    | you must change the below value to any value you want.
    |
    */
    'distance_key_prefix' => '',

For more details, Please visit Github.

Note

Suppose you are an enterprise and want to leverage Laravel for your next PHP-based web application, CRM Software, E-commerce application, SAAS application, or any custom web application development for your custom requirements. In that case, you must find an impeccable team with experience in the Laravel framework. So Codebrisk is here to help you with your tailored requirements regarding Laravel Development. For further assistance, Please feel free to send us an email at rizwan@codebrisk.com or get in touch with us, our business person will get back to you.

Published at : 10-10-2022

Author : Rizwan Aslam
AUTHOR
Rizwan Aslam

I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.

Launch your project

Launch project