-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinearInaccuracy.cs
More file actions
64 lines (57 loc) · 2.51 KB
/
LinearInaccuracy.cs
File metadata and controls
64 lines (57 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
namespace InaccuracyCalculator
{
/// <summary>
/// Список расчитанных погрешностей линейных измерений (используются Рекомендации по технической инвентаризации и регистрации зданий гражданского назначения" (приняты Росжилкоммунсоюзом 01.01.1991)
/// </summary>
public class LinearInaccuracy
{
private readonly List<LinearInaccuracyItem> _items;
/// <summary>
/// Инициализация списка
/// </summary>
public LinearInaccuracy()
{
_items = new List<LinearInaccuracyItem>
{
new LinearInaccuracyItem(0, 0.99, 0.01),
new LinearInaccuracyItem(1, 5.99, 0.03),
new LinearInaccuracyItem(6, 11.99, 0.05),
new LinearInaccuracyItem(12, 23.99, 0.08),
new LinearInaccuracyItem(24, 99.99, 0.3)
};
}
/// <summary>
/// Величиная погрешности линеных измерений в зависимости от максимальной длины фигуры
/// </summary>
/// <param name="MaxLinearLenght">Максимальная сторона фигуры</param>
/// <returns></returns>
public double GetLinearInaccuracy(double MaxLinearLenght)
{
IEnumerable<LinearInaccuracyItem> _properItems = _items.Where((x) => x.Max >= MaxLinearLenght && x.Min <= MaxLinearLenght);
if (_properItems.Count() < 1)
{
throw new Exception($"Для такого расстояная {MaxLinearLenght} нет подходящих погрешностей");
}
return _properItems.First().Inaccuracy;
}
private class LinearInaccuracyItem
{
/// <summary>
/// Запись из таблицы росчегото-там
/// </summary>
/// <param name="min"></param>
/// <param name="max"></param>
/// <param name="inaccuracy"></param>
public LinearInaccuracyItem(double min, double max, double inaccuracy)
{
Min = min;
Max = max;
Inaccuracy = inaccuracy;
}
public double Min, Max, Inaccuracy;
}
}
}