diff --git a/AsbCloudApp/Data/TrajectoryDto.cs b/AsbCloudApp/Data/TrajectoryDto.cs
new file mode 100644
index 00000000..80c965f4
--- /dev/null
+++ b/AsbCloudApp/Data/TrajectoryDto.cs
@@ -0,0 +1,13 @@
+namespace AsbCloudApp.Data
+{
+ ///
+ /// Формирование визуализации траектории 3D
+ ///
+ /// Глубина ствола
+ /// Зенитный угол
+ /// Азимут географиеский
+ public record TrajectoryDto(
+ double WellboreDepth,
+ double ZenithAngle,
+ double AzimuthGeo);
+}
diff --git a/AsbCloudApp/Repositories/IFactualTrajectoryRepository.cs b/AsbCloudApp/Repositories/IFactualTrajectoryRepository.cs
index 692c53dd..536419ed 100644
--- a/AsbCloudApp/Repositories/IFactualTrajectoryRepository.cs
+++ b/AsbCloudApp/Repositories/IFactualTrajectoryRepository.cs
@@ -10,7 +10,7 @@ namespace AsbCloudApp.Repositories
/// CRUD для работы с фактической траекторией из клиента
///
///
- public interface IFactualTrajectoryRepository
+ public interface IFactualTrajectoryRepository : ITrajectoryRepository
{
///
/// Получить все добавленные по скважине координаты фактической траектории
diff --git a/AsbCloudApp/Repositories/IPlannedTrajectoryRepository.cs b/AsbCloudApp/Repositories/IPlannedTrajectoryRepository.cs
index 94f19162..85362f9f 100644
--- a/AsbCloudApp/Repositories/IPlannedTrajectoryRepository.cs
+++ b/AsbCloudApp/Repositories/IPlannedTrajectoryRepository.cs
@@ -9,7 +9,7 @@ namespace AsbCloudApp.Repositories
/// CRUD для работы с плановой траекторией из клиента
///
///
- public interface IPlannedTrajectoryRepository
+ public interface IPlannedTrajectoryRepository : ITrajectoryRepository
{
///
/// Получить все добавленные по скважине координаты плановой траектории
diff --git a/AsbCloudApp/Repositories/ITrajectoryRepository.cs b/AsbCloudApp/Repositories/ITrajectoryRepository.cs
new file mode 100644
index 00000000..ad4ee0f4
--- /dev/null
+++ b/AsbCloudApp/Repositories/ITrajectoryRepository.cs
@@ -0,0 +1,24 @@
+using AsbCloudApp.Data;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace AsbCloudApp.Repositories
+{
+ ///
+ /// Репозиторий по работе с траекторией
+ ///
+ public interface ITrajectoryRepository
+ {
+ ///
+ /// Получение траектории для 3D-визуализации
+ ///
+ /// ключ скважины
+ ///
+ ///
+ Task GetTrajectoryAsync(int idWell, CancellationToken token);
+ }
+}
diff --git a/AsbCloudInfrastructure/Repository/FactualTrajectoryRepository.cs b/AsbCloudInfrastructure/Repository/FactualTrajectoryRepository.cs
index d140775d..67126227 100644
--- a/AsbCloudInfrastructure/Repository/FactualTrajectoryRepository.cs
+++ b/AsbCloudInfrastructure/Repository/FactualTrajectoryRepository.cs
@@ -1,8 +1,10 @@
-using AsbCloudApp.Data.WITS;
+using AsbCloudApp.Data;
+using AsbCloudApp.Data.WITS;
using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
+using Mapster;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
@@ -34,14 +36,16 @@ namespace AsbCloudInfrastructure.Repository
.OrderBy(e => e.Deptsvym)
.ToListAsync(token);
var result = entities
- .Select(r => new Record7Dto()
- {
- IdTelemetry = r.IdTelemetry,
- Deptsvym = r.Deptsvym,
- Svyinc = r.Svyinc,
- Svyazc = r.Svyazc
- });
+ .Select(r => r.Adapt());
return result;
}
+
+ public async Task GetTrajectoryAsync(int idWell, CancellationToken token)
+ {
+ return (await GetAsync(idWell, token))
+ .Where(coord => coord.Deptsvym != null && coord.Svyinc != null && coord.Svyazc != null)
+ .Select(coord => new TrajectoryDto(coord.Deptsvym!.Value, coord.Svyinc!.Value, coord.Svyazc!.Value))
+ .ToArray();
+ }
}
}
diff --git a/AsbCloudInfrastructure/Repository/PlannedTrajectoryRepository.cs b/AsbCloudInfrastructure/Repository/PlannedTrajectoryRepository.cs
index 0db7022d..9b4873f0 100644
--- a/AsbCloudInfrastructure/Repository/PlannedTrajectoryRepository.cs
+++ b/AsbCloudInfrastructure/Repository/PlannedTrajectoryRepository.cs
@@ -115,6 +115,13 @@ namespace AsbCloudInfrastructure.Repository
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
return entity;
}
+
+ public async Task GetTrajectoryAsync(int idWell, CancellationToken token)
+ {
+ return (await GetAsync(idWell, token))
+ .Select(coord => new TrajectoryDto(coord.WellboreDepth, coord.ZenithAngle, coord.AzimuthGeo))
+ .ToArray();
+ }
}
}
diff --git a/AsbCloudInfrastructure/Services/Trajectory/TrajectoryVisualizationService.cs b/AsbCloudInfrastructure/Services/Trajectory/TrajectoryVisualizationService.cs
index 1ef563f9..cc1557bc 100644
--- a/AsbCloudInfrastructure/Services/Trajectory/TrajectoryVisualizationService.cs
+++ b/AsbCloudInfrastructure/Services/Trajectory/TrajectoryVisualizationService.cs
@@ -33,12 +33,8 @@ namespace AsbCloudInfrastructure.Services.Trajectory
{
var result = new PlanFactBase>();
- var geoPlanCoordinates = (await plannedRepository.GetAsync(idWell, token))
- .Select(coord => new TrajectoryDto(coord.WellboreDepth, coord.ZenithAngle, coord.AzimuthGeo))
- .ToArray();
- var geoFactCoordinates = (await factualRepository.GetAsync(idWell, token))
- .Select(coord => new TrajectoryDto(coord.Deptsvym, coord.Svyinc, coord.Svyazc))
- .ToArray();
+ var geoPlanCoordinates = await plannedRepository.GetTrajectoryAsync(idWell, token);
+ var geoFactCoordinates = await factualRepository.GetTrajectoryAsync(idWell, token);
result.Plan = GetTrajectoryVisualisation(geoPlanCoordinates);
result.Fact = GetTrajectoryVisualisation(geoFactCoordinates);
@@ -61,56 +57,25 @@ namespace AsbCloudInfrastructure.Services.Trajectory
{
var intervalGeoParams = geoCoordinates[i - 1];
var deltaWellLength = geoCoordinates[i].WellboreDepth - intervalGeoParams.WellboreDepth;
+ var projectionLengthToXYSurface = deltaWellLength * Math.Sin(intervalGeoParams.ZenithAngle * Math.PI / 180);
- if (intervalGeoParams.ZenithAngle != null && intervalGeoParams.AzimuthGeo != null && deltaWellLength != null) {
-
- var projectionLengthToXYSurface = deltaWellLength.Value * Math.Sin(intervalGeoParams.ZenithAngle.Value * Math.PI / 180);
+ var dz = deltaWellLength * Math.Cos(intervalGeoParams.ZenithAngle * Math.PI / 180);
+ var dx = projectionLengthToXYSurface * Math.Sin(intervalGeoParams.AzimuthGeo * Math.PI / 180);
+ var dy = projectionLengthToXYSurface * Math.Cos(intervalGeoParams.AzimuthGeo * Math.PI / 180);
- var dz = deltaWellLength.Value * Math.Cos(intervalGeoParams.ZenithAngle.Value * Math.PI / 180);
- var dx = projectionLengthToXYSurface * Math.Sin(intervalGeoParams.AzimuthGeo.Value * Math.PI / 180);
- var dy = projectionLengthToXYSurface * Math.Cos(intervalGeoParams.AzimuthGeo.Value * Math.PI / 180);
+ var preCoordinates = cartesianCoordinates[i - 1];
+ var coordinates = new TrajectoryVisualizationDto
+ {
+ Z = preCoordinates.Z + dz,
+ X = preCoordinates.X + dx,
+ Y = preCoordinates.Y + dy,
+ };
- var preCoordinates = cartesianCoordinates[i - 1];
- var coordinates = new TrajectoryVisualizationDto
- {
- Z = preCoordinates.Z + dz,
- X = preCoordinates.X + dx,
- Y = preCoordinates.Y + dy,
- };
-
- cartesianCoordinates.Add(coordinates);
- }
+ cartesianCoordinates.Add(coordinates);
}
return cartesianCoordinates;
}
}
- ///
- /// Класс для формирования визуализации траектории 3D
- ///
- internal class TrajectoryDto
- {
- ///
- /// Глубина ствола
- ///
- public double? WellboreDepth { get; }
-
- ///
- /// Зенитный угол
- ///
- public double? ZenithAngle { get; }
-
- ///
- /// Азимут географиеский
- ///
- public double? AzimuthGeo { get; }
-
- public TrajectoryDto(double? wellboreDepth, double? zenithAngle, double? azimuthGeo)
- {
- WellboreDepth = wellboreDepth;
- ZenithAngle = zenithAngle;
- AzimuthGeo = azimuthGeo;
- }
- }
}