public GeoJson ConvertToGeoJson(bool convertLineStringCoordsToPolygon, int maxVerticesToApproximateTo) { if (LineworkBoundaries == null) { return(null); } var geoJson = new GeoJson { Type = GeoJson.FeatureType.FEATURE_COLLECTION, Features = new List <Feature>() }; foreach (var boundary in LineworkBoundaries) { var fencePoints = DouglasPeucker.DouglasPeuckerByCount( boundary.Boundary.Select(p => new WGSPoint(latitude: p.Lat, longtitude: p.Lon)).ToArray(), maxVerticesToApproximateTo); geoJson.Features.Add(new Feature { Type = GeoJson.FeatureType.FEATURE, Properties = new Properties { Name = boundary.BoundaryName }, Geometry = GetCoordinatesFromFencePoints(fencePoints, convertLineStringCoordsToPolygon) }); } return(geoJson); }
public IActionResult PolylineReducePoints([FromBody] SmoothPolylineRequest requestDto) { Log.LogDebug($"{nameof(PolylineReducePoints)}: {requestDto}"); if (requestDto.MaxPoints > SmoothPolylineRequest.NOT_DEFINED && requestDto.MaxPoints < 3) { return(StatusCode((int)HttpStatusCode.BadRequest, new { Message = "Cannot reduce polyline to fewer than 3 points." })); } var fencePoints = DouglasPeucker.DouglasPeuckerByCount(requestDto.Coordinates, requestDto.MaxPoints); return(StatusCode((int)HttpStatusCode.OK, new { coordinates = fencePoints })); }