public void ToSqlGeographyValidMultiPolygonTest() { SqlGeography sqlMultiPolygon = multiPolygon.ToSqlGeography(); Assert.IsNotNull(multiPolygon); Assert.IsNotNull(sqlMultiPolygon); Assert.AreEqual(sqlMultiPolygon.STGeometryType().Value, OpenGisGeometryType.MultiPolygon.ToString()); Assert.AreEqual(sqlMultiPolygon.STNumGeometries().Value, multiPolygon.Coordinates.Count); Assert.AreEqual(sqlMultiPolygon.STNumPoints().Value, multiPolygon.Coordinates.SelectMany(p => p.Coordinates).SelectMany(ls => ls.Coordinates).Count()); }
public static SqlGeography FromGeoJsonToSqlGeography(this MultiPolygon multiPolygon) { SqlGeography sqlGeography = multiPolygon.ToSqlGeography(); if (sqlGeography.STIsValid() == SqlBoolean.False) { //ErrorSignal.FromCurrentContext().Raise(new InvalidMultipolygonDefinitionException()); SqlGeography validSqlGeography = sqlGeography.MakeValid(); return(validSqlGeography); } return(sqlGeography); }