Skip to content

Commit

Permalink
feat(doc): Improve the individual package documentations. BM-776 (#2981)
Browse files Browse the repository at this point in the history
#### Motivation
Tidy up individual READMEs, make sure text is up-to-date

#### Modification
- Review and rewrite all the individual READMES.
- Link through to package READMEs from main README

#### Checklist

- [ ] Tests updated
- [x] Docs updated
- [ ] Issue linked in Title

---------

Co-authored-by: Blayne Chard <[email protected]>
  • Loading branch information
Wentao-Kuang and blacha authored Oct 27, 2023
1 parent 6493957 commit 5a4adcb
Show file tree
Hide file tree
Showing 18 changed files with 339 additions and 207 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@

A digital basemap provides a consistent background detail necessary to orient location and add to aesthetic appeal. Basemaps can be made up of streets, parcels, boundaries (country, regional, and city boundaries), shaded relief of a digital elevation model, waterways, hydrography, aerial and satellite imagery. Basemaps can be used as desktop, website or mobile phone application components, or as a 3rd party layers within a GIS or desktop mapping application.

## Packages:

- [@basemaps/test](packages/__tests__/) - Testing utilities and assets
- [@basemaps/infra](packages/_infra/) - Infrastructure code using [AWS CDK](https://github.com/aws/aws-cdk)
- [@basemaps/attribution](packages/attribution/) - Calculate the attribution for given map location
- [@basemaps/bathymetry](packages/bathymetry/) - Convert bathymetry from [GEBCO](https://www.gebco.net/) into colorized HillShade geotiff.
- [@basemaps/cli](packages/cli/) - cli that using for CICD process
- [@basemaps/cogify](packages/cogify/) - CLI to re-tile imagery into a Cloud Optimised Geotiffs (COG)
- [@basemaps/config](packages/config/) - Configurations for Basemaps system
- [@basemaps/geo](packages/geo/) - Utility to work with QuadKeys, Tiles and Projections.
- [@basemaps/lambda-analytics](packages/lambda-analytics/) - Generate analytics from CloudFront distribution statistics
- [@basemaps/lambda-tiler](packages/lambda-tiler/) - Lambda server for WMTS/XYZ map generation
- [@basemaps/landing](packages/landing/) - The landing page for Basemaps
- [@basemaps/server](packages/server/) - cli for WMTS/XYZ Tile server
- [@basemaps/shared](packages/shared/) - Shared Utilities for other Basemaps packages
- [@basemaps/smoke](packages/smoke/) - Smoke tests
- [@basemaps/sprites](packages/sprites/) - sprite sheet generation
- [@basemaps/tiler](packages/tiler/) - Compose CogGeoTiffs for xyz tile server
- [@basemaps/tiler-sharp](packages/tiler-sharp/) - Generate tiles by using [sharp](https://github.com/lovell/sharp) and [libvips](https://github.com/libvips/libvips)
- [@linzjs/docker-command](packages/linzjs-docker-command/) - Utilities for running commands inside Docker
- [@linzjs/geojson](packages/linzjs-geojson/) - Utility for working with GeoJSON
- [@linzjs/metrics](packages/linzjs-metrics/) - Simple timing metric tracker for NodeJS

## Building

This repository requires [NodeJs](https://nodejs.org/en/) > 16 & [Yarn](https://yarnpkg.com/en/)
Expand Down
2 changes: 1 addition & 1 deletion packages/__tests__/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @basemaps/test

Testing utlities and assets
Testing utilities and assets

## Approx equal

Expand Down
39 changes: 24 additions & 15 deletions packages/_infra/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
# @basemaps/infra

Using AWS CDK to deploy and manage the infrastructure for basemaps
Infrastructure code that using [AWS CDK](https://github.com/aws/aws-cdk) to deploy and manage the AWS infrastructure for Basemaps

## Stacks

There are three stacks used for this system
There are three following stacks used for Basemaps system

### Table

API Key table, this dynamodb table is shared across stacks so it is deployed as a sperate stack.
It is used to track api key usage

### Edge

This is the edge of the tile serving, it is the egress point for all tiles. It deploys a CloudFront distribution with a lambda function that validates API Keys against the API Key Table
`TileMetadataTable` table, this dynamodb table is shared across stacks so it is deployed as a separated stack.
It is used to save the Metadata of the Basemaps configurations in the [@basemaps/config](../config/).

### Serve

The core tile generation service, this service generates the tiles and serves them via a application load balancer which is connected to Edge
The core tile generation service for [@basemaps/lambda-tiler](../lambda-tiler/) APIs, this service generates the tiles and serves them via a lambda URL which is connected to Edge CDN

### Edge

This is the edge of the tile serving, it is the egress point for all tiles.

## Usage

The infrastructure needs a number of environment variables to run

```javascript
// The accountId that will be used to deploy into
CDK_DEFAULT_ACCOUNT
CDK_DEFAULT_ACCOUNT;

// Due to the convoluted way that TLS certificates are made inside LINZ a hard coded TLS ARN is needed for the load balancer and Cloudfront
ALB_CERTIFICATE_ARN
CLOUDFRONT_CERTIFICATE_ARN
// Due to the convoluted way that TLS certificates are made inside LINZ a hard coded TLS ARN is needed for the Cloudfront
CLOUDFRONT_CERTIFICATE_ARN;
```


For first usage you will need to bootstrap the account, this will create a s3 bucket to store CDK assets in

```bash
Expand All @@ -43,5 +40,17 @@ npx cdk bootstrap
To create a CloudFormation template

```bash
cdk synth
npx cdk synth
```

To list all the available stacks

```bash
npx cdk list
```

To deploy `ServeStack` stack

```bash
npx cdk deploy ServeStack
```
2 changes: 1 addition & 1 deletion packages/attribution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Library to determine to applicable attribution for a given extent and zoom level
npm install @basemaps/attribution
```

```js
```typescript
import { Attribution } from '@basemaps/attribution';

const attributions = await Attribution.load('https://basemaps.linz.govt.nz/v1/tiles/aerial/EPSG:3857/attribution.json?api=...');
Expand Down
7 changes: 3 additions & 4 deletions packages/bathymetry/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Bathymetry creation
# @basemaps/bathymetry

## Bathymetry creation

This process takes batheymetric data from [GEBCO](https://www.gebco.net/) and converts it into a colorized hillshaded geotiff.

![](./images/bathyoutput.png)


## Usage

You will need:
Expand All @@ -18,7 +18,7 @@ You will need:
# Install dependencies
yarn add @basemaps/bathymetry

# To prevent very long CI/Dev build times, mapnik will need to be manually installed
# To prevent very long CI/Dev build times, mapnik will need to be manually installed
yarn add mapnik

# Ensure the javascript has been built
Expand All @@ -28,7 +28,6 @@ yarn build
node build/index.js -v create --input gebco_2020.nc --docker --output gebco/
```


## Process

![](./images/bathyprocess.png)
2 changes: 1 addition & 1 deletion packages/bathymetry/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"rootDir": "./src",
"outDir": "./build"
},
"include": ["src/**/*"],
"include": [".src/**/*"],
"references": [{ "path": "../__tests__" }, { "path": "../shared" }, { "path": "../cli" }]
}
118 changes: 10 additions & 108 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @basemaps/cli

CreateThis package is to control the configuration in the LINZ basemaps product.
This package contains cli's that are mainly used by the configuration and CICD processes in the LINZ Basemaps. All of the cli commands in this package will be build into docker container and publish as a [github container](https://github.com/linz/basemaps/pkgs/container/basemaps%2Fcli)

## Install

Expand All @@ -14,130 +14,32 @@ npm i @basemaps/cli

## Usage -- Bundle

Bundle config files into config bundle json from a given config path.
Bundle config files into config bundle json from a given config path. This is mainly use for [linz/basemaps-config](https://github.com/linz/basemaps-config) CICD process to bundle all the individual config json files into a single JSON bundle.

```bash
./bin/bmc.js bundle --config config/ --output config.json
./bin/bmc.js bundle --config config/ --assets assets/asset.tar --output config.json
```

## Usage -- Import

Import all configs from a bundled config.json into dynamo db from a given config path
Import all configs from a bundled config.json into dynamo db from a given config path. This is mainly use for [linz/basemaps-config](https://github.com/linz/basemaps-config) repository ci/cd process to deploy the config changes into DynamoDB.

```bash
./bin/bmc.js import --config config.json --commit
```

## Usage -- Screenshots
## Usage -- Create Config

Dump the screenshots from basemaps production
Create a individual config.json from a path of imagery for Basemaps to load as standalone server to view them. This is mainly used for the preview images for the Basemaps imagery import process.

```bash
./bin/bmc.js screenshot
./bin/bmc.js create-config --path s3://..../images/*.tiff --title image_title --commit
```

Dump the screenshots from different host
## Usage -- Overview

```bash
./bin/bmc.js screenshot --host HOST

```

Dump the screenshots with config file

```bash
./bin/bmc.js screenshot --config s3://..../config.json.gz

```

## Usage -- sprites

Generate a sprite sheet from a list of sprites

```
./bin/bmc.js sprites --ratio 1 --ratio 2 --path ./config/sprites/topographic --output assets
```

Outputs:

assets/topographic.json
assets/topographic.png

assets/[email protected]
assets/[email protected]

## Usage -- cogify

Create a collection of cloud optimized geotiff's from a collection of geotiff, that is optimized to be used in `@basemaps/tiler`

Create a list of COG's to create

```bash
./bin/bmc.js -V job --source ./source_folder/ --output ./source_folder/cogify/
```

Build a specific COG

```bash
./bin/bmc.js -V cog --job ./cogs/01DYREBEEFFXEPBAYBED2TMAFJ/job.json --name 1-2-3 --commit
```

Make cog job json
Create a overview tar file of tiles from the given of imagery. This create low zoom level tiles for the individual imagery and significantly improve the performance of serving individual imagery by pre-rendering and saving the tiles instead of rendering them on the fly.

```bash
./bin/bmc.js -V make-cog --imagery s3://imagery_path --target destination_bucket --name imagery_name --tile-matrix NZTM2000Quad --output ./jobs.json
./bin/bmc.js create-overview --config s3://..../images/*.tiff --output overview/overviews.tar.co
```

Split make cog job into chunked sub-jobs

```bash
./bin/bmc.js -V split-job --job s3://imagery_path/job.json --output jobs.json
```

## Advanced Job creation

Useful configuration options for `cogify job`

### Min Tile zoom `--min-zoom :number`

using the argument `--min-zoom` will configure the highest COG tile that can be created
for example, `--min-zoom 10` means tiles of zoom `0 - 10` can be created but `11` cannot.

This is useful to control the size of COGS across varying imagery sets World level z0-5 vs region z12-15 vs specific area 20+

### Concurrency `--concurrency :number`

To load metadata quickly from S3 a lot of actions are run concurrently. using `--concurrent` controls the number of requests that can be outstanding at one time.

### Max COGs `--max-cogs :number`

Controls the number of output COGs to create for small imagery sets (<50GB) this number should be low < 5 for larger imagery sets this number can be much larger (100+ for TB+ imagery sets)

### GeoJson `--geojson`

Outputs two GeoJSON files to provide a representation of the source and target imagery, this can be used to help tune the generation parameters

## Building a COG collection

The best way to build a cog collection is to create multiple JOBS with `--geojson` enabled while adjusting `--max-cogs` and `--min-zoom` when a good covering is found the job can then be submitted to AWS for processing.

Using a large area of interest as shown in the imagery set below and is showing three different sets of parameters, The shaded green area is the original source imagery

![Example Covering](./static/example-covering.png)

### Green outline

**Arguments:** `--max-cogs 5 --min-zoom 15`
This has too much empty space inside the tile areas and is not a good example of a good collection of COGs to make.

### Red outline

**Arguments:** `--max-cogs 500 --min-zoom 25`

This creates too many tiles with many only including one or two source images.

### Blue outline

**Arguments:** `--max-cogs 70 --min-zoom 20`

This creates a decent covering without wasting too much space and not creating large area's of empty COG
Loading

0 comments on commit 5a4adcb

Please sign in to comment.