/// <summary> /// Convert Vector3 World Space location to Position taking account of zoom, scale and mapscale /// </summary> /// <param name="position">Vector3 World Space coordinates</param> /// <returns>Position</returns> static public IPosition ToPosition(this Vector3 position, ICRSObject crs = null) { Geometry geom = position.ToGeometry(); SpatialReference sr = new SpatialReference(null); if (crs == null) { sr.SetWellKnownGeogCS("EPSG:4326"); } else { switch (crs.Type) { case CRSType.Name: string name = (crs as NamedCRS).Properties["name"] as string; sr.SetProjCS(name); break; case CRSType.Link: string url = (crs as LinkedCRS).Properties["href"] as string; sr.ImportFromUrl(url); break; case CRSType.Unspecified: sr.SetWellKnownGeogCS("EPSG:4326"); break; } } geom.TransformTo(sr); double[] argout = new double[3]; geom.GetPoint(0, argout); return(new Position(argout[0], argout[1], argout[2])); }