Setup Pleiades
To setup Pleiades lookup and search, you can either use a separate API service (using the Pleiades API Docker image) or integrate its endpoints in your own API. Here we show the latter approach, which is more integrated and spares an additional service in the stack.
The Pleiades project integrated in Cadmus (but also usable as a standalone resource) contains the logic to import the downloadable JSON document with all data into a GIS-enabled Postgis database and an API to support lookup and extensive search.
Prerequisite
You must have the binary dump of the Pleiades database. If you need to create it:
- download JSON data from the official repository.
-
use the provided CLI tool to import it into a PostgreSQL PostGIS database and then dump it, e.g.:
./pleitool import-graph c:/users/dfusi/desktop/pleiades-places.json ./pleitool index c:/users/dfusi/desktop/pleiades-profile.json -c ./pleitool pop-spatial ./pleitool export c:/users/dfusi/desktop/dump - in the app server host, copy the dump binary files into a subfolder named
pleiades-data, placed in the same folder of yourdocker-compose.yml. This way, the next time your API starts (once its Docker image has been updated) it will automatically recreate the Pleiades database.
Backend
▶️ (1) add package Pleiades.Api.Controllers to your API.
▶️ (2) in your API Program.cs, add the Pleiades services:
using Pleiades.Api.Controllers;
private static void ConfigureAppServices(IServiceCollection services,
IConfiguration config)
{
// ...
// Pleiades (section Pleiades, ConnectionStrings:Pleiades; requires
// PostGIS; seeded from the binary dumps in Pleiades:DataDirectory)
services.AddPleiadesServices(config);
}
▶️ (3) in your API appsettings.json, add Pleiades settings (in this example my PostGIS service is running at port 5433 in localhost):
"ConnectionStrings": {
"Pleiades": "Server=localhost;Port=5433;Database=pleiades;User Id=postgres;Password=postgres;Include Error Detail=True"
}
"Pleiades": {
"DataDirectory": "/var/pleiades",
"EnableAutoInitialization": true,
"StopOnInitializationFailure": false
}
Frontend
In your frontend Cadmus editor:
▶️ (1) ensure to install the ngx-maplibre-gl Angular Maplibre wrapper and its dependencies (see https://github.com/vedph/cadmus-bricks-shell-v3/blob/master/projects/myrmidon/cadmus-refs-pleiades-lookup/README.md).
💡 For Maplibre setup you can also see https://github.com/vedph/cadmus-geo-shell/blob/master/maplibre-setup.md.
▶️ (2) install packages:
pnpm i @myrmidon/cadmus-refs-lookup @myrmidon/cadmus-refs-pleiades-lookup
▶️ (3) add to env.js the base URL for your Pleiades API, e.g.:
// local example:
window.__env.pleiadesUrl = "http://localhost:5101/api/";
// remote example:
window.__env.pleiadesUrl = "https://pleiades-api.fusi-soft.com/api/";
▶️ (4) to use Pleiades among the providers of a RefLookupSetComponent copy the icon from public/img/pleiades128.png and add a configuration like:
import {
PLEIADES_LOOKUP_OPTIONS_DIALOG_CONFIG,
PLEIADES_QUERY_DIALOG_CONFIG,
PleiadesLookupOptionsComponent,
PleiadesQueryDialogComponent,
PleiadesRefLookupService,
PleiadesSearchResult,
} from '@myrmidon/cadmus-refs-pleiades-lookup';
// in app.ts call configureLookup from your constructor
private configureLookup(storage: RamStorageService): void {
storage.store(LOOKUP_CONFIGS_KEY, [
// ...
// Pleiades
{
name: 'Pleiades',
iconUrl: '/img/pleiades128.png',
description: 'Pleiades gazetteer of ancient places',
label: 'ID',
service: inject(PleiadesRefLookupService),
itemIdGetter: (item: PleiadesSearchResult) => item?.id,
itemLabelGetter: (item: PleiadesSearchResult) => item?.name,
// the settings button opens the lookup filters (no place is picked)
optDialog: PleiadesLookupOptionsComponent,
optDialogConfig: PLEIADES_LOOKUP_OPTIONS_DIALOG_CONFIG,
// the More button opens the full Pleiades search to pick a place
moreDialog: PleiadesQueryDialogComponent,
moreDialogConfig: PLEIADES_QUERY_DIALOG_CONFIG,
},
]);
}
▶️ (5) if you create a Docker image with NGINX, ensure that it is configured to avoid long-term cache for MapLibre worker files, or you might get worker load errors when trying to use Maplibre:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
# ES modules (e.g. MapLibre worker): browsers require a JS MIME type
types {
application/javascript mjs;
}
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
listen [::]:80;
server_name localhost;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
# MapLibre worker files have no hash in their name: do not cache long-term
location /assets/maplibre-gl/ {
root /usr/share/nginx/html;
add_header Cache-Control "no-cache";
try_files $uri =404;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
▶️ (6) in your docker-compose.yml, add PostGIS and integrate the API in your API service:
services:
# PostGIS
cadmus-__PRJ__-pgis:
image: postgis/postgis
container_name: cadmus-__PRJ__-pgis
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
ports:
- 127.0.0.1:5433:5432
# required by the API's depends_on condition service_healthy
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
volumes:
- pgis-vol:/var/lib/postgresql
networks:
- cadmus-__PRJ__-network
# Cadmus __PRJ__ API
cadmus-__PRJ__-api:
# ...
depends_on:
# ...
- cadmus-__PRJ__-postgis
environment:
# ...
- CONNECTIONSTRINGS__PLEIADES=Server=cadmus-__PRJ__-pgis;port=5432;Database=pleiades;User Id=postgres;Password=postgres;Include Error Detail=True
volumes:
# copy bin dumps into ./pleiades-data
- ./pleiades-data:/var/pleiades:ro
volumes:
pgis-vol: