clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

feat/atlas-next-horizon
atlas / internal / app / vnext_geometry_kind_test.go
vnext_geometry_kind_test.go 2.1K
1package app23import (4 "testing"56 "github.com/FelineStateMachine/atlas/format/semconv"7 "github.com/FelineStateMachine/atlas/format/vnext"8)910func TestFeatureSetGeometryKindUsesStableClaim(t *testing.T) {11 t.Parallel()1213 tests := []struct {14 name string15 claim string16 semanticType string17 geometry vnext.GeometryKind18 }{19 {name: "point", claim: semconv.GeometryPoint, semanticType: "transport.station", geometry: vnext.GeometryPolygon},20 {name: "path", claim: semconv.GeometryPath, semanticType: "place.landmark", geometry: vnext.GeometryPoint},21 {name: "area", claim: semconv.GeometryArea, semanticType: "network.route", geometry: vnext.GeometryLineString},22 }23 for _, test := range tests {24 test := test25 t.Run(test.name, func(t *testing.T) {26 t.Parallel()2728 set := vnext.FeatureSet{29 SemanticType: test.semanticType,30 Claims: []vnext.Property{{31 Field: vnext.Field{32 Name: semconv.KeyGeometryKind,33 Kind: vnext.KindString,34 },35 Value: vnext.StringValue(test.claim),36 }},37 Features: []vnext.Feature{{Geometry: vnext.Geometry{Kind: test.geometry}}},38 }3940 if got := featureSetGeometryKind(set); got != test.claim {41 t.Fatalf("feature set geometry kind = %q, want stable claim %q", got, test.claim)42 }43 })44 }45}4647func TestFeatureSetGeometryKindSniffsGeometryWithoutClaim(t *testing.T) {48 t.Parallel()4950 tests := []struct {51 name string52 geometry vnext.GeometryKind53 want string54 }{55 {name: "point", geometry: vnext.GeometryPoint, want: semconv.GeometryPoint},56 {name: "path", geometry: vnext.GeometryLineString, want: semconv.GeometryPath},57 {name: "area", geometry: vnext.GeometryPolygon, want: semconv.GeometryArea},58 }59 for _, test := range tests {60 test := test61 t.Run(test.name, func(t *testing.T) {62 t.Parallel()6364 set := vnext.FeatureSet{65 SemanticType: "geometry.unrelated",66 Features: []vnext.Feature{{Geometry: vnext.Geometry{Kind: test.geometry}}},67 }68 if got := featureSetGeometryKind(set); got != test.want {69 t.Fatalf("feature set geometry kind = %q, want sniffed %q", got, test.want)70 }71 })72 }73}