Skip to content

Commit f784bf0

Browse files
committed
docs: improve
Signed-off-by: Bartosz Czyż <czyzbartosz3@gmail.com>
1 parent 9740965 commit f784bf0

4 files changed

Lines changed: 115 additions & 6 deletions

File tree

here-naksha-cli/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Naksha CLI - Command Line Interface for Naksha
2+
3+
## How to Build and Run
4+
5+
Use the provided script `./naksha-cli` to build and run the CLI.
6+
7+
> [!NOTE]
8+
> The build process runs only once by default.
9+
> To force a rebuild, pass the `--Sbuild` flag:
10+
> ```bash
11+
> ./naksha-cli --Sbuild
12+
> ```
13+
14+
## Available Storages
15+
16+
The fat JAR includes the following built-in storage implementations:
17+
18+
- `com.here.naksha.cli.storages.GeneratingStorage`
19+
- `naksha.psql.PsqlStorage`
20+
21+
### Adding Custom Storage
22+
23+
You can add your own storage implementation by:
24+
25+
1. Creating a class that implements the required storage interface `naksha.model.IStorage`.
26+
2. Ensuring the class is **packaged inside the fat JAR** so it's available at runtime (i.e., included in the JAR's
27+
classpath).
28+
3. Editing the [Gradle build file](./build.gradle.kts) to include your custom storage class in the final JAR.
29+
30+
> [!NOTE]
31+
> Your custom storage class **must be included in the classpath of the fat JAR** in order to be discovered and loaded
32+
> correctly at runtime.
33+
34+
## Populated PostgreSQL
35+
36+
This module contains a prepared Dockerfile that utilizes the Naksha CLI to create a Docker image with a PostgreSQL
37+
database populated with random features. For more details, see the [docker](./docker/README.md).
38+
39+
## Releasing
40+
41+
To release a new version, use the command below. The JAR file will be prepared automatically.
42+
The JAR can be found in the [build/libs](./build/libs) directory.
43+
44+
```bash
45+
gradle releaseAndShadow -Prelease.forceVersion=0.1.1
46+
```
47+
48+
## Read More
49+
50+
For more information, see the [docs](./docs).

here-naksha-cli/docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
## Build image
1212
1313
- Move to `here-naksha-cli/docker` dir.
14-
- To edit generation's parameters edit files in `naksha-cli-files` dir. Look at `here-naksha-cli/docs/GeneratingStorageConfig.md` to learn more.
14+
- To edit generation's parameters edit files in `naksha-cli-files` dir. Look at [GeneratingStorageConfig.md](../docs/GeneratingStorageConfig.md) to learn more.
1515
> [!NOTE]
1616
> There are defaults targetMapId="genmap" and targetCollectionId="gencol".
1717
> You can change target's mapId and collectionId using build-args:

here-naksha-cli/docs/GeneratingStorageConfig.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ We define the configuration in a JSON file. The schema looks like this:
77
"id": "generating_storage",
88
"className": "com.here.naksha.cli.storages.GeneratingStorage",
99
"properties": {
10-
"count": 1000, // Required: Number of features to generate
11-
"idsPrefix": "genTest", // Optional: Prefix for generated feature IDs. Defaults to "gen" if not provided
12-
"featureTemplateFile": "sample_topology_feature.json", // Optional: Path to the feature template file used as a base for generated features.
10+
// Required: Number of features to generate
11+
"count": 1000,
12+
// Optional: Prefix for generated feature IDs. Defaults to "gen" if not provided
13+
"idsPrefix": "genTest",
14+
// Optional: Path to the feature template file used as a base for generated features.
15+
// It can be an absolute path or relative to the working directory
16+
"featureTemplateFile": "sample_topology_feature.json",
1317
// Either "tileIdsCsvFile" or "tileIds" must be provided to specify the tiles where features will be generated
18+
// Absolute path or relative to the working directory
1419
"tileIdsCsvFile": "tile_ids.csv",
1520
"tileIds": ["122013000000", "122013000001"]
1621
}

here-naksha-cli/docs/HOW_TO.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,62 @@
22

33
## Copy command
44

5+
### Database population
6+
7+
1. Prepare the source Storage Configuration
8+
9+
To generate features use Generating Storage. Look at [GeneratingStorageConfig.md](./GeneratingStorageConfig.md) to learn more about configuration.
10+
11+
Create `gen.json` file. The example content of the file:
12+
```json
13+
{
14+
"id": "test_generating_storage",
15+
"className": "com.here.naksha.cli.storages.GeneratingStorage",
16+
"properties": {
17+
"featureTemplateFile": "./sample_topology_feature.json",
18+
"count": 40000,
19+
"tileIdsCsvFile": "./tile_ids.csv",
20+
"idsPrefix": "gen"
21+
}
22+
}
23+
```
24+
25+
2. Prepare the target Storage Configuration
26+
27+
Create `psql.json` file. The example content of the file:
28+
```json
29+
{
30+
"id": "storage",
31+
"type": "Storage",
32+
"create": true,
33+
"upgrade": true,
34+
"className": "naksha.psql.PsqlStorage",
35+
"master": {
36+
"host": "0.0.0.0",
37+
"database": "postgres",
38+
"port": "5432",
39+
"user": "postgres",
40+
"password": "password",
41+
"readOnly": false
42+
}
43+
}
44+
```
45+
46+
3. Run the Copy Command
47+
```bash
48+
./naksha-cli copy \
49+
--srcStorageConfig gen.json \
50+
--targetStorageConfig psql.json \
51+
--targetMapId "targetmapid" \
52+
--targetCollectionId "targetcolid" \
53+
--autoCreateTarget
54+
```
55+
56+
### The same PsqlStorage as target and source
57+
558
1. Prepare the Storage Configuration
659

7-
In my case:
60+
Create `test_config.json` file. The example content of the file:
861
```json
962
{
1063
"id": "storage",
@@ -17,11 +70,12 @@
1770
"database": "postgres",
1871
"port": "5432",
1972
"user": "postgres",
20-
"password": "pass",
73+
"password": "password",
2174
"readOnly": false
2275
}
2376
}
2477
```
78+
2579
2. Run the Copy Command
2680
```bash
2781
./naksha-cli copy \

0 commit comments

Comments
 (0)