tile38
/tile38
Obsługuje bazę geoprzestrzenną Tile38 z Go: zapisuje punkty, szuka w pobliżu i obsługuje geofencing oraz zdarzenia na żywo.
- Autor
- GO-VIRTUAL-bv ↗
- Repozytorium
- tile38.go ↗
- Licencja
- MPL-2.0
- Ostatnia zmiana repozytorium
- 12.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 1
Brak sygnałów. Repozytorium zmienione 12.10.2026, bez odwołań do wycofanych modeli i API.
MPL-2.0, otwarta.
Co robi i kiedy
Obsługuje bazę geoprzestrzenną Tile38 z Go: zapisuje punkty, szuka w pobliżu i obsługuje geofencing oraz zdarzenia na żywo.
Oryginalny opis (EN)
Use the tile38.go Go client (github.com/GO-VIRTUAL-bv/tile38.go) to talk to a Tile38 geospatial database — connect, SET/GET objects, run NEARBY/WITHIN/INTERSECTS/SCAN searches, and stream live geofences, channels, and hooks. Trigger when writing Go that stores or queries geospatial points, needs geofence/proximity events, or when the user mentions Tile38, geofence, NEARBY/WITHIN/INTERSECTS, or this client.
Jak działa
- Install
- Connect
- Core rule: chain, then call the terminal
- Searches
- Live geofences
- Everything else
Podgląd SKILL.md
---
name: tile38
description: Use the tile38.go Go client (github.com/GO-VIRTUAL-bv/tile38.go) to talk to a Tile38 geospatial database — connect, SET/GET objects, run NEARBY/WITHIN/INTERSECTS/SCAN searches, and stream live geofences, channels, and hooks. Trigger when writing Go that stores or queries geospatial points, needs geofence/proximity events, or when the user mentions Tile38, geofence, NEARBY/WITHIN/INTERSECTS, or this client.
---
# tile38.go
A dependency-free Go client for [Tile38](https://tile38.com). It speaks RESP over
`net.Conn` directly, so **live geofences** (a connection that streams events) are
first-class — something a Redis-library client cannot do.
This file is the fast path: the shape of the API and the one gotcha that bites
first. The catalog lives in the doc comments — see **Everything else** below.
## Install
```bash
go get github.com/GO-VIRTUAL-bv/tile38.go
```
Import path ends in `.go`; package is named `tile38`. Requires Go 1.25+.
```go
import "github.com/GO-VIRTUAL-bv/tile38.go"
```
## Connect
```go
c := tile38.New("localhost:9851", tile38.WithTimeout(2*time.Second))
defer c.Close()
if err := c.Ping(ctx); err != nil { return err }
```
Options: `WithPassword`, `WithMaxIdle`, `WithMaxActive`, `WithDialTimeout`,
`WithTimeout` — each doc comment states its default. `Client` is safe for
concurrent use; nothing connects until the first command.
## Core rule: chain, then call the terminal
Every command is a builder. Chain the parts **in any order** — they assemble into
protocol order at exec time. The terminal method is the one taking a `context`.
```go
// Write a point with a field and a 60s TTL.
err := c.Set("fleet", "truck1").EX(60).Field("speed", 42).Point(33.5, -115.5).Do(ctx)
// Read it back.
lat, lon, err := c.Get("fleet", "truck1").Point(ctx)
```
Method names mirror Tile38 keywords in Go casing (`Point`, `EX`, `Where`).
## Searches
Verbs `Nearby`, `Within`, `Intersects`, `Scan`. A search ends in `Do(ctx)`, and
an output format — `IDs`, `Points`, `Objects`, `Rects`, `Hashes`, `A5Cells` —
decides what `Do` returns; omit it for IDs. `Count(ctx)` and `Fence(ctx)` are
terminals instead, ending a chain in place of `Do`. Areas `Bounds`, `Circle`, `Object`, `Get`, `Tile`, `A5` (`Nearby`
uses `Point().Radius()`). Filters `Where`/`WhereIn`/`Match` accumulate;
`Limit`/`Cursor`/`Sparse`/`NoFields`/`Clip` overwrite.
```go
ids, err := c.Nearby("fleet").Where("speed > 40").Point(33.5, -115.5).Radius(5000).Do(ctx)
pts, err := c.Nearby("fleet").Point(33.5, -115.5).Radius(5000).Points().Do(ctx)
n, err := c.Within("fleet").Bounds(33, -116, 34, -115).Count(ctx)
```
### The 100-result cap — the #1 gotcha
**Tile38 caps every search except `Count` at 100 results when no `Limit` is set.**
`Do` is one round trip and one page: a capped page comes back with a nil error,
so a query that is complete against a small collection quietly returns a prefix
once that collection grows.
Range `Iter(ctx)` instead of calling `Do` to take everything — it pages itself
and yields one result at a time:
```go
for id, err := range c.Scan("fleet").Iter(ctx) {
if err != nil {
return err
}
use(id)
}
```
Otherwise set an explicit `Limit` (or `Cursor`), which also bounds `Iter` to that
one page, or page by hand with `Cursor`/`NextCursor`:
```go
scan := c.Scan("fleet")
ids, err := scan.Do(ctx)
if scan.NextCursor() != 0 {
// ids holds the first 100; more match.
}
```
### Errors
A `-ERR` reply is a `tile38.ServerError`: the command was rejected, the
connection is fine. Two sentinels cover a miss, matched with `errors.Is` through
every wrap: `ErrKeyNotFound` and `ErrIDNotFound`.
**Over RESP most misses are a null reply, not an error.** `GET`, `JGET` and
`BOUNDS` null out; only `FGET`, `FSET` and `RENAME` answer `-ERR`; `TTL` answers
`-2`. The client normalises all three onto the two sentinels. A null cannot say
which of the two went missing, so `Get`/`JGet` report `ErrIDNotFound` even for a
missing collection. `Set(...).NX()` over an existing object is a silent no-op,
not an error — use `Exists` if you need to know.
```go
lat, lon, err := c.Get("fleet", "truck1").Point(ctx)
switch {
case errors.Is(err, tile38.ErrIDNotFound):
// no such object; normal control flow, not a failure
case err != nil:
return err
}
```
`ErrUnexpectedReply` means the command was accepted but the reply did not decode
— a different problem from a rejection, and retrying will not fix it.
`ErrClosed` is a command issued on a closed `Client`.
## Live geofences
Adding `Fence` opens a `*Stream` instead of returning results. It owns its own
connection, has no read timeout, and must be `Close`d.
```go
st, err := c.Within("zones").Bounds(-90, -180, 90, 180).
Detect(tile38.Enter, tile38.Exit).Fence(ctx)
if err != nil { return err }
defer st.Close()
for {
ev, err := st.Next() // io.EOF after Close, ctx.Err() on cancel
if err != nil { return err }
fmt.Println(ev.Detect, ev.ID, string(ev.Object))
}
```
`Detect`: `Inside`, `Outside`, `Enter`, `Exit`, `Cross`. A `Nearby` fence can
`Roam("targets", 250)`. `Fence` is on `Nearby`, `Within` and `Intersects` only.
## Everything else
`go doc github.com/GO-VIRTUAL-bv/tile38.go <Symbol>` is the catalog. It is
generated from the code, so unlike this file it cannot be wrong — and every doc
comment carries the protocol quirk that bites at that call site: the 100-result
cap on each `Do`, why `NearbyCmd` has no `Buffer`, the three spellings of a miss
on `ErrIDNotFound`. Read the symbol rather than guessing at it.
The names to look up:
- **Server-side fences** — `SetChan`, `Subscribe`/`PSubscribe`, `SetHook`,
`Hooks`/`Chans`, `DelHook`/`DelChan`. The sibling `endpoint` package builds the
fourteen endpoint URL schemes (`endpoint.Kafka`, `endpoint.NATS`, …).
- **More searching** — `Search` (matches stored string values), `Test` with the
`Area*` constructors, `Buffer`, `WhereEval`/`WhereEvalSha`, `Asc`/`Desc`,
`Sparse`, `Distance`.
- **Reads and fields** — `Get(…)` terminals `Point`/`PointZ`/`Bounds`/`Object`/
`Hash`/`A5`/`WithFields`; `FGet`, `FSet`, `FExists`; `FieldOf[T]` and
`MustFieldOf[T]` to decode a field off a result.
- **Management** — `Del`, `Drop`, `PDel`, `Rename`, `Expire`, `Persist`, `TTL`,
`Exists`, `Keys`, `Bounds`, `Stats`, `DBSize`, `FlushDB`, `JSet`/`JGet`/`JDel`.
- **Server** — `ConfigGet`/`ConfigSet`/`ConfigRewrite`, `GC`, `Healthz`,
`AOFShrink`, `ReadOnly`, `Follow`/`FollowNone`, `Timeout`.
- **Batching** — `Pipeline()`, then `.Set(…).Queue()` per write and `Flush(ctx)`.
- **Anything unmodeled** — `c.Do(ctx, "SERVER")` sends a raw command; replies
decode to `string`, `int64`, `[]any` or `nil`.
Wersje
W bazie nie ma innych skilli o nazwie tile38.
Migawka bazy z 13.11.2026 · wersja paczki dd5bea424134 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100nearby
Wyszukuje miejsca i punkty zainteresowania w pobliżu lokalizacji na samodzielnie hostowanych danych map i pokazuje je na mapie, np. apteki w promieniu 2 km.