diff --git a/pmtiles/makesync.go b/pmtiles/makesync.go index f2ebc2c..80e4c20 100644 --- a/pmtiles/makesync.go +++ b/pmtiles/makesync.go @@ -418,8 +418,14 @@ func Sync(logger *log.Logger, file string, syncfilename string, overfetch float3 ranges := make([]SrcDstRange,0) for _, v := range wanted { - ranges = append(ranges,SrcDstRange{SrcOffset:v.Offset,DstOffset:v.Offset,Length:v.Length}) + l := len(ranges) + if l > 0 && (ranges[l-1].SrcOffset + ranges[l-1].Length) == v.Offset { + ranges[l-1].Length = ranges[l-1].Length + v.Length + } else { + ranges = append(ranges,SrcDstRange{SrcOffset:v.Offset,DstOffset:v.Offset,Length:v.Length}) + } } + fmt.Printf("need %d chunks.\n", len(ranges)) requests, _ := MergeRanges(ranges, overfetch) fmt.Printf("need %d requests with overfetch=%f.\n", requests.Len(), overfetch)