Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
Google geocoding on the fly using laravel queue

I have about 100 GPS device sending coordinates periodically on every 10 seconds . My customer want real time reverse geocoding to see his vehicles along with location on a tabular view. I have set up a queue to save all those packets in db before where I have added geocoding script like below

  1. Receive TCP IP message using websocket

    public function onMessage(ConnectionInterface $conn, $msg) {
     //get the message
     // send the dispatch job to save it in db
     $this->dispatch(new SavePacketsToDb($key_1, json_encode(
                                            array(
                                                'company_id' => $key_1,
                                                'vehicle_id' => $company->vehicle_id,
                                                'tracker_id' => $company->tracker_id,
                                                'lat' => $lat,
                                                'lng' => $lng,
                                                'imei' => $imei,
                                                'datetime' => $datetime,
                                                                                )
                             )));   
    

    }

  2. Run a queue

    public function handle(){
            $lat=$obj->lat;
            $lng=$obj->lng;
    
    
    
    $url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" . $lat . "," . $lng . "&key=mykey";
                    $json = file_get_contents($url);
                    $data = json_decode($json);
                    $status = $data->status;
                    $address = '';
                    if ($status == "OK") {  
                       // echo "from geocode address";
                        echo $address = $data->results[0]->formatted_address;
                    }
                    else{
                        $address=NULL;
                    }
    
         //save to db
      }
    

I am just worried if it works for 1000 concurrent devices if I include this geocoding on queue, is there any better approach for it?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

We developed something similar, initially with google maps api but i moved away because it was not so accurate in my location (Brazil).

For google maps, if you dont notice any problems with accuracy you could run up a queue and process the data but with a limited amount per day (notice the 2500 lookups limit i believe) for free service or buy the required lookups.

If you need real-time of all devices, you will need to pay for larger volume in google maps and i would use a queueing service for it. We are using RabbitMQ Queue to receive the coordinates and then we have small clients/workers that get items from the queue and process them (there are other APIs involved).

I dont believe your customer will be all day long in front of that screen, so maybe you can:

  • Always store the coordinates
  • Run the API calls only when he/she/someone is in that page
  • Use a priority system for GPS coordinates in the viewed area of the screen (viewed map boundaries at frontent)
  • Run low priority coordinates on a best effort window (based on API availability, usage limit, etc), maybe even on a secondary API for non-priority

Btw we're using HereMaps, it's payed but you can create a demo/test account for 3 months.

about 4 years ago · Santiago Trujillo Relatório

0

I think reverse geocode each coordinate is quite inefficient. I would rather try to group some coordinates in some packages and the use something like the thephpleague/geotools batch api to reverse geocoding this data, if they are requested.

And i would not rely only on google maps. I think a good advice is to have a fallback, because google maps does not know each address and you can quit easy in the rate limit (with such amount of data). Have a look at the [geocoder-php/Geocoder] package, which supports many geocoding services.

Mabye a site note: I'm one of the people who maintain this project.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda