Demo server
Setting up a demo OGCAPI-Records
In order to run OGCAPI-Records, you will need:
- PostgreSQL/PostGIS database
- Elastic Search (recommend v8.14)
- GN4
- GN5
Setting up PostgreSQL
This container (kartoza/postgis:16-3.4) is for an M1 mac - use a different docker container for an X64 machine.
docker run -p 5432:5432 -e POSTGRES_PASS=postgres -e POSTGRES_USER=postgres kartoza/postgis:16-3.4
PGPASSWORD=postgres psql -h localhost -U postgres -d template1 -c "create database gn;"
PGPASSWORD=postgres psql -h localhost -U postgres -d gn -c "create extension postgis;"
PGPASSWORD=postgres psql -h localhost -U postgres -d gn -c "CREATE USER \"www-data\" WITH SUPERUSER PASSWORD 'www-data';"
This will:
- run the
dockerPostgreSQL/PostGIS container (available on PORT 5432). The admin user will be postgres/postgres. - create a database called
gn - add the PostGIS extension to the database
- add a super user with name
www-dataand passwordwww-data.
These settings should match what is in your GN5 application.yml file.
To run a psql session:
Setup Elastic Search (recommend v8.14)
This will run an elastic search docker container (v8.14.0) on port 9200.
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" -e "xpack.security.enrollment.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:8.14.0
This does not have any indexes in it - when you run GN4 (see below) it will add the indexes.
Here are some interesting URLs:
- http://localhost:9200/ Cluster URL
- http://localhost:9200/gn-records/_search?pretty=true&q=: All records in the index
- http://localhost:9200/gn-records/_search?pretty=true&q=_id:ce6dc729-7ec0-4ba9-baf8-4bc1525120c8 Show a particular record (by metadata ID)
- http://localhost:9200/gn-records The index definition (advanced users only!)
Setup GN4
Run GeoNetwork 5 connected to the PostgreSQL/PostGIS database. The easiest way to do this is to checkout and build GN4 from source.
cd web
mvn jetty:run -Dgeonetwork.db.type=postgres-postgis -Djdbc.database=gn -Djdbc.username=www-data -Djdbc.password=www-data -Djdbc.host=localhost -Ddb.port=5432 -Djdbc.port=5432
DEMO GN4 setup
Here are some steps to take to setup some data in GN4. This demo will include the 5 iso19139 sample records supplied with GN4 and two extra ones we will use to annotate geonetwork portals (Also called sources in GeoNetwork and collections or catalogs in OGCAPI-Records).
We then create a sub-portal (called "subportal") and attach the subportal.xml record to it.
We then attach the main.xml record to the main portal.
Setup Records
- Login as admin http://localhost:8080/geonetwork
- Go to
Admin console->Metadata and Templates- Tick
Geographic information -- Metadata (iso19139:2007) (iso19139)and pressLoad samples for selected standards
- Tick
- Download main.xml and subportal.xml which are two extra sample metadata records.
- Go to
Contribute->Import New Records- Tick
Publish - Choose the
main.xmlyou downloaded (above) (useChoose or drop resource here) - Press
Import
- Tick
- Go to
Contribute->Import New Records- Tick
Publish - Choose the
subportal.xmlyou downloaded (above) (useChoose or drop resource here) - Press
Import
- Tick
At this point you should have 7 records in your GN4 installation.
Setup Portals
- Login as admin http://localhost:8080/geonetwork
- Go to
Admin console->Settingsand chooseSourceson the left column. - Press "Add portal"
Identifier- subportalName- SubPortalSearch Filter- leave this blank, you can modify this later if you wantRecords to use for GetCapabilities- type "sub" and then choose the "GeoCat Demo OGCIAPI sub-portal" record- Choose a logo from the
Logo Selection - Press "Save"
- On the Left hand column, choose
Settings- Go down to the "Catalog Services for the Web"
- In the
Record to use for GetCapabilities, type "4e2e361b-02cf-499f-b16e-7eff87925e40" - Press
Save Settings(very top)
NOTE: There's no way to edit the GeoNetwork Source for the main-portal, so we use the CSW GetCapabilities link instead!
Setup GN5
You should be able to just run GeoNetwork 5 (from source).
- Checkout GN5 from GitHub
- Verify that the
application.xml(inconfig/) - Build (with java21):
mvn clean install -DskipTests - Run with:
Running the DEMO
- Go to http://localhost:7979/v3/api-docs?f=json to see the OpenAPI (swagger) documentation.
- Go to http://localhost:7979/ogcapi-records/?f=json
- This is the OGCAPI-Records Landing Page
- The title should be "GeoCat Demo OGCIAPI Server"
- Notice that it has an extra
catalogInfowhich contains information taken frommain.xml
- Go to http://localhost:7979/ogcapi-records/collections?f=json
- This is the OGCAPI-Records Collections ("Catalogs") page
- There should be two collections - "GeoCat Demo OGCIAPI Server" and "GeoCat Demo OGCIAPI sub-portal"
- Notice that the title (and contact) information is coming from the linked metadata records (
main.xmlandsubportal.xml)
- Go to http://localhost:7979/ogcapi-records/collections/subportal?f=json
- This is the OGCAPI-Records Collection ("Catalog") page for the sub-portal collection
- The metadata about this is coming from the attached
subportal.xmlrecord
- Go to http://localhost:7979/ogcapi-records/collections/subportal/queryables?f=json
- This is the OGCAPI-Records Queryables page for the sub-portal collection
- This are all the "extra" ways you can query the collection
- Advanced users can see how this is configured in queryables.json.
- Go to http://localhost:7979/ogcapi-records/collections/subportal/items?f=json
- This is the OGCAPI-Records Items page for the sub-portal collection
- This returns a GeoJSON feature collection JSON document
- Since we haven't put a filter on the sub-portal, all 7 metadata records in the GN4 catalog will be shown
- Go to http://localhost:7979/ogcapi-records/collections/subportal/items/da165110-88fd-11da-a88f-000d939bc5d8?f=json
- This is the OGCAPI-Records Items page for single record in the sub-portal collection
- This is the JSON representation of the ISO19193 record (in the format specified by the OGCAPI-Records specification and in GeoJSON format)
- It also contains the underlying record, in XML, in the the
metadataRecordTextproperty
Here are some queries you can run (see the queryables):
- Find
contactsthat contain "jody" http://localhost:7979/ogcapi-records/collections/subportal/items?contacts=jody&f=json - Find by
idhttp://localhost:7979/ogcapi-records/collections/subportal/items?id=9bac358b-11ec-4293-aeef-5a077b778412&f=json - Find by
organizationhttp://localhost:7979/ogcapi-records/collections/subportal/items?organization=geocat&f=json - Find by
keywordhttp://localhost:7979/ogcapi-records/collections/subportal/items?keywords=africa&f=json - Find records created in 2008 http://localhost:7979/ogcapi-records/collections/subportal/items?created=2007-01-01/2007-12-31&f=json
NOTE: See the OGCAPI-Records Specification for more info on querying.
NOTE: You can change the above URLs to have 'f=html`. However, the current HTML page is trivial - just showing the JSON result.