diff --git a/go/libraries/doltcore/schema/typeinfo/geometry.go b/go/libraries/doltcore/schema/typeinfo/geometry.go index 5d488a5a19..c6a9decd96 100644 --- a/go/libraries/doltcore/schema/typeinfo/geometry.go +++ b/go/libraries/doltcore/schema/typeinfo/geometry.go @@ -55,6 +55,8 @@ func (ti *geometryType) ConvertNomsValueToValue(v types.Value) (interface{}, err return types.ConvertTypesMultiPointToSQLMultiPoint(val), nil case types.MultiLineString: return types.ConvertTypesMultiLineStringToSQLMultiLineString(val), nil + case types.MultiPolygon: + return types.ConvertTypesMultiPolygonToSQLMultiPolygon(val), nil default: return nil, fmt.Errorf(`"%v" cannot convert NomsKind "%v" to a value`, ti.String(), v.Kind()) } @@ -87,6 +89,10 @@ func (ti *geometryType) ReadFrom(nbf *types.NomsBinFormat, reader types.CodecRea if val, err = reader.ReadMultiLineString(); err != nil { return nil, err } + case types.MultiPolygonKind: + if val, err = reader.ReadMultiPolygon(); err != nil { + return nil, err + } case types.GeometryKind: // Note: GeometryKind is no longer written // included here for backward compatibility @@ -148,6 +154,8 @@ func (ti *geometryType) FormatValue(v types.Value) (*string, error) { return MultiPointType.FormatValue(val) case types.MultiLineString: return MultiLineStringType.FormatValue(val) + case types.MultiPolygon: + return MultiPolygonType.FormatValue(val) case types.Geometry: switch inner := val.Inner.(type) { case types.Point: @@ -160,6 +168,8 @@ func (ti *geometryType) FormatValue(v types.Value) (*string, error) { return MultiPointType.FormatValue(inner) case types.MultiLineString: return MultiLineStringType.FormatValue(inner) + case types.MultiPolygon: + return MultiPolygonType.FormatValue(val) default: return nil, fmt.Errorf(`"%v" has unexpectedly encountered a value of type "%T" from embedded type`, ti.String(), v.Kind()) } @@ -189,7 +199,10 @@ func (ti *geometryType) IsValid(v types.Value) bool { case types.Geometry, types.Point, types.LineString, - types.Polygon: + types.Polygon, + types.MultiPoint, + types.MultiLineString, + types.MultiPolygon: return true default: return false diff --git a/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go b/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go index 0091f0438f..c777a82746 100644 --- a/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go +++ b/go/libraries/doltcore/schema/typeinfo/typeinfo_test.go @@ -359,6 +359,7 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) { {PolygonType}, {MultiPointType}, {MultiLineStringType}, + {MultiPolygonType}, {GeometryType}, generateSetTypes(t, 16), {TimeType}, @@ -394,9 +395,10 @@ func generateTypeInfoArrays(t *testing.T) ([][]TypeInfo, [][]types.Value) { json.MustTypesJSON(`false`), json.MustTypesJSON(`{"a": 1, "b": []}`)}, //JSON {types.LineString{SRID: 0, Points: []types.Point{{SRID: 0, X: 1, Y: 2}, {SRID: 0, X: 3, Y: 4}}}}, // LineString {types.Point{SRID: 0, X: 1, Y: 2}}, // Point - {types.Polygon{SRID: 0, Lines: []types.LineString{{SRID: 0, Points: []types.Point{{SRID: 0, X: 0, Y: 0}, {SRID: 0, X: 0, Y: 1}, {SRID: 0, X: 1, Y: 1}, {SRID: 0, X: 0, Y: 0}}}}}}, // Polygon - {types.MultiPoint{SRID: 0, Points: []types.Point{{SRID: 0, X: 1, Y: 2}, {SRID: 0, X: 3, Y: 4}}}}, // MultiPoint - {types.MultiLineString{SRID: 0, Lines: []types.LineString{{SRID: 0, Points: []types.Point{{SRID: 0, X: 0, Y: 0}, {SRID: 0, X: 0, Y: 1}, {SRID: 0, X: 1, Y: 1}, {SRID: 0, X: 0, Y: 0}}}}}}, // Polygon + {types.Polygon{SRID: 0, Lines: []types.LineString{{SRID: 0, Points: []types.Point{{SRID: 0, X: 0, Y: 0}, {SRID: 0, X: 0, Y: 1}, {SRID: 0, X: 1, Y: 1}, {SRID: 0, X: 0, Y: 0}}}}}}, // Polygon + {types.MultiPoint{SRID: 0, Points: []types.Point{{SRID: 0, X: 1, Y: 2}, {SRID: 0, X: 3, Y: 4}}}}, // MultiPoint + {types.MultiLineString{SRID: 0, Lines: []types.LineString{{SRID: 0, Points: []types.Point{{SRID: 0, X: 0, Y: 0}, {SRID: 0, X: 0, Y: 1}, {SRID: 0, X: 1, Y: 1}, {SRID: 0, X: 0, Y: 0}}}}}}, // MultiLineString + {types.MultiPolygon{SRID: 0, Polygons: []types.Polygon{{SRID: 0, Lines: []types.LineString{{SRID: 0, Points: []types.Point{{SRID: 0, X: 0, Y: 0}, {SRID: 0, X: 0, Y: 1}, {SRID: 0, X: 1, Y: 1}, {SRID: 0, X: 0, Y: 0}}}}}}}}, // MultiPolygon {types.Geometry{Inner: types.Point{SRID: 0, X: 1, Y: 2}}}, // Geometry holding a Point {types.Uint(1), types.Uint(5), types.Uint(64), types.Uint(42), types.Uint(192)}, //Set {types.Int(0), types.Int(1000000 /*"00:00:01"*/), types.Int(113000000 /*"00:01:53"*/), types.Int(247019000000 /*"68:36:59"*/), types.Int(458830485214 /*"127:27:10.485214"*/)}, //Time