Download the PHP package vkr/geolocation-bundle without Composer

On this page you can find all versions of the php package vkr/geolocation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package geolocation-bundle

About

This bundle was created to sort out a rather nasty problem I've encountered - searching for a point in a large chunk of data that is the nearest one to some point N. There is a rather complicated formula that helps us do it precisely, however, it's a really bad idea to use it in your DB query - you will kill your database.

This bundle provides a solution for this problem by creating a two-step algorithm that first executes a simple DB query that looks for any point that has a remote chance to be the nearest one and then using the script to apply the formula and choose a 'winner' among these points.

The bundle consists of three services that you can use separately - first for step #1, second for step #2, third for talking to Doctrine. The bundle depends on Symfony and Doctrine, however, you do not need to actually use Doctrine if you prefer not to activate the third service.

Installation

Nothing to install here, except for activating the bundle in .

Usage

Retrieving a bounding box

First of all, we will need to create a bounding box which is a square chunk of land, and then find all points that lie inside that box.

I assume that all your geospatial data uses degrees of latitude and longitude.

To create a bounding box, we need to know the side of the square. As all our data is in degrees, we will use degrees for that measure as well. However, a degree of longitude corresponds to different distances, depending on the latitude. Therefore, we will measure the box in degrees of latitude, that are immutable. One degree of latitude equals 111.375 km.

Here is how the box is created around the point with given latitude and longitude.

Here we have a square with a side of roughly 55 km (half a degree of latitude) with a point (40, -100) at the center.

The desired allowance depends on how densely the points are distributed in your data source. For example, if you are searching for zip codes in a metropolitan zone, you wouldn't want to use anything more than 0.1 for allowance.

If your coordinates are located near the international date line (longitude of +180/-180), the service will take that into account and will still give you a perfectly square box.

If you prefer not to use the service, you can create the object yourself, according to the following rules:

Example:

Querying the DB

With the bounding box ready, we need to parse its contents into a DQL query. That is what the service is for. However, you need to define a data source entity to use it. The entity must conform to that defines and methods. The service will collect all points that lie inside your bounding box.

The contents of are nothing more than what you usually get from in Doctrine.

Sometimes you might want to get a list of all values of a non-unique field that are encountered in a bounding box. For example, you have a DB with zip codes but you are only interested in cities. If this is the case, you can utilize :

You will get a zero-indexed array of city names.

Calculating the nearest point

Finally, we can test which point inside your query result is the nearest one.

That's about it.

Optional: defining the entity manager

If you are using a setup with multiple entity managers, you can define an optional parameter in . Suppose that your manager is called "my", then add this to :

This way, the service will query the DB using the specified entity manager.

API

VKR\GeolocationBundle\Entity\Perishable\BoundingBox BoundingBoxFinder::setBoundingBox(float $lat, float $lng, float $allowanceLat)

void DoctrineQuerier::__construct(Doctrine\ORM\EntityManager $em)

array|null DoctrineQuerier::getRecords(VKR\GeolocationBundle\Entity\Perishable\BoundingBox $boundingBox, string $entityClassName)

array DoctrineQuerier::getDistinctRecords(VKR\GeolocationBundle\Entity\Perishable\BoundingBox $boundingBox, string $entityClassName, string $fieldName)

int NearestPointCalculator::findNearestPoint(float $lat, float $lng, array $valueList)

The third argument must be a zero-indexed array of objects.


All versions of geolocation-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
symfony/symfony Version ~2.8|~3.0
doctrine/orm Version >=2.2.3
doctrine/doctrine-bundle Version ~1.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vkr/geolocation-bundle contains the following files

Loading the files please wait ....