-
Notifications
You must be signed in to change notification settings - Fork 2
Tracking Service
Maciej Mionskowski edited this page Mar 6, 2017
·
5 revisions
Tracking service let's you set the current GPS position for a specific device and route.
import (
"github.com/route4me/route4me-go-sdk"
"github.com/route4me/route4me-go-sdk/tracking"
"github.com/route4me/route4me-go-sdk/routing" //You might need routing for device type
)
func main() {
client := route4me.NewClient("your-api-key")
service := &tracking.Service{Client: client}
}
To set the GPS position you have to obtain route-id
first. Learn how to do that.
import (
"github.com/route4me/route4me-go-sdk"
"github.com/route4me/route4me-go-sdk/tracking"
"github.com/route4me/route4me-go-sdk/routing" //You might need routing for device type
)
func main() {
client := route4me.NewClient("your-api-key")
service := &tracking.Service{Client: client}
query := &tracking.GPS{
RouteID: "route-id",
Latitude: 33.14384,
Longitude: -83.22466,
Course: 1,
Speed: 120,
DeviceType: routing.IPad,
MemberID: 1,
DeviceGUID: "TEST_GPS",
DeviceTimestamp: "2014-06-14 17:43:35",
}
_, err = service.SetGPS(query)
if err != nil {
//handle errors
return
}
}
In order to get last location, you have to acquire route-id
. Learn how to do that.
import (
"github.com/route4me/route4me-go-sdk"
"github.com/route4me/route4me-go-sdk/tracking"
"github.com/route4me/route4me-go-sdk/routing" //You might need routing for device type
)
func main() {
client := route4me.NewClient("your-api-key")
service := &tracking.Service{Client: client}
dataObject, err := service.GetLastLocation("route-id")
if err != nil {
//handle errors
}
//dataObject.TrackingHistory contains all tracking history
}
In order to device's location history, you have to acquire route-id
. Learn how to do that.
import (
"github.com/route4me/route4me-go-sdk"
"github.com/route4me/route4me-go-sdk/tracking"
"github.com/route4me/route4me-go-sdk/routing" //You might need routing for device type
)
func main() {
client := route4me.NewClient("your-api-key")
service := &tracking.Service{Client: client}
trackingHistory, err := service.GetDeviceLocationHistory(&tracking.TrackingHistoryQuery{
TimePeriod: tracking.TimePeriodCustom,
StartDate: unix-time-start-date,
EndDate: unix-time-end-date,
RouteID: `route-id`,
})
if err != nil {
//handle errors
}
//trackingHistory contains all tracking history
}
import (
"github.com/route4me/route4me-go-sdk"
"github.com/route4me/route4me-go-sdk/tracking"
"github.com/route4me/route4me-go-sdk/routing" //You might need routing for device type
)
func main() {
client := route4me.NewClient("your-api-key")
service := &tracking.Service{Client: client}
assetTracking, err := service.TrackAssets(`tracking-code`)
if err != nil {
//handle errors
}
//assetTracking contains all tracking data
}
You can look at service's test file for more implementation details.
- Activity
- Addressbook
- Routing
- Single Driver Route 10 Stops
- Single Driver Round Trip
- Single Depot Multiple Driver No Time Windows
- Single Depot Multiple Driver Time Windows
- Multiple Depot Multiple Driver
- Multiple Depot Multiple Driver With Time Windows
- Multiple Depot Multiple Driver With Time Windows (24 Stops)
- Tracking
- Geocoding
- Users
- Territories
- Orders
- Vehicles
- Telematics