react-native-brouter 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +125 -0
- package/android/build.gradle +110 -0
- package/android/generated/java/com/jhotadhari/reactnative/brouter/NativeBRouterSpec.java +39 -0
- package/android/generated/jni/CMakeLists.txt +28 -0
- package/android/generated/jni/RNBRouterSpec-generated.cpp +32 -0
- package/android/generated/jni/RNBRouterSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNBRouterSpec/RNBRouterSpecJSI.h +38 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/aidl/btools/routingapp/IBRouterService.aidl +47 -0
- package/android/src/main/java/com/jhotadhari/reactnative/brouter/BRouterClient.java +205 -0
- package/android/src/main/java/com/jhotadhari/reactnative/brouter/BRouterError.java +38 -0
- package/android/src/main/java/com/jhotadhari/reactnative/brouter/BRouterModule.java +135 -0
- package/android/src/main/java/com/jhotadhari/reactnative/brouter/BRouterPackage.kt +33 -0
- package/android/src/main/java/com/jhotadhari/reactnative/brouter/BRouterServiceConnection.java +54 -0
- package/android/src/main/java/com/jhotadhari/reactnative/brouter/ParamMapper.java +174 -0
- package/android/src/test/java/com/jhotadhari/reactnative/brouter/BRouterClientTest.java +247 -0
- package/android/src/test/java/com/jhotadhari/reactnative/brouter/BRouterErrorTest.java +48 -0
- package/android/src/test/java/com/jhotadhari/reactnative/brouter/BRouterModuleTest.java +137 -0
- package/android/src/test/java/com/jhotadhari/reactnative/brouter/ParamMapperTest.java +279 -0
- package/lib/module/NativeBRouter.js +5 -0
- package/lib/module/NativeBRouter.js.map +1 -0
- package/lib/module/geojson/index.js +235 -0
- package/lib/module/geojson/index.js.map +1 -0
- package/lib/module/index.js +297 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/release.config.d.ts +11 -0
- package/lib/typescript/release.config.d.ts.map +1 -0
- package/lib/typescript/src/NativeBRouter.d.ts +9 -0
- package/lib/typescript/src/NativeBRouter.d.ts.map +1 -0
- package/lib/typescript/src/geojson/index.d.ts +122 -0
- package/lib/typescript/src/geojson/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +13 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +93 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +159 -0
- package/react-native.config.js +12 -0
- package/src/NativeBRouter.ts +8 -0
- package/src/geojson/index.ts +371 -0
- package/src/index.tsx +344 -0
- package/src/types.ts +112 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 jhotadhari
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# react-native-brouter
|
|
2
|
+
|
|
3
|
+
React Native Turbo Module for Android to communicate with the [BRouter](https://github.com/abrensch/brouter) Android app service for offline routing/navigation based on OpenStreetMap data.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install react-native-brouter
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Add this to your app's `AndroidManifest.xml`:
|
|
12
|
+
```xml
|
|
13
|
+
<queries>
|
|
14
|
+
<package android:name="btools.routingapp" />
|
|
15
|
+
</queries>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Install the [BRouter Android app](https://github.com/abrensch/brouter) on the device.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Core API
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { getRoute, type Waypoint } from 'react-native-brouter';
|
|
26
|
+
|
|
27
|
+
const waypoints: Waypoint[] = [
|
|
28
|
+
{ position: [-71.047736, -13.950089] },
|
|
29
|
+
{ position: [-70.902377, -13.791436] },
|
|
30
|
+
{ position: [-70.97545, -13.591525] },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const result = await getRoute({
|
|
35
|
+
waypoints,
|
|
36
|
+
vehicle: 'bicycle',
|
|
37
|
+
format: 'json',
|
|
38
|
+
});
|
|
39
|
+
console.log(result.raw); // JSON track string
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.log(e.code); // 'SERVICE_UNAVAILABLE' | 'INVALID_PARAMS' | ...
|
|
42
|
+
console.log(e.message); // human-readable description
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### GeoJSON API (works with `@turf/turf`)
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { getRoute } from 'react-native-brouter/geojson';
|
|
50
|
+
import turfAlong from '@turf/along';
|
|
51
|
+
import { lineString, point } from '@turf/helpers';
|
|
52
|
+
|
|
53
|
+
const result = await getRoute({
|
|
54
|
+
waypoints: [
|
|
55
|
+
[-71.047736, -13.950089],
|
|
56
|
+
[-70.902377, -13.791436],
|
|
57
|
+
[-70.97545, -13.591525],
|
|
58
|
+
],
|
|
59
|
+
vehicle: 'bicycle',
|
|
60
|
+
format: 'json',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// result.parsed.track → GeoJSON FeatureCollection<LineString>
|
|
64
|
+
// result.parsed.waypoints → GeoJSON FeatureCollection<Point>
|
|
65
|
+
// result.parsed.summary → { totalDistanceMeters, totalDurationSeconds, ascentMeters, ... }
|
|
66
|
+
|
|
67
|
+
// Use with turf:
|
|
68
|
+
const line = lineString(result.parsed.track.features[0].geometry.coordinates);
|
|
69
|
+
const midpoint = turfAlong(line, result.parsed.summary.totalDistanceMeters / 2);
|
|
70
|
+
console.log(midpoint.geometry.coordinates); // [lng, lat] of route midpoint
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Nogo Areas
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { getRoute } from 'react-native-brouter';
|
|
77
|
+
|
|
78
|
+
const result = await getRoute({
|
|
79
|
+
waypoints: [
|
|
80
|
+
{ position: [10, 20] },
|
|
81
|
+
{ position: [30, 40] },
|
|
82
|
+
],
|
|
83
|
+
vehicle: 'foot',
|
|
84
|
+
nogos: [
|
|
85
|
+
{ position: [15, 25], radiusMeters: 500 }, // simple circle
|
|
86
|
+
{ position: [35, 45], radiusMeters: 1000, weight: 2 }, // weighted
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### All Supported Options
|
|
92
|
+
|
|
93
|
+
| Option | Type | Description |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| `waypoints` | `Waypoint[]` (≥2) | Route waypoints with position, optional name, optional direct flag |
|
|
96
|
+
| `profile` | `string` | BRouter profile file name (without `.brf`) |
|
|
97
|
+
| `remoteProfile` | `string` | Raw profile content (overrides `profile` + `vehicle` + `fast`) |
|
|
98
|
+
| `vehicle` | `'motorcar' \| 'bicycle' \| 'foot'` | Travel mode |
|
|
99
|
+
| `fast` | `boolean` | Fast mode (ignored if `remoteProfile` is set) |
|
|
100
|
+
| `format` | `'gpx' \| 'kml' \| 'json'` | Output format (default `'gpx'`) |
|
|
101
|
+
| `alternativeIndex` | `0 \| 1 \| 2 \| 3` | Alternative route index (default 0) |
|
|
102
|
+
| `nogos` | `NogoArea[]` | Exclusion zones (position + radiusMeters + optional weight) |
|
|
103
|
+
| `polylines` | `Polyline[]` | Waypoint corridors |
|
|
104
|
+
| `polygons` | `Polygon[]` | Area constraints |
|
|
105
|
+
| `pois` | `Poi[]` | Points of interest in output |
|
|
106
|
+
| `exportWaypoints` | `boolean` | Include waypoints in output |
|
|
107
|
+
| `turnInstructionFormat` | `'osmand' \| 'locus'` | Turn instruction format |
|
|
108
|
+
| `turnInstructionMode` | `'none' \| 'auto-choose' \| 'locus' \| 'osmand' \| 'comment' \| 'gpsies' \| 'orux' \| 'locus-old'` | Turn instruction detail level |
|
|
109
|
+
| `heading` | `number` | Start direction in degrees |
|
|
110
|
+
| `direction` | `number` | Recalculation start direction in degrees |
|
|
111
|
+
| `elevation` | `boolean` | Request elevation data (`engineMode=2`) |
|
|
112
|
+
| `maxRunningTime` | `number` | Routing timeout in seconds (default 60) |
|
|
113
|
+
| `connectTimeout` | `number` | Connection timeout in ms (default 1000) |
|
|
114
|
+
| `pathToFileResult` | `string` | Save result to file path instead of returning |
|
|
115
|
+
| `acceptCompressedResult` | `boolean` | Compress gpx output |
|
|
116
|
+
| `extraParams` | `Record<string, string>` | Profile setup key=value pairs |
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
MIT
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
125
|
+
- The Java code to connect to the BRouter service is copied from [OsmAnd](https://github.com/osmandapp/OsmAnd)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['BRouter_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.9.1"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
|
|
24
|
+
def getExtOrIntegerDefault(name) {
|
|
25
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["BRouter_" + name]).toInteger()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def supportsNamespace() {
|
|
29
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
30
|
+
def major = parsed[0].toInteger()
|
|
31
|
+
def minor = parsed[1].toInteger()
|
|
32
|
+
|
|
33
|
+
// Namespace support was added in 7.3.0
|
|
34
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
android {
|
|
38
|
+
if (supportsNamespace()) {
|
|
39
|
+
namespace "com.jhotadhari.reactnative.brouter"
|
|
40
|
+
|
|
41
|
+
sourceSets {
|
|
42
|
+
main {
|
|
43
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
49
|
+
|
|
50
|
+
defaultConfig {
|
|
51
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
52
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
buildFeatures {
|
|
56
|
+
buildConfig true
|
|
57
|
+
aidl true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
buildTypes {
|
|
61
|
+
release {
|
|
62
|
+
minifyEnabled false
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
lintOptions {
|
|
67
|
+
disable "GradleCompatible"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
testOptions {
|
|
71
|
+
unitTests.returnDefaultValues = true
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
compileOptions {
|
|
75
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
76
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
sourceSets {
|
|
80
|
+
main {
|
|
81
|
+
java.srcDirs += [
|
|
82
|
+
"generated/java",
|
|
83
|
+
"generated/jni"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
repositories {
|
|
90
|
+
mavenCentral()
|
|
91
|
+
google()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
95
|
+
|
|
96
|
+
dependencies {
|
|
97
|
+
implementation "com.facebook.react:react-android"
|
|
98
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
99
|
+
|
|
100
|
+
testImplementation "junit:junit:4.13.2"
|
|
101
|
+
testImplementation "org.mockito:mockito-core:5.1.1"
|
|
102
|
+
testImplementation "net.bytebuddy:byte-buddy:1.14.12"
|
|
103
|
+
testImplementation "net.bytebuddy:byte-buddy-agent:1.14.12"
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
react {
|
|
107
|
+
jsRootDir = file("../src/")
|
|
108
|
+
libraryName = "BRouter"
|
|
109
|
+
codegenJavaPackageName = "com.jhotadhari.reactnative.brouter"
|
|
110
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.jhotadhari.reactnative.brouter;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
21
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
22
|
+
import javax.annotation.Nonnull;
|
|
23
|
+
|
|
24
|
+
public abstract class NativeBRouterSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
25
|
+
public static final String NAME = "BRouter";
|
|
26
|
+
|
|
27
|
+
public NativeBRouterSpec(ReactApplicationContext reactContext) {
|
|
28
|
+
super(reactContext);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public @Nonnull String getName() {
|
|
33
|
+
return NAME;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@ReactMethod
|
|
37
|
+
@DoNotStrip
|
|
38
|
+
public abstract void getRoute(ReadableMap params, Promise promise);
|
|
39
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
cmake_minimum_required(VERSION 3.13)
|
|
7
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
8
|
+
|
|
9
|
+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNBRouterSpec/*.cpp)
|
|
10
|
+
|
|
11
|
+
add_library(
|
|
12
|
+
react_codegen_RNBRouterSpec
|
|
13
|
+
OBJECT
|
|
14
|
+
${react_codegen_SRCS}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
target_include_directories(react_codegen_RNBRouterSpec PUBLIC . react/renderer/components/RNBRouterSpec)
|
|
18
|
+
|
|
19
|
+
target_link_libraries(
|
|
20
|
+
react_codegen_RNBRouterSpec
|
|
21
|
+
fbjni
|
|
22
|
+
jsi
|
|
23
|
+
# We need to link different libraries based on whether we are building rncore or not, that's necessary
|
|
24
|
+
# because we want to break a circular dependency between react_codegen_rncore and reactnative
|
|
25
|
+
reactnative
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
target_compile_reactnative_options(react_codegen_RNBRouterSpec PRIVATE)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "RNBRouterSpec.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_NativeBRouterSpecJSI_getRoute(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
static jmethodID cachedMethodId = nullptr;
|
|
17
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getRoute", "(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
NativeBRouterSpecJSI::NativeBRouterSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
21
|
+
: JavaTurboModule(params) {
|
|
22
|
+
methodMap_["getRoute"] = MethodMetadata {1, __hostFunction_NativeBRouterSpecJSI_getRoute};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
std::shared_ptr<TurboModule> RNBRouterSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
26
|
+
if (moduleName == "BRouter") {
|
|
27
|
+
return std::make_shared<NativeBRouterSpecJSI>(params);
|
|
28
|
+
}
|
|
29
|
+
return nullptr;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
14
|
+
#include <ReactCommon/TurboModule.h>
|
|
15
|
+
#include <jsi/jsi.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JNI C++ class for module 'NativeBRouter'
|
|
21
|
+
*/
|
|
22
|
+
class JSI_EXPORT NativeBRouterSpecJSI : public JavaTurboModule {
|
|
23
|
+
public:
|
|
24
|
+
NativeBRouterSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSI_EXPORT
|
|
29
|
+
std::shared_ptr<TurboModule> RNBRouterSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
template <typename T>
|
|
19
|
+
class JSI_EXPORT NativeBRouterCxxSpec : public TurboModule {
|
|
20
|
+
public:
|
|
21
|
+
static constexpr std::string_view kModuleName = "BRouter";
|
|
22
|
+
|
|
23
|
+
protected:
|
|
24
|
+
NativeBRouterCxxSpec(std::shared_ptr<CallInvoker> jsInvoker) : TurboModule(std::string{NativeBRouterCxxSpec::kModuleName}, jsInvoker) {
|
|
25
|
+
methodMap_["getRoute"] = MethodMetadata {.argCount = 1, .invoker = __getRoute};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private:
|
|
29
|
+
static jsi::Value __getRoute(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
30
|
+
static_assert(
|
|
31
|
+
bridging::getParameterCount(&T::getRoute) == 2,
|
|
32
|
+
"Expected getRoute(...) to have 2 parameters");
|
|
33
|
+
return bridging::callFromJs<jsi::Value>(rt, &T::getRoute, static_cast<NativeBRouterCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule),
|
|
34
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asObject(rt));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package btools.routingapp;
|
|
2
|
+
|
|
3
|
+
// Copy of https://github.com/abrensch/brouter/blob/master/brouter-routing-app/src/main/aidl/btools/routingapp/IBRouterService.aidl
|
|
4
|
+
|
|
5
|
+
interface IBRouterService {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
//param params--> Map of params:
|
|
9
|
+
// "pathToFileResult"-->String with the path to where the result must be saved, including file name and extension
|
|
10
|
+
// -->if null, the track is passed via the return argument, this should be default when Android Q or later
|
|
11
|
+
// "maxRunningTime"-->String with a number of seconds for the routing timeout, default = 60
|
|
12
|
+
// "turnInstructionFormat"-->String selecting the format for turn-instructions values: osmand, locus
|
|
13
|
+
// "trackFormat"-->[kml|gpx|json] default = gpx
|
|
14
|
+
// "acceptCompressedResult"-->[true] sends a compressed result when output format is gpx
|
|
15
|
+
// "lats"-->double[] array of latitudes; 2 values at least.
|
|
16
|
+
// "lons"-->double[] array of longitudes; 2 values at least.
|
|
17
|
+
// "nogoLats"-->double[] array of nogo latitudes; may be null.
|
|
18
|
+
// "nogoLons"-->double[] array of nogo longitudes; may be null.
|
|
19
|
+
// "nogoRadi"-->double[] array of nogo radius in meters; may be null.
|
|
20
|
+
// "fast"-->[0|1]
|
|
21
|
+
// "v"-->[motorcar|bicycle|foot]
|
|
22
|
+
// "remoteProfile"--> (String), net-content of a profile. If remoteProfile != null, v+fast are ignored
|
|
23
|
+
//
|
|
24
|
+
// "lonlats" = lon,lat|... (unlimited list of lon,lat waypoints separated by |)
|
|
25
|
+
// variantes: lon,lat,d|... (from this point to the next do a direct line)
|
|
26
|
+
// lon,lat,name|... (route point has a name and should not be ignored)
|
|
27
|
+
// "straight" = idx1,idx2,.. (optional, minimum one value, index of a direct routing point in the waypoint list)
|
|
28
|
+
// "nogos" = lon,lat,radius,weight|... (optional, list of lon, lat, radius in meters, weight (optional))
|
|
29
|
+
// "polylines" = lon,lat,lon,lat,...,weight|... (unlimited list of lon,lat and weight (optional), lists separated by |)
|
|
30
|
+
// "polygons" = lon,lat,lon,lat,...,weight|... (unlimited list of lon,lat and weight (optional), lists separated by |)
|
|
31
|
+
// "profile" = profile file name without .brf
|
|
32
|
+
// "alternativeidx" = [0|1|2|3] (optional, default 0)
|
|
33
|
+
// "exportWaypoints" = 1 to export them (optional, default is no export)
|
|
34
|
+
// "pois" = lon,lat,name|... (optional)
|
|
35
|
+
// "extraParams" = Bundle key=value list for a profile setup (like "profile:")
|
|
36
|
+
// "timode" = turnInstructionMode [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style, 7=locus-old-style] default 0
|
|
37
|
+
// "heading" = angle (optional to give a route a start direction)
|
|
38
|
+
// "direction" = angle (optional, used like "heading" on a recalculation request by Locus as start direction)
|
|
39
|
+
// "engineMode" = 0 (optional, default 0, 2 = get elevation)
|
|
40
|
+
|
|
41
|
+
// return null if all ok and no path given, the track if ok and path given, an error message if it was wrong
|
|
42
|
+
// the resultas string when 'pathToFileResult' is null, this should be default when Android Q or later
|
|
43
|
+
// call in a background thread, heavy task!
|
|
44
|
+
|
|
45
|
+
String getTrackFromParams(in Bundle params);
|
|
46
|
+
}
|
|
47
|
+
|