Select to view content in your preferred language

GeometryEngine.Project() Arguments

07-13-2017 12:01 AM
Occasional Contributor

What do you think about this API method?

public static Geometry GeometryEngine.Project(Geometry geometry, SpatialReference spatialReference)

In my opinion, this method is to generic and involves to many casts when it's used, e.g.

var mapPoint = new MapPoint(...)
var projectedPoint = (MapPoint)GeometryEngine.Project(mapPoint, anySpatialReference);

If we had a finite list of supported overloads, like:

public static MapPoint GeometryEngine.Project(MapPoint mapPoint, SpatialReference sr) {}
public static LineSegment GeometryEngine.Project(LineSegment lineSegment, SpatialReference sr) {}
public static Polygon GeometryEngine.Project(Polygon polygon, SpatialReference sr) {}

...use of the API would be easier and more clear.

What do you think about this?

0 Kudos
1 Reply
Esri Notable Contributor

Thank you for the feedback. However there is actually no guarantee that projecting a geometry of a certain type will return that same type. There are cases where a polygon can collapse to a line or a point, or a line to a point, and Envelopes will almost always return as Polygons.

Projecting points will however always return a point or null, so I could see an argument for adding a point-specific overload.

0 Kudos