OGC 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 仓库
来自真实用户的反馈,见证轩辕镜像的优质服务
免费版仅支持 Docker Hub 加速,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
免费版仅支持 docker.io;专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像加速服务
在 Docker Desktop 配置镜像加速
Docker Compose 项目配置加速
Kubernetes 集群配置 Containerd
在宝塔面板一键配置镜像加速
Synology 群晖 NAS 配置加速
飞牛 fnOS 系统配置镜像加速
极空间 NAS 系统配置加速服务
爱快 iKuai 路由系统配置加速
绿联 NAS 系统配置镜像加速
QNAP 威联通 NAS 配置加速
Podman 容器引擎配置加速
HPC 科学计算容器配置加速
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名加速
需要其他帮助?请查看我们的 常见问题 或 官方QQ群: 13763429