Skip to content

Commit

Permalink
Merge pull request #15 from GeoTecINIT/location-props
Browse files Browse the repository at this point in the history
Extend Location properties
  • Loading branch information
matey97 authored Aug 30, 2022
2 parents a08e75a + f81c909 commit 2d7083e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 18 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,16 @@ export const defaultConfig = {
#### [`LocationSensorSample`](src/internal/sensors/location/sample.ts)
| Property | Type | Description |
|-------------|-----------|---------------------------------|
| `latitude` | `number` | Latitude coordinate component. |
| `longitude` | `number` | Longitude coordinate component. |
| `altitude` | `number` | Altitude coordinate component. |
| Property | Type | Description |
|----------------------|----------|--------------------------------------------------------------|
| `latitude` | `number` | Latitude coordinate component. |
| `longitude` | `number` | Longitude coordinate component. |
| `altitude` | `number` | Altitude coordinate component. |
| `verticalAccuracy` | `number` | Estimated error in the latitude. |
| `horizontalAccuracy` | `number` | Estimated error in the longitude. |
| `speed` | `number` | Estimated device's speed when the location was acquired. |
| `direction` | `number` | Estimated device's direction when the location was acquired. |
### [`PlainMessageClient`](src/internal/communication/plain-message/android/plain-message-client.android.ts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ function getFakeLocationData() {
latitude: 39.9939752904,
longitude: -0.0741332084749,
altitude: 20,
verticalAccuracy: 10,
horizontalAccuracy: 10,
speed: 0,
direction: 90
};
}

function buildFakeEncodedMessage(expectedSamples: LocationSensorSample[]) {
const bytes = Array.create("byte", (4 + (32) * expectedSamples.length));
const bytes = Array.create("byte", (4 + (32 + 16) * expectedSamples.length)); // Int + (4 * Double + 4 * Float) * Size
for (let i = 0; i < bytes.length; i++) {
bytes[i] = 0;
}
Expand All @@ -51,6 +55,10 @@ function buildFakeEncodedMessage(expectedSamples: LocationSensorSample[]) {
buff.putDouble(sample.latitude);
buff.putDouble(sample.longitude);
buff.putDouble(sample.altitude);
buff.putFloat(sample.verticalAccuracy);
buff.putFloat(sample.horizontalAccuracy);
buff.putFloat(sample.speed);
buff.putFloat(sample.direction);
buff.putLong(sample.timestamp);
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,28 @@ export class LocationRecordMessagingService extends AbstractRecordMessagingServi
decodeSamples(messageEvent: wearOS.MessageEvent): SensorRecord<LocationSensorSample> {
const buff = ByteBuffer.wrap(messageEvent.getData());
const size = buff.getInt();
let lat, lon, alt, time;
let timestamp, latitude, longitude, altitude, verticalAccuracy, horizontalAccuracy, speed, direction;

const samples: LocationSensorSample[] = [];
for (let i = 0; i < size; i++) {
lat = buff.getDouble();
lon = buff.getDouble();
alt = buff.getDouble();
time = buff.getLong();
latitude = buff.getDouble();
longitude = buff.getDouble();
altitude = buff.getDouble();
verticalAccuracy = buff.getFloat();
horizontalAccuracy = buff.getFloat();
speed = buff.getFloat();
direction = buff.getFloat();
timestamp = buff.getLong();

samples.push({
timestamp: time,
latitude: lat,
longitude: lon,
altitude: alt,
timestamp,
latitude,
longitude,
altitude,
verticalAccuracy,
horizontalAccuracy,
speed,
direction
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/internal/sensors/location/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ export interface LocationSensorSample extends SensorSample {
latitude: number;
longitude: number;
altitude: number;
verticalAccuracy: number;
horizontalAccuracy: number;
speed: number;
direction: number;
}
4 changes: 2 additions & 2 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-wearos-sensors",
"version": "1.1.0",
"version": "1.2.0",
"description": "Plugin to develop smartphone apps that receive sensors' data from a paired WearOS smartwatch.",
"main": "wearos-sensors",
"typings": "index.d.ts",
Expand Down

0 comments on commit 2d7083e

Please sign in to comment.