geonetwork/gn-cloud-ogc-api-records-serviceOGC API Records 是一个基于 OGC API Records 标准实现的服务,用于提供记录集合的标准化 API 访问。该服务允许客户端查询记录集合、检索单个记录、执行高级搜索(包括全文搜索、空间搜索等),并支持多种输出格式和多语言响应,适用于地理信息元数据管理、数据目录服务等场景。
q 参数)bbox 参数,支持空间相交关系)externalids 参数)limit 和 startindex 参数)f URL 参数显式指定格式(如 ?f=xml)通过 Accept-Language 请求头或 l URL 参数指定响应语言(如 Accept-Language: fr 或 ?l=fr)。
shell# 编译并生成 OpenAPI 代码 mvn clean compile
生成的代码位于 target/generate-sources 目录。
shell# 默认启动(使用默认端口和配置) mvn spring-boot:run # 自定义端口和 Profile SERVER_PORT=9901 mvn spring-boot:run -Dspring-boot.run.profiles=standalone
运行中更新 XSLT 资源文件:
shellmvn process-resources # 若需更新其他模块共享的 XSLT(如 common-view 模块),可通过以下方式: # cd modules/library/common-view; mvn compile # 或创建符号链接(示例): # cd modules/services/ogc-api-records/service/src/main/resources/xslt # ln -s ../../../../../../../library/common-view/src/main/resources/xslt/core core
shellmvn package
shell# 基础启动(指定端口和 standalone Profile) SERVER_PORT=9901 java -Dspring.profiles.active=standalone -jar target/gn-ogc-api-records.jar # 自定义配置文件位置 SERVER_PORT=9901 java -Dspring.profiles.active=standalone -Dspring.config.location=./config/ -jar target/gn-ogc-api-records.jar
shellcd modules/services/ogc-api-records/service mvn package -Pwar,-docker
shellmvn jetty:run -Pwar -Dspring.profiles.active=standalone -Dspring.config.location=./service/src/main/resources/
| 参数名 | 描述 | 默认值 |
|---|---|---|
SERVER_PORT | 服务监听端口 | 8080 |
-Dspring.profiles.active=standalone 指定,支持多环境配置-Dspring.config.location=./config/ 指定外部配置目录(优先级高于内置配置)| 参数名 | 描述 | 示例 |
|---|---|---|
limit | 每页记录数 | ?limit=20 |
startindex | 分页起始索引(默认 0) | ?startindex=20&limit=20 |
q | 全文搜索关键词 | ?q=map |
bbox | 空间范围(minx,miny,maxx,maxy) | ?bbox=-100,40,-80,50 |
externalids | 记录 UUID 筛选(支持多个值) | ?externalids=uuid1&externalids=uuid2 |
l | 响应语言 | ?l=fr |
f | 输出格式 | ?f=xml |
shellcurl 127.0.0.1:9901/collections \ -H "Accept: application/json"
shell# 通过 Accept-Language 头 curl 127.0.0.1:9901/collections \ -H "Accept: text/html" -H "Accept-Language: fr" # 通过 l 参数 curl 127.0.0.1:9901/collections?l=fr \ -H "Accept: text/html"
shell# 提取首个集合名称 firstCollection=$( \ curl 127.0.0.1:9901/collections \ -H "Accept: application/json" \ | jq -r '.collections[0].name' \ ) # 查询集合详情 curl 127.0.0.1:9901/collections/$firstCollection \ -H "Accept: application/json"
shellcurl 127.0.0.1:9901/collections/$firstCollection \ -H "Accept: application/opensearchdescription+xml"
shellcurl 127.0.0.1:9901/collections/$firstCollection/sortables \ -H "Accept: application/json"
shell# JSON 格式 curl 127.0.0.1:9901/collections/$firstCollection/items \ -H "Accept: application/json" # XML 格式 curl 127.0.0.1:9901/collections/$firstCollection/items \ -H "Accept: application/xml" # RSS 格式 curl 127.0.0.1:9901/collections/$firstCollection/items \ -H "Accept: application/rss+xml"
shell# 限制每页 20 条记录 curl 127.0.0.1:9901/collections/$firstCollection/items?limit=20 \ -H "Accept: application/json" # 从第 20 条开始,每页 20 条(第二页) curl 127.0.0.1:9901/collections/$firstCollection/items?startindex=20&limit=20 \ -H "Accept: application/json"
shellcurl 127.0.0.1:9901/collections/$firstCollection/items?q=map \ -H "Accept: application/json"
shell# bbox 参数格式:minx,miny,maxx,maxy(空间相交关系) curl 127.0.0.1:9901/collections/$firstCollection/items?bbox=-100,40,-80,50 \ -H "Accept: application/json"
shellcurl 127.0.0.1:9901/collections/$firstCollection/items?externalids=8306437bc59910b70223865b44100ffab97ba069&externalids=8a9bc9e8f86cb02be8be4450e310d261415ac909 \ -H "Accept: application/json"
shell# 提取首个记录 ID uuid=$( \ curl 127.0.0.1:9901/collections/$firstCollection/items \ -H "Accept: application/json" \ | jq -r '.hits.hits[0]._id' \ ) # JSON 格式 curl 127.0.0.1:9901/collections/$firstCollection/items/$uuid \ -H "Accept: application/json" # JSON-LD 格式 curl 127.0.0.1:9901/collections/$firstCollection/items/$uuid \ -H "Accept: application/ld+json" # XML 格式 curl 127.0.0.1:9901/collections/$firstCollection/items/$uuid \ -H "Accept: application/xml" # DCAT2 XML 格式 curl 127.0.0.1:9901/collections/$firstCollection/items/$uuid \ -H "Accept: application/dcat2+xml" # Turtle 格式 curl 127.0.0.1:9901/collections/$firstCollection/items/$uuid \ -H "Accept: text/turtle" # RDF XML 格式 curl 127.0.0.1:9901/collections/$firstCollection/items/$uuid \ -H "Accept: application/rdf+xml"
shell# 构建 JAR 包(需本地预先构建) mvn package # 启动容器(standalone 模式,暴露 9901 端口,挂载配置目录) docker run -d \ --name ogc-api-records \ -p 9901:9901 \ -e SERVER_PORT=9901 \ -e SPRING_PROFILES_ACTIVE=standalone \ -v $(pwd)/config:/app/config \ -v $(pwd)/target/gn-ogc-api-records.jar:/app/gn-ogc-api-records.jar \ openjdk:11-jre-slim \ java -jar /app/gn-ogc-api-records.jar
创建 docker-compose.yml 文件:
yamlversion: '3.8' services: ogc-api-records: image: openjdk:11-jre-slim container_name: ogc-api-records restart: always ports: - "9901:9901" environment: - SERVER_PORT=9901 - SPRING_PROFILES_ACTIVE=standalone - SPRING_CONFIG_LOCATION=file:/app/config/ volumes: - ./config:/app/config # 外部配置目录(可选) - ./target/gn-ogc-api-records.jar:/app/gn-ogc-api-records.jar command: java -jar /app/gn-ogc-api-records.jar
启动服务:
shelldocker-compose up -d
GitHub 仓库

manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务