I’ve solved this exact GPS payload format and coordinate mapping issue multiple times across different device fleets on c8y-1018. Your 40% error rate and devices appearing in the ocean are classic symptoms of incorrect coordinate structure. Let me address all three focus areas comprehensively:
GPS Payload Format: The issue is that you’re using a custom position structure instead of Cumulocity’s standard c8y_Position fragment. The map widget ONLY recognizes the standard format:
{
"c8y_Position": {
"lat": 40.7128,
"lng": -74.0060,
"alt": 0,
"accuracy": 10
}
}
Note the key differences:
- Fragment must be named “c8y_Position” (not “position”)
- Longitude property must be “lng” (not “lon”)
- Optional altitude and accuracy fields improve visualization
Your current payload uses “lon” which the map widget might misinterpret as latitude, causing the coordinate swap that places devices in oceans.
Widget Device Template: The map widget configuration needs to explicitly reference the c8y_Position fragment. Edit your map widget settings:
- Verify the widget is configured to display devices with c8y_Position fragment
- Check that no custom coordinate mapping is overriding the standard behavior
- Ensure the device type filter includes all your fleet devices
Coordinate Mapping Solutions:
You have three implementation options depending on your architecture:
Option 1 - Device Firmware Update (Best long-term):
Modify device firmware to send c8y_Position directly:
{
"c8y_Position": {
"lat": {{latitude}},
"lng": {{longitude}},
"alt": {{altitude}},
"accuracy": {{gps_accuracy}}
},
"time": "{{timestamp}}"
}
Option 2 - Smart REST Template (Quick fix):
Create a template that transforms your custom format:
10,999,POST,/inventory/managedObjects/{{id}}/event,
11,999,,c8y_Position.lat,{{position.lat}}
11,999,,c8y_Position.lng,{{position.lon}}
Option 3 - Transformation Microservice (Most flexible):
Implement a microservice that:
- Subscribes to device measurements with your custom position format
- Transforms to c8y_Position
- Updates the device managed object
- Preserves original payload for audit purposes
Pseudocode for transformation microservice:
// Pseudocode - GPS format transformation microservice:
1. Listen for measurements with "position" fragment
2. Extract lat/lon values from custom format
3. Validate coordinates (lat: -90 to 90, lon: -180 to 180)
4. Create c8y_Position fragment with lng property
5. Update device managed object via Inventory API
6. Log transformation for debugging
// Deploy as Cumulocity microservice with event subscription
Fixing Existing Bad Data:
For the 40% of devices already showing incorrect locations, you need a data correction script:
// Pseudocode - Correct historical position data:
1. Query all devices with incorrect position fragments
2. For each device:
a. Fetch position history from audit logs
b. Extract original lat/lon values
c. Create corrected c8y_Position fragment
d. Update device managed object
e. Verify map widget displays correctly
3. Generate correction report for validation
Implementation Steps:
-
Immediate Fix (stops new bad data):
- Implement Smart REST template to transform incoming GPS data
- Test with 5-10 devices before fleet-wide deployment
- Verify map widget shows correct locations for test devices
-
Historical Data Correction (fixes existing bad data):
- Run the data correction script during off-peak hours
- Process devices in batches of 50 to avoid API rate limits
- Validate corrected locations against known device positions
-
Long-term Solution (permanent fix):
- Plan firmware update to send c8y_Position directly
- Phase out the transformation layer once all devices are updated
- Document the standard GPS payload format for future device integrations
-
Validation:
- Verify all devices appear at correct map locations
- Check that real-time position updates work properly
- Confirm historical position data is accessible and correct
Why Devices Appear in Oceans:
The “lon” vs “lng” mismatch causes the map widget to either:
- Swap latitude and longitude (placing land devices in oceans)
- Default to 0,0 coordinates (Gulf of Guinea off Africa)
- Misinterpret the coordinate system entirely
The combination of proper GPS payload format, correct widget device template configuration, and systematic coordinate mapping will resolve all location display issues. The Smart REST template approach can be implemented in hours and will immediately fix new incoming data, while the historical correction script can run overnight to fix existing bad positions.