gammaper's avatar

Working with gps tracking in Laravel

I would like to know how to develop a gps tracking like uber in laravel. Is there any information about that?

0 likes
8 replies
Snapey's avatar

I know of an application for android gps2gpsgate

Its designed to Post to a server called Gpsgate but it can be configured to post gps strings to any server.

Unfortunately I cannot find an equivalent for IOS

gammaper's avatar

Thanks for your answer, what about information to develop that web application on Laravel?.

Snapey's avatar

create a route to receive the event from gps2gpsgate

Route::get('Gps/{vehicle}/GpsGate/','GpsGateController@feed');

and then the controller, receives the event as;

    /**
     * recieve a position event from a GPSGate protocol device or application
     * Like GpsGate?cmd=$FRCMD,355847052501769,_SendMessage,,5300.8595,N,00118.9156,W,59,0,0.0,220415,090512.404,1
     * 0 command = $FRCMD
     * 1 username = 355847012301769
     * 2 type = _SendMessage
     * 3 empty =''
     * 4 GPSLatitude =  5300.8595
     * 5 NorthSouth = 'N'   (or 'S')
     * 6 GPSLongitude = 00118.9156
     * 7 EastWest = 'W' (or 'E') for east of Greenwich
     * 8 Altitude = 59
     * 9 Speed = 0  in knots!
     * 10 Heading = 0.0
     * 11 Date = 220415
     * 12 Time = 090512.404
     * 13 buddy = 1
     * 14 checksum = ????
     * @return [type] [description]
     */
    public function feed(Request $request, $vehicle) {

        $gpsString = explode(',',$request->input('cmd'));

        if(($gpsString[0] != '$FRCMD') || ($gpsString[2] != '_SendMessage')) return 'Error in command format';

        // convert Lat from ddmm.mmmm format into decimal degrees
        $lat = intval($gpsString[4]/100);
        $lat = $lat + (($gpsString[4] - $lat*100) / 60);
        $lat = ($gpsString[5] == 'S')? 0-$lat : $lat;

        // convert Long
        $long = intval($gpsString[6]/100);
        $long = $long + (($gpsString[6] - $long*100) / 60);
        $long = ($gpsString[7] == 'W')? 0-$long : $long;

        // prepare the event that will be posted as a result of this GPS feed call

        $event = (object) array(
                'resource_name' => $vehicle,
                'latitude' => $lat,
                'longitude' => $long,
                'event' => 'Distance_Log',
                'ignition' => 0,
                'speed_ms' => $gpsString[9] * 0.514444,     //convert from knots to m/s
                'distance' => 0,
                'bearing' => $gpsString[10]+0
                );

        //then save the event and do whatever you need with it
1 like
kikearcos's avatar

Helo, I want to know more about this topic, I'm from Ecuador

kikearcos's avatar

how do I listen to the gps, any socket, help please

Please or to participate in this conversation.