Skip to content

Commit

Permalink
refactor(maptiles): unifiy crag and boundary props (#403)
Browse files Browse the repository at this point in the history
* refactor(maptiles): unifiy crag and boundary props
  • Loading branch information
vnugent authored May 29, 2024
1 parent 98d54fc commit a9ae822
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ TYPESENSE_API_KEY_RW=define_me
AUTH0_DOMAIN=https://dev-fmjy7n5n.us.auth0.com
AUTH0_KID=uciP2tJdJ4BKWoz73Fmln

MAPTILES_WORKING_DIR=./maptiles
MAPTILES_WORKING_DIR=./maptiles
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
{
"type": "node",
"request": "launch",
"name": "Crag Geojson",
"program": "${workspaceFolder}/src/db/export/CragGeojson/index.ts",
"name": "Generate map tiles",
"program": "${workspaceFolder}/src/db/utils/jobs/MapTiles/exportCmd.ts",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/build/**/*.js"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"jsonwebtoken": "^8.5.1",
"jwks-rsa": "^2.1.4",
"mongoose": "6.4.7",
"mongoose-lean-virtuals": "0.9.1",
"mongoose-lean-virtuals": "^0.9.1",
"node-fetch": "2",
"p-limit": "^4.0.0",
"pino": "^8.2.0",
Expand Down
12 changes: 9 additions & 3 deletions scripts/upload-tiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ set +a
S3_DEST=':s3,provider=Cloudflare,no_check_bucket=true,env_auth=true,acl=private:maptiles'

echo "------ Generating crags tiles file ------"
tippecanoe --force -o ${MAPTILES_WORKING_DIR}/crags.pmtiles -l crags -n "Crags" -zg ${MAPTILES_WORKING_DIR}/crags.*.geojson
tippecanoe --force -o ${MAPTILES_WORKING_DIR}/crags.pmtiles \
-l crags -n "Crags" \
--coalesce-densest-as-needed \
-z11 ${MAPTILES_WORKING_DIR}/crags.*.geojson

echo "**Uploading to remote storage"
rclone copy ${MAPTILES_WORKING_DIR}/crags.pmtiles ${S3_DEST}

echo "------ Generating crag group tiles file ------"
tippecanoe --force -o ${MAPTILES_WORKING_DIR}/crag-groups.pmtiles -l crag-groups -n "Crag groups" -zg ${MAPTILES_WORKING_DIR}/crag-groups.geojson
tippecanoe --force -o ${MAPTILES_WORKING_DIR}/areas.pmtiles \
-l areas -n "Areas" \
--drop-densest-as-needed \
-z8 ${MAPTILES_WORKING_DIR}/areas.geojson

echo "**Uploading to remote storage"
rclone copy ${MAPTILES_WORKING_DIR}/crag-groups.pmtiles ${S3_DEST}
rclone copy ${MAPTILES_WORKING_DIR}/areas.pmtiles ${S3_DEST}

exit $?
6 changes: 6 additions & 0 deletions src/db/AreaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export type AreaType = IAreaProps & {
*/
export interface IAreaProps extends AuthorMetadata {
_id: mongoose.Types.ObjectId

/**
* Area unique id (in UUID format). Same as `metadata.area_id`.
*/
uuid: MUUID

/**
* ShortCodes are short, globally uniqe codes that identify significant climbing areas
**/
Expand Down
8 changes: 6 additions & 2 deletions src/db/MediaObjectSchema.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import mongoose from 'mongoose'

import { MediaObject, EntityTag } from './MediaObjectTypes.js'
import { PointSchema } from './ClimbSchema.js'
import { MUUID } from 'uuid-mongodb'

const { Schema } = mongoose

const UUID_TYPE = {
type: 'object', value: { type: 'Buffer' }
}

const muuidTransform = (v: MUUID): string => {
return v.toUUID().toString()
}

const EntitySchema = new Schema<EntityTag>({
targetId: { ...UUID_TYPE, index: true, transform: (v: any) => v.toUUID().toString() },
targetId: { ...UUID_TYPE, index: true, transform: muuidTransform },
climbName: { type: Schema.Types.String },
areaName: { type: Schema.Types.String, required: true },
type: { type: Schema.Types.Number, required: true },
Expand Down
1 change: 1 addition & 0 deletions src/db/import/usa/AreaTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const makeDBArea = (node: AreaNode): AreaType => {
}
return {
_id,
uuid,
shortCode: '',
area_name: areaName,
children: Array.from(children),
Expand Down
Loading

0 comments on commit a9ae822

Please sign in to comment.