public void ValidateGeometry_WhenValidPolygon_ThenValidResult() { SqlGeometry polygon = SqlGeometry.Parse("POLYGON((1 1, 4 1, 4 4, 1 4, 1 1))"); GeometryTools geometryTools = new GeometryTools(); GeometryValidationResult result = geometryTools.ValidateGeometry(polygon); Assert.IsTrue(result.IsValid); Assert.AreEqual(24400, result.StatusCode); Assert.AreEqual(GeometryValidationStatusId.Valid, result.GeometryValidationStatusId); Assert.AreEqual("Valid", result.Description); }
public void ValidateGeometry_WhenInvalidPolygon_ThenInvalidResult() { SqlGeometry polygon = SqlGeometry.Parse("POLYGON((1 1, 4 1, 1 4, 4 4, 1 1))"); GeometryTools geometryTools = new GeometryTools(); GeometryValidationResult result = geometryTools.ValidateGeometry(polygon); Assert.IsFalse(result.IsValid); Assert.AreEqual(24404, result.StatusCode); Assert.AreEqual(GeometryValidationStatusId.NotValidBecausePolygonRingIntersectsItself, result.GeometryValidationStatusId); Assert.AreEqual("Not valid because polygon ring (1) intersects itself or some other ring.", result.Description); }
public void ValidateGeometry_WhenConvertedInvalidPolygon_ThenInvalidResult() { Polygon pol = GetInvalidPolygon(); GeometryConversionTool geometryConversionTool = new GeometryConversionTool(); SqlGeometry polygon = geometryConversionTool.PolygonToSqlGeometry(pol); GeometryTools geometryTools = new GeometryTools(); GeometryValidationResult result = geometryTools.ValidateGeometry(polygon); Assert.IsFalse(result.IsValid); Assert.AreEqual(24404, result.StatusCode); Assert.AreEqual(GeometryValidationStatusId.NotValidBecausePolygonRingIntersectsItself, result.GeometryValidationStatusId); Assert.AreEqual("Not valid because polygon ring (1) intersects itself or some other ring.", result.Description); }
public void ValidateFeatureGeometry_WhenValidFeatureGeometry_ThenValidResult() { //Arrange const string strFeature = "{ \"type\": \"Feature\", \"id\":\"myFeature\", \"bbox\": [-170.0, -70.0, 160.0, 85.0], \"geometry\": {\"type\": \"Polygon\",\"coordinates\": [[[-180.0, 10.0], [20.0, 90.0], [180.0, -5.0], [-30.0, -90.0],[-180.0, 10.0]]]}}"; Feature feature = JsonConvert.DeserializeObject <Feature>(strFeature); GeometryTools geometryTools = new GeometryTools(); //Act GeometryValidationResult result = geometryTools.ValidateFeatureGeometry(feature); //Assert Assert.IsTrue(result.IsValid); Assert.AreEqual(24400, result.StatusCode); Assert.AreEqual(GeometryValidationStatusId.Valid, result.GeometryValidationStatusId); Assert.AreEqual("Valid", result.Description); }
public void ValidateFeatureGeometry_WhenPolygonIntersectsItself_ThenInvalidResult() { //Arrange const string strFeature = "{ \"type\": \"Feature\", \"id\":\"myFeature\", \"geometry\": {\"type\": \"Polygon\",\"coordinates\": [[[1, 1], [4, 1], [1, 4], [4, 4], [1, 1]]]}}"; Feature feature = JsonConvert.DeserializeObject <Feature>(strFeature); GeometryTools geometryTools = new GeometryTools(); //Act GeometryValidationResult result = geometryTools.ValidateFeatureGeometry(feature); //Assert Assert.IsFalse(result.IsValid); Assert.AreEqual(24404, result.StatusCode); Assert.AreEqual(GeometryValidationStatusId.NotValidBecausePolygonRingIntersectsItself, result.GeometryValidationStatusId); Assert.AreEqual("Not valid because polygon ring (1) intersects itself or some other ring.", result.Description); }