Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bound.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var emptyBound = Bound{Min: Point{1, 1}, Max: Point{-1, -1}}

// A Bound represents a closed box or rectangle.
// To create a bound with two points you can do something like:
//
// orb.MultiPoint{p1, p2}.Bound()
type Bound struct {
Min, Max Point
Expand Down
10 changes: 5 additions & 5 deletions clip/smartclip/smart.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,11 @@ func smartWrap(box orb.Bound, input []orb.LineString, o orb.Orientation) orb.Mul

const notOnSide = 0xFF

// 4
// +-+
// 1 | | 3
// +-+
// 2
// : 4
// : +-+
// : 1 | | 3
// : +-+
// : 2
func pointSide(b orb.Bound, p orb.Point) uint8 {
if p[1] == b.Max[1] {
return 4
Expand Down
10 changes: 5 additions & 5 deletions encoding/ewkb/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
// }
type GeometryScanner struct {
sridInPrefix bool
g interface{}
g any
SRID int
Geometry orb.Geometry
Valid bool // Valid is true if the geometry is not NULL
Expand Down Expand Up @@ -56,7 +56,7 @@ type GeometryScanner struct {
// } else {
// // NULL value
// }
func Scanner(g interface{}) *GeometryScanner {
func Scanner(g any) *GeometryScanner {
return &GeometryScanner{g: g}
}

Expand All @@ -75,20 +75,20 @@ func Scanner(g interface{}) *GeometryScanner {
// Scan(&srid, wkb.Scanner(&p))
//
// https://dev.mysql.com/doc/refman/5.7/en/gis-data-formats.html
func ScannerPrefixSRID(g interface{}) *GeometryScanner {
func ScannerPrefixSRID(g any) *GeometryScanner {
return &GeometryScanner{sridInPrefix: true, g: g}
}

// Scan will scan the input []byte data into a geometry.
// This could be into the orb geometry type pointer or, if nil,
// the scanner.Geometry attribute.
func (s *GeometryScanner) Scan(d interface{}) error {
func (s *GeometryScanner) Scan(d any) error {
s.Geometry = nil
s.Valid = false

var (
srid int
data interface{}
data any
)

data = d
Expand Down
18 changes: 9 additions & 9 deletions encoding/ewkb/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func TestScanPoint_errors(t *testing.T) {
// error conditions
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -496,7 +496,7 @@ func TestScanMultiPoint(t *testing.T) {
func TestScanMultiPoint_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -590,7 +590,7 @@ func TestScanLineString(t *testing.T) {
func TestScanLineString_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -684,7 +684,7 @@ func TestScanMultiLineString(t *testing.T) {
func TestScanMultiLineString_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -772,7 +772,7 @@ func TestScanRing(t *testing.T) {
func TestScanRing_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -866,7 +866,7 @@ func TestScanPolygon(t *testing.T) {
func TestScanPolygon_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -966,7 +966,7 @@ func TestScanMultiPolygon(t *testing.T) {
func TestScanMultiPolygon_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -1054,7 +1054,7 @@ func TestScanCollection(t *testing.T) {
func TestScanCollection_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -1148,7 +1148,7 @@ func TestScanBound(t *testing.T) {
func TestScanBound_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down
2 changes: 1 addition & 1 deletion encoding/internal/wkbcommon/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
// Scan will scan the input []byte data into a geometry.
// This could be into the orb geometry type pointer or, if nil,
// the scanner.Geometry attribute.
func Scan(g, d interface{}) (orb.Geometry, int, bool, error) {
func Scan(g, d any) (orb.Geometry, int, bool, error) {
if d == nil {
return nil, 0, false, nil
}
Expand Down
10 changes: 5 additions & 5 deletions encoding/mvt/geometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ type keyValueEncoder struct {
keyMap map[string]uint32

Values []*vectortile.Tile_Value
valueMap map[interface{}]uint32
valueMap map[any]uint32

keySortBuffer []string
}

func newKeyValueEncoder() *keyValueEncoder {
return &keyValueEncoder{
keyMap: make(map[string]uint32),
valueMap: make(map[interface{}]uint32),
valueMap: make(map[any]uint32),
}
}

Expand All @@ -161,7 +161,7 @@ func (kve *keyValueEncoder) Key(s string) uint32 {
return i
}

func (kve *keyValueEncoder) Value(v interface{}) (uint32, error) {
func (kve *keyValueEncoder) Value(v any) (uint32, error) {
// If a type is not comparable we can't figure out uniqueness in the hash,
// we also can't encode it into a vectortile.Tile_Value.
// So we encoded it as a json string, which is what other encoders
Expand Down Expand Up @@ -191,7 +191,7 @@ func (kve *keyValueEncoder) Value(v interface{}) (uint32, error) {
return i, nil
}

func encodeValue(v interface{}) (*vectortile.Tile_Value, error) {
func encodeValue(v any) (*vectortile.Tile_Value, error) {
tv := &vectortile.Tile_Value{}
switch t := v.(type) {
case string:
Expand Down Expand Up @@ -242,7 +242,7 @@ func encodeValue(v interface{}) (*vectortile.Tile_Value, error) {
return tv, nil
}

func decodeValue(v *vectortile.Tile_Value) interface{} {
func decodeValue(v *vectortile.Tile_Value) any {
if v == nil {
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions encoding/mvt/geometry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ func (s stringer) String() string {
func TestEncodeValue(t *testing.T) {
cases := []struct {
name string
input interface{}
output interface{}
input any
output any
}{
{
name: "string",
Expand Down Expand Up @@ -303,7 +303,7 @@ func TestEncodeValue(t *testing.T) {
}

// error if a weird type, but typical json decode result
input := map[string]interface{}{
input := map[string]any{
"a": 1,
"b": 2,
}
Expand Down
4 changes: 2 additions & 2 deletions encoding/mvt/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func addFeature(layer *vectortile.Tile_Layer, kve *keyValueEncoder, f *geojson.F
return addSingleGeometryFeature(layer, kve, f.Geometry, f.Properties, f.ID)
}

func addSingleGeometryFeature(layer *vectortile.Tile_Layer, kve *keyValueEncoder, g orb.Geometry, p geojson.Properties, id interface{}) error {
func addSingleGeometryFeature(layer *vectortile.Tile_Layer, kve *keyValueEncoder, g orb.Geometry, p geojson.Properties, id any) error {
geomType, encodedGeometry, err := encodeGeometry(g)
if err != nil {
return err
Expand Down Expand Up @@ -141,7 +141,7 @@ func encodeProperties(kve *keyValueEncoder, properties geojson.Properties) ([]ui
return tags, nil
}

func convertID(id interface{}) *uint64 {
func convertID(id any) *uint64 {
if id == nil {
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions encoding/mvt/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ func compareProperties(t testing.TB, result, expected geojson.Properties) {
t.Helper()

// properties
fr := map[string]interface{}(result)
fe := map[string]interface{}(expected)
fr := map[string]any(result)
fe := map[string]any(expected)

for k, v := range fe {
if _, ok := v.([]interface{}); ok {
if _, ok := v.([]any); ok {
// arrays are not included
delete(fr, k)
delete(fe, k)
Expand Down Expand Up @@ -414,7 +414,7 @@ func loadGeoJSON(t testing.TB, tile maptile.Tile) map[string]*geojson.FeatureCol
func TestMarshal_ID(t *testing.T) {
cases := []struct {
name string
id interface{}
id any
val float64
}{
{
Expand Down
4 changes: 2 additions & 2 deletions encoding/mvt/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func Unmarshal(data []byte) (Layers, error) {
// decoder is here to reuse objects to save allocations/memory.
type decoder struct {
keys []string
values []interface{}
values []any
features [][]byte

valMsg *protoscan.Message
Expand Down Expand Up @@ -429,7 +429,7 @@ func (gd *geomDecoder) done() bool {
return !gd.iter.HasNext()
}

func decodeValueMsg(msg *protoscan.Message) (interface{}, error) {
func decodeValueMsg(msg *protoscan.Message) (any, error) {
for msg.Next() {
switch msg.FieldNumber() {
case 1:
Expand Down
6 changes: 3 additions & 3 deletions encoding/wkb/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
// // NULL value
// }
type GeometryScanner struct {
g interface{}
g any
Geometry orb.Geometry
Valid bool // Valid is true if the geometry is not NULL
}
Expand Down Expand Up @@ -59,14 +59,14 @@ type GeometryScanner struct {
// first 4 bytes and try again. This works for most use cases.
//
// For supported behavior see `ewkb.ScannerPrefixSRID`
func Scanner(g interface{}) *GeometryScanner {
func Scanner(g any) *GeometryScanner {
return &GeometryScanner{g: g}
}

// Scan will scan the input []byte data into a geometry.
// This could be into the orb geometry type pointer or, if nil,
// the scanner.Geometry attribute.
func (s *GeometryScanner) Scan(d interface{}) error {
func (s *GeometryScanner) Scan(d any) error {
if d == nil {
return nil
}
Expand Down
18 changes: 9 additions & 9 deletions encoding/wkb/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func TestScanPoint_errors(t *testing.T) {
// error conditions
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -293,7 +293,7 @@ func TestScanMultiPoint(t *testing.T) {
func TestScanMultiPoint_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -385,7 +385,7 @@ func TestScanLineString(t *testing.T) {
func TestScanLineString_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -482,7 +482,7 @@ func TestScanMultiLineString(t *testing.T) {
func TestScanMultiLineString_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -564,7 +564,7 @@ func TestScanRing(t *testing.T) {
func TestScanRing_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -656,7 +656,7 @@ func TestScanPolygon(t *testing.T) {
func TestScanPolygon_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -753,7 +753,7 @@ func TestScanMultiPolygon(t *testing.T) {
func TestScanMultiPolygon_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -835,7 +835,7 @@ func TestScanCollection(t *testing.T) {
func TestScanCollection_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down Expand Up @@ -957,7 +957,7 @@ func TestScanBound(t *testing.T) {
func TestScanBound_errors(t *testing.T) {
cases := []struct {
name string
data interface{}
data any
err error
}{
{
Expand Down
2 changes: 1 addition & 1 deletion encoding/wkt/benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func BenchmarkUnmarshalMultiPolygon(b *testing.B) {
}
}

func loadJSON(tb testing.TB, filename string, obj interface{}) {
func loadJSON(tb testing.TB, filename string, obj any) {
data, err := os.ReadFile(filename)
if err != nil {
tb.Fatalf("failed to load mvt file: %v", err)
Expand Down
Loading
Loading