このKongプラグインは、FIWARE Orion Context Brokerからのレスポンスをインターセプトし、GeoJSON形式に変換するためのものです。
FIWARE OrionのNGSI v2レスポンスをGeoJSON形式に変換するKongプラグインです。エンティティの位置情報を抽出し、標準的なGeoJSON形式で提供します。
kong/plugins/orion2GeoJSON/
├── handler.lua # メイン処理ロジック
└── schema.lua # 設定スキーマ定義
- リクエスト受信
- レスポンスボディの取得(body_filterフェーズ)
- エンティティタイプと位置情報の検証
- GeoJSON形式への変換
- レスポンスの返却
| パラメータ | 必須 | デフォルト値 | 説明 |
|---|---|---|---|
| entity_type | はい | - | 変換対象のエンティティタイプ(例:Room, Car など)。アルファベット、数字、ハイフン、アンダースコアのみ使用可能。 |
| location_attr | はい | - | 位置情報を含む属性名(例:location)。アルファベット、数字、ハイフン、アンダースコアのみ使用可能。 |
| output_format | はい | FeatureCollection | 出力形式。"FeatureCollection"(複数エンティティ)または"Feature"(単一エンティティ)。 |
curl 'http://localhost:8000/orion/v2/entities/Room1?type=Room'{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [13.3986112, 52.554699]
},
"properties": {
"temperature": 23,
"humidity": 45
}
}curl 'http://localhost:8000/orion/v2/entities?type=Room'{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [13.3986112, 52.554699]
},
"properties": {
"temperature": 23
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [13.3986113, 52.554700]
},
"properties": {
"temperature": 25
}
}
]
}# リポジトリのクローン
git clone https://github.com/[username]/kong-plugin-orion2GeoJSON.git
cd kong-plugin-orion2GeoJSON
# Pongoのインストール(初回のみ)
curl -Ls https://get.konghq.com/pongo | bash
export PATH=$PATH:~/.local/bin# すべてのテストを実行
pongo run
# 特定のテストファイルを実行
pongo run spec/plugin-orionGeoJSON/01-unit_spec.lua# テスト環境の起動
pongo up
# テスト用シェルの起動
pongo shell# Luaインタープリタの起動
luarocks test
# プラグインの動作確認
curl localhost:8000/orion/v2/entities- Kong Gateway
- Orion v3.10.1
- MongoDB 4.4
Apache License 2.0