Skip to content

Commit 5b21c24

Browse files
committed
Auto clip vector tile geometries
Automatically clip all geometries in an MVT request. The clipping rectangle is 6.25% larger than the tile. This will ensure that geometry points that are outside the viewing tile area are not included in the MVT binary, making for much smaller payloads, particularly for lower zoom levels.
1 parent c8ccb5e commit 5b21c24

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

internal/server/mvt.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/tidwall/geojson"
88
"github.com/tidwall/geojson/geometry"
99
"github.com/tidwall/mvt"
10-
"github.com/tidwall/tile38/internal/log"
1110
)
1211

1312
type mvtObj struct {
@@ -135,6 +134,5 @@ func mvtFilterHTTPArgs(msg *Message, query string) (modified bool) {
135134
msg.Args = append(msg.Args, "LIMIT", "100000000")
136135
}
137136
msg.Args = append(msg.Args, "MVT", parts[2], parts[3], parts[1])
138-
log.HTTPf("%s", path)
139137
return true
140138
}

internal/server/search.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,11 @@ func parseRectArea(ltyp string, vs []string) (nvs []string,
173173
}
174174
nvs = vs
175175
if ltyp == "mvt" {
176-
// expand rectangle by 10%
177-
178-
rect.Min.Y -= (rect.Max.Y - rect.Min.Y) * 0.1
179-
rect.Max.Y += (rect.Max.Y - rect.Min.Y) * 0.1
180-
rect.Min.X -= (rect.Max.X - rect.Min.X) * 0.1
181-
rect.Max.X += (rect.Max.X - rect.Min.X) * 0.1
176+
// Expand rectangle by 0.0625%
177+
rect.Min.Y -= (rect.Max.Y - rect.Min.Y) * 0.0625
178+
rect.Max.Y += (rect.Max.Y - rect.Min.Y) * 0.0625
179+
rect.Min.X -= (rect.Max.X - rect.Min.X) * 0.0625
180+
rect.Max.X += (rect.Max.X - rect.Min.X) * 0.0625
182181
if rect.Min.Y < bing.MinLatitude {
183182
rect.Min.Y = bing.MinLatitude
184183
}
@@ -386,6 +385,7 @@ func (s *Server) cmdSearchArgs(
386385
}
387386
if ltyp == "mvt" {
388387
lfs.mvt = true
388+
lfs.clip = true
389389
}
390390
case "get":
391391
if lfs.clip {

0 commit comments

Comments
 (0)