Select to view content in your preferred language

What happened to the geometryType enum in 200.0?

589
1
Jump to solution
04-05-2023 12:13 PM
GBreen
by
Occasional Contributor

In 100.0 you could decide the type of a geometry via a GeometryType enum, but that doesn't seem to exist in 200.0.

0 Kudos
1 Solution

Accepted Solutions
Ting
by Esri Contributor
Esri Contributor

Hope you don't mind, I moved this question to the new Swift Maps SDK Questions forum.

In 200.x we get rid of the previous geometryType property of a geometry, and rely on the metatype of a type, to better follow Swift conventions. Metatypes are used extensively throughout the standard library.

Below is the comparison between the old and new way.

 

// 100.x
switch geometryType {
case .point: return "Point"
case .polyline: return "Polyline"
case .polygon: return "Polygon"
default:
    return nil
}

// 200.x
switch geometry {
case is Point: return "Point"
case is Polyline: return "Polyline"
case is ArcGIS.Polygon: return "Polygon"
default:
    return nil
}

// or sth like…
let geometryType: Geometry.Type = ...
switch geometryType {
case is Point.Type:
    print("Point!")
default:
    print("Not Point.")
}

 

View solution in original post

1 Reply
Ting
by Esri Contributor
Esri Contributor

Hope you don't mind, I moved this question to the new Swift Maps SDK Questions forum.

In 200.x we get rid of the previous geometryType property of a geometry, and rely on the metatype of a type, to better follow Swift conventions. Metatypes are used extensively throughout the standard library.

Below is the comparison between the old and new way.

 

// 100.x
switch geometryType {
case .point: return "Point"
case .polyline: return "Polyline"
case .polygon: return "Polygon"
default:
    return nil
}

// 200.x
switch geometry {
case is Point: return "Point"
case is Polyline: return "Polyline"
case is ArcGIS.Polygon: return "Polygon"
default:
    return nil
}

// or sth like…
let geometryType: Geometry.Type = ...
switch geometryType {
case is Point.Type:
    print("Point!")
default:
    print("Not Point.")
}