public void GetCentroidForCoordinates_ShouldReturnCentroidForLineString_WhenCoordinatesAreLineString() { // Arrange var jsonData = GetGeoJson(); var featureCollection = FeatureCollectionLoader.LoadFeatureCollectionFromGeoJsonString(jsonData); var coordinates = FeatureCollectionHelper.GetPointCoordinatesFromFeatureCollection(featureCollection).ToArray(); var expectedCentroidLineString = new Coordinate(12.480333076209453, 41.904384802740324); const double tolerance = 0.00001; // Act var resultCentroid = CentroidHelper.GetCentroidForCoordinates(coordinates); // Assert _output.WriteLine($"centroid for line string: {resultCentroid}"); Assert.True(expectedCentroidLineString.Equals2D(resultCentroid.Coordinate, tolerance)); }
public void GetCentroidForCoordinates_ShouldReturnCentroidForPolygon_WhenForcePolygonIsTrue() { // Arrange var jsonData = GetGeoJson(); var featureCollection = FeatureCollectionLoader.LoadFeatureCollectionFromGeoJsonString(jsonData); var coordinates = FeatureCollectionHelper.GetPointCoordinatesFromFeatureCollection(featureCollection).ToArray(); var expectedCentroidForPolygon = new Coordinate(12.495307072902103, 41.914354766677732); const double tolerance = 0.00001; const bool forcePolygon = true; // Act var resultCentroid = CentroidHelper.GetCentroidForCoordinates(coordinates, forcePolygon); // Assert _output.WriteLine($"centroid for polygon: {resultCentroid}"); Assert.True(expectedCentroidForPolygon.Equals2D(resultCentroid.Coordinate, tolerance)); }