/// <summary> /// Build a GeoJson Point from latitude and longitude. /// </summary> /// <returns>GeoJson Point</returns> public static DurMap.Site.Models.GeoJson.Point GeoJsonPointFromLocation(double latitude, double longitude) { var point = new DurMap.Site.Models.GeoJson.Point() { coordinates = new double[2] }; //we can safely round the lat/long to 5 decimal places as thats 1.11m at equator, reduces data transfered to client point.coordinates[0] = Math.Round(longitude, 5); point.coordinates[1] = Math.Round(latitude, 5); return(point); }
/// <summary> /// Build an SqlGeography Point from a GeoJson Point. /// </summary> /// <param name="point">GeoJson Point</param> /// <returns>SqlGeography Point</returns> public static SqlGeography GeographyFromGeoJsonPoint(DurMap.Site.Models.GeoJson.Point point) { var geob = new SqlGeographyBuilder(); geob.SetSrid(SRID); geob.BeginGeography(OpenGisGeographyType.Point); geob.BeginFigure(point.coordinates[1], point.coordinates[0]); geob.EndFigure(); geob.EndGeography(); var geog = geob.ConstructedGeography; //Trace.WriteLine(geog.AsGml().Value); return(geog); }