Checking a branch nearest to a zip code

7

I'm working on a multi-branch course system.

Within the register I have a zip code field and would like this zip code to find the nearest branch. Is there any API or some way to handle this problem?

    
asked by anonymous 03.10.2014 / 20:18

2 answers

6

First, you need to georeference your zip codes, and their drives, with latitude and longitude. Some databases provide this data, such as the zip code (there are other initiatives in this regard, it should be researched).

The biggest problem is that ZIPs do not have a direct link to placement , just a simple orientation by distribution regions and subregions, which is not good for a big city

If it can, it is even better to give users the opportunity to choose their location through a map, as CEPS often covers large areas, sometimes even whole cities.

This resolved, you need to organize your base by the nearest units, such as discussed in this question:

How to organize by proximity using PHP?

Or even in the case of distances in the national territory (Brazil or Portugal), calculations can be simplified using the traditional distance calculation given by the formula:

 distancia = raiz(  ( x2 - x1 )² + ( y2 - y1 )² )

Because in these cases the geodesic between the two points can be ignored, since the error rates will fall far short of normal distances between two branches. And even if both are close, it is probably the case to return both, below a tolerance margin.

    
06.10.2014 / 22:12
4

See if this information helps with something:

1. x0000-000 (Região)
2. 0×000-000 (Sub-Região)
3. 00×00-000 (Setor)
4. 000×0-000 (Sub-Setor)
5. 0000x-000 (Divisor de sub-setor)
6. 00000-xxx (Identificadores de distribuição)
    
03.10.2014 / 20:42