tile38 一款开源的geo 数据库

tile38 是基于golang 编写的geo 数据库,支持地理空间索引、实时地理围栏,同时也支持leader-flower 的部署模型
备注: 下边测试一个简单的地理围栏功能

环境准备

  • docker-compose 文件
    包含了一个简单的webhook 工具
 
version: "3"
services:
  app:
    image: tile38/tile38
    ports:
    - "9851:9851"
  benthos:
    image: jeffail/benthos
    volumes:
    - "./conf/webhook.yaml:/benthos.yaml"
    ports:
    - "4195:4195"
 

运行&&测试地理围栏功能

启动

docker-compose up -d

使用

  • 进入容器 app (tile38 服务)
docker-compose exec app sh
tile38-cli
 
  • 添加webhook格式
SETHOOK name endpoint [META name value ...] [EX seconds] NEARBY|WITHIN|INTERSECTS key FENCE [DETECT what] [COMMANDS which] param [param ...]
 
  • 添加数据围栏:
/ # tile38-cli
127.0.0.1:9851> SETHOOK warehouse http://benthos:4195/ NEARBY fleet FENCE POINT 33.462 -112.268 6000
{"ok":true,"elapsed":"118.008µs"}
 
  • 添加进入围栏区域的数据
SET fleet truck1 POINT 33.5123 -112.2693
  • webhook 数据
docker-compose logs -f benthos

效果

benthos_1 | get email message: {"command":"set","group":"5c395823b1e3cb00012724bc","detect":"enter","hook":"warehouse","key":"fleet","time":"2019-01-12T02:59:47.766263252Z","id":"dalong","object":{"type":"Point","coordinates":[-112.2693,33.5123]}}
benthos_1 | get email message: {"command":"set","group":"5c395823b1e3cb00012724bc","detect":"inside","hook":"warehouse","key":"fleet","time":"2019-01-12T02:59:47.766263252Z","id":"dalong","object":{"type":"Point","coordinates":[-112.2693,33.5123]}}

说明:
默认的webhook 数据会包含所有包含的类型,我们可以指定需要的类型

 
NEARBY fleet FENCE DETECT inside,outside POINT 33.462 -112.268 6000

说明

tile38 使用简单,包含了rest 以及resp 协议的支持,同时webhook支持多种协议 http,https,redis,nats,grpc。。。

参考资料

https://tile38.com/topics/geofencing/
https://github.com/tidwall/tile38

posted on 2019-01-12 11:08  荣锋亮  阅读(2723)  评论(0编辑  收藏  举报

导航