Skip to content

Commit d0c19b6

Browse files
committed
Add README, prepare more elaborate URI rendering
1 parent eb4d271 commit d0c19b6

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# CSW Client
2+
A client to browse Geographic ***C***atalog ***S***ervices for the ***W***eb (CSW) which enables users to discover, browse, and query geospatial records in catalogues across the web.
3+
4+
## Prerequisites
5+
* git
6+
* Node.js (version 20 is recommended; other versions have not been tested)
7+
8+
9+
## Install
10+
```bash
11+
git clone this_repository
12+
cd this_repository
13+
npm install
14+
```
15+
16+
## Start
17+
Set up your OPENAI_API_KEY if you plan to use the translation feature requiring external API calls:
18+
```bash
19+
# Windows:
20+
set OPENAI_API_KEY=your_openai_api_key
21+
# Linux:
22+
export OPENAI_API_KEY=your_openai_api_key
23+
24+
# start the service
25+
node app.js
26+
27+
# point you browser to http://localhost:3000 to interact with the CSW Client
28+
```
29+
30+
## Project structure
31+
32+
This CSW Client is built on the [Express.js](https://expressjs.com) Web Application framework. Main entry point is module ```app.js```. This module sets up the http service routes (or 'handlers') to proxy CSW requests to CSW servers. The route results are returned as JSON. The ```app.js``` module also exposes directory ```public``` that hosts a csw client web application (```index.html``` + ```csw-app.js```) to be used in a browser (http://localhost:3000). The browser app displays a selection of predefined CSW servers to search. This list is defined in file ```endpoints.js```.
33+
34+
The actual requests and responses to the CSW servers are handled in module ```cswrequests.js```. Note that if you want to execute this request/response Javascript code directly in a browser (bypassing the Express.js proxy), the CSW server must allow CORS requests for this to work. The administrator of the CSW service may or may not have enabled CORS. Enabled CORS on the CSW server is not required for use in this project.

endpoints.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const cswEndPoints = [
44
{name: "linz", url: "https://data.linz.govt.nz/services/csw?service=CSW&version=2.0.2&request=GetRecords", language: "English"},
55
{name: "geo-solutions", url: "https://gs-stable.geo-solutions.it/geoserver/csw", language: "Italian"},
66
{name: "geoplatforme.fr", url: "https://data.geopf.fr/csw/", language: "French"},
7-
{name: "Bundesamt für Kartographie und Geodäsie (BKG)", url: "https://mis.bkg.bund.de/csw", language: "German"},
7+
{name: "B.amt für Kartogr und Geod. (BKG)", url: "https://mis.bkg.bund.de/csw", language: "German"},
88
{name: "GDI-DE", url: "https://gdk.gdi-de.org/geonetwork/srv/ger/csw", language: "German"},
99
{name: "ign-fr", url: "https://wxs.ign.fr/catalogue/csw-inspire/", language: "French"},
1010
{name: "ign-es", url: "http://www.ign.es/csw-inspire/srv/spa/csw", language: "Spanish"},

public/csw-app.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ class CSWApp extends LitElement {
225225
}
226226
}
227227
}
228+
renderUri(uri) {
229+
return html`${uri.protocol} <a href="${uri.url}" target="cswlink">${uri.name?uri.name:'No name'} ${uri.description}</a>`;
230+
}
228231
renderFullRecord(record) {
229232
if (!record) return html`<p>No record selected</p>`;
230233
const subject = record.subject ? Array.isArray(record.subject) ? record.subject.join(', ') : record.subject : '';
@@ -249,7 +252,7 @@ class CSWApp extends LitElement {
249252
<tr><td>Relation:</td><td> ${record.relation? html`<span @click="${(_e)=>this.updateFullRecord(record.relation)}">Link</span>`:'none'}</td></tr>
250253
<tr><td>Links: </td><td></td></tr>
251254
${record.URI ?
252-
record.URI.map(uri => html`<tr><td></td><td>${uri.protocol} <a href="${uri.url}" target="cswlink">${uri.name?uri.name:'No name'} ${uri.description}</a></td></tr>`)
255+
record.URI.map(uri => html`<tr><td></td><td>${this.renderUri(uri)}</td></tr>`)
253256
:
254257
html`<tr><td></td><td>no URI/URLs defined</td></tr>`
255258
}

0 commit comments

Comments
 (0)