public static void ClearLocations(INetworkCoverage networkCoverage, IBranch branch) { var locationsToRemove = networkCoverage.GetLocationsForBranch(branch); if (locationsToRemove.Count != 0) { networkCoverage.Locations.RemoveValues(networkCoverage.Locations.CreateValuesFilter(locationsToRemove)); } }
// Evaluate value at start and end of segment and interpolate the colors based on colors from theme. // The 4 dictinctive cases below should be properly handled by coverage.Evaluate //A 0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - constant // 0000012334566788877776665555444333322211110000000 //B 0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - linear // -10001233456678887777666555544433332221111000-1-1 //C 0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - none // ddd00123345667888777766655554443333222111100ddddd where d is default value for coverage //D0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - n.a. // 0011233455667888777766565555444433332222111110000 // no interpolation; only locations are visible // 0 8 0 // [ ][ ][ ] // interpolate - constant // 0000000008888888888888888888800000000000000000000 // 0 8 0 // [ ][ ][ ] // interpolate - constant // 0000000088888888888888888888888880000000000000000 private static bool RenderBranchSegments(IBranch branch, VectorLayer segmentsLayer, Graphics graphics, INetworkCoverage coverage, Dictionary <INetworkLocation, INetworkSegment> locationsToSegmentDictonary) { var knownBranchLocations = coverage.GetLocationsForBranch(branch); if (knownBranchLocations.Count == 0) //nothing to draw { return(false); } var theme = segmentsLayer.Theme; var defaultStyle = (theme != null) ? (VectorStyle)theme.GetStyle(coverage.DefaultValue) : segmentsLayer.Style; var first = true; var allBranchLocations = new List <INetworkLocation>(); var branchSegments = new List <INetworkSegment>(); foreach (var location in knownBranchLocations) { if (!locationsToSegmentDictonary.Keys.Contains(location)) { continue; } var segment = locationsToSegmentDictonary[location]; branchSegments.Add(segment); if (first) { allBranchLocations.Add(new NetworkLocation(segment.Branch, segment.Offset)); } allBranchLocations.Add(location); allBranchLocations.Add(new NetworkLocation(segment.Branch, segment.Offset + segment.Length)); first = false; } var allBranchLocationValues = coverage.EvaluateWithinBranch(allBranchLocations); for (var i = 0; i < branchSegments.Count; i++) { var firstSegment = (i == 0); var lastSegment = (i == branchSegments.Count - 1); var segment = branchSegments[i]; var offset = knownBranchLocations[i].Offset; DrawSegment(segmentsLayer, coverage, theme, i, allBranchLocationValues, firstSegment, lastSegment, graphics, segment, defaultStyle, offset); } return(true); }
// Evaluate value at start and end of segment and interpolate the colors based on colors from theme. // The 4 dictinctive cases below should be properly handled by coverage.Evaluate //A 0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - constant // 0000012334566788877776665555444333322211110000000 //B 0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - linear // -10001233456678887777666555544433332221111000-1-1 //C 0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - none // ddd00123345667888777766655554443333222111100ddddd where d is default value for coverage //D0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - n.a. // 0011233455667888777766565555444433332222111110000 // no interpolation; only locations are visible // 0 8 0 // [ ][ ][ ] // interpolate - constant // 0000000008888888888888888888800000000000000000000 // 0 8 0 // [ ][ ][ ] // interpolate - constant // 0000000088888888888888888888888880000000000000000 private static void RenderBranchSegments(IBranch branch, VectorLayer segmentsLayer, Graphics graphics, INetworkCoverage coverage, Dictionary<INetworkLocation, INetworkSegment> locationsToSegmentDictonary) { var knownBranchLocations = coverage.GetLocationsForBranch(branch); var theme = segmentsLayer.Theme; var defaultStyle = (theme != null) ? (VectorStyle)theme.GetStyle(coverage.DefaultValue) : segmentsLayer.Style; var first = true; var allBranchLocations = new List<double>(); var branchSegments = new List<INetworkSegment>(); foreach (var location in knownBranchLocations) { if (!locationsToSegmentDictonary.Keys.Contains(location)) { continue; } var segment = locationsToSegmentDictonary[location]; branchSegments.Add(segment); if (first) { allBranchLocations.Add(segment.Chainage); } allBranchLocations.Add(location.Chainage); allBranchLocations.Add(segment.Chainage + segment.Length); first = false; } if (allBranchLocations.Any()) { var allBranchLocationValues = coverage.EvaluateWithinBranch(branch, allBranchLocations.OrderBy(o => o), knownBranchLocations); for (var i = 0; i < branchSegments.Count; i++) { var firstSegment = (i == 0); var lastSegment = (i == branchSegments.Count - 1); var segment = branchSegments[i]; var offset = knownBranchLocations[i].Chainage; DrawSegment(segmentsLayer, coverage, theme, i, allBranchLocationValues, firstSegment, lastSegment, graphics, segment, defaultStyle, offset); } } else { // When no locations, we still render because there // might be interpolation across nodes (ordered branches), // otherwise it will be rendered at the default coverage value. var values = new List<double>() { coverage.Evaluate(new NetworkLocation(branch, 0)), coverage.Evaluate(new NetworkLocation(branch, branch.Length/2)), coverage.Evaluate(new NetworkLocation(branch, branch.Length)) }; var segment = new NetworkSegment() { Branch = branch, Chainage = 0.0, Length = branch.Length, Geometry = branch.Geometry }; DrawSegment(segmentsLayer, coverage, theme, 0, values, true, true, graphics, segment, defaultStyle, branch.Length / 2); } }
// Evaluate value at start and end of segment and interpolate the colors based on colors from theme. // The 4 dictinctive cases below should be properly handled by coverage.Evaluate //A 0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - constant // 0000012334566788877776665555444333322211110000000 //B 0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - linear // -10001233456678887777666555544433332221111000-1-1 //C 0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - none // ddd00123345667888777766655554443333222111100ddddd where d is default value for coverage //D0 8 0 // [ ][ ][ ] // interpolate - linear // extrapolate - n.a. // 0011233455667888777766565555444433332222111110000 // no interpolation; only locations are visible // 0 8 0 // [ ][ ][ ] // interpolate - constant // 0000000008888888888888888888800000000000000000000 // 0 8 0 // [ ][ ][ ] // interpolate - constant // 0000000088888888888888888888888880000000000000000 private static void RenderBranchSegments(IBranch branch, VectorLayer segmentsLayer, Graphics graphics, INetworkCoverage coverage, Dictionary <INetworkLocation, INetworkSegment> locationsToSegmentDictonary) { var knownBranchLocations = coverage.GetLocationsForBranch(branch); var theme = segmentsLayer.Theme; var defaultStyle = (theme != null) ? (VectorStyle)theme.GetStyle(coverage.DefaultValue) : segmentsLayer.Style; var first = true; var allBranchLocations = new List <double>(); var branchSegments = new List <INetworkSegment>(); foreach (var location in knownBranchLocations) { if (!locationsToSegmentDictonary.Keys.Contains(location)) { continue; } var segment = locationsToSegmentDictonary[location]; branchSegments.Add(segment); if (first) { allBranchLocations.Add(segment.Chainage); } allBranchLocations.Add(location.Chainage); allBranchLocations.Add(segment.Chainage + segment.Length); first = false; } if (allBranchLocations.Any()) { var allBranchLocationValues = coverage.EvaluateWithinBranch(branch, allBranchLocations.OrderBy(o => o), knownBranchLocations); for (var i = 0; i < branchSegments.Count; i++) { var firstSegment = (i == 0); var lastSegment = (i == branchSegments.Count - 1); var segment = branchSegments[i]; var offset = knownBranchLocations[i].Chainage; DrawSegment(segmentsLayer, coverage, theme, i, allBranchLocationValues, firstSegment, lastSegment, graphics, segment, defaultStyle, offset); } } else { // When no locations, we still render because there // might be interpolation across nodes (ordered branches), // otherwise it will be rendered at the default coverage value. var values = new List <double>() { coverage.Evaluate(new NetworkLocation(branch, 0)), coverage.Evaluate(new NetworkLocation(branch, branch.Length / 2)), coverage.Evaluate(new NetworkLocation(branch, branch.Length)) }; var segment = new NetworkSegment() { Branch = branch, Chainage = 0.0, Length = branch.Length, Geometry = branch.Geometry }; DrawSegment(segmentsLayer, coverage, theme, 0, values, true, true, graphics, segment, defaultStyle, branch.Length / 2); } }