private static Models.GeoJson.Point GeoJsonPointFromGeometry(SqlGeometry Geometry, int numDigitsMantissa) { Debug.Assert(Geometry.STGeometryType().ToString() == OpenGisGeometryType.Point.ToString()); var point = new Models.GeoJson.Point(0, 0); //we can safely round the lat/long to 5 decimal places as thats 1.11m at equator, reduces data transfered to client point.coordinates = reduceCoords(Geometry.STX.Value, Geometry.STY.Value, numDigitsMantissa); //point.coordinates[0] = Math.Round((double)Geometry.Long, numDigitsMantissa); //point.coordinates[1] = Math.Round((double)Geometry.Lat, numDigitsMantissa); 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(Models.GeoJson.Point point, int SRID) { var geob = new SqlGeographyBuilder(); geob.SetSrid(SRID); geob.BeginGeography(OpenGisGeographyType.Point); geob.BeginFigure(point.coordinates[0], point.coordinates[1]); geob.EndFigure(); geob.EndGeography(); var geog = geob.ConstructedGeography; return(geog); }