diff --git a/AsbCloudApp/Data/TrajectoryVisualizationDto.cs b/AsbCloudApp/Data/TrajectoryVisualizationDto.cs
index 8e47ccd5..1deb4fbd 100644
--- a/AsbCloudApp/Data/TrajectoryVisualizationDto.cs
+++ b/AsbCloudApp/Data/TrajectoryVisualizationDto.cs
@@ -1,5 +1,6 @@
namespace AsbCloudApp.Data
{
+#nullable enable
///
/// Визуализация траектории 3D
///
diff --git a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj
index 48b0a009..ffc380f4 100644
--- a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj
+++ b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj
@@ -12,7 +12,7 @@
-
+
@@ -30,7 +30,7 @@
-
+
diff --git a/AsbCloudInfrastructure/DependencyInjection.cs b/AsbCloudInfrastructure/DependencyInjection.cs
index cfa4d8ac..2da84cc4 100644
--- a/AsbCloudInfrastructure/DependencyInjection.cs
+++ b/AsbCloudInfrastructure/DependencyInjection.cs
@@ -12,10 +12,10 @@ using AsbCloudInfrastructure.Services;
using AsbCloudInfrastructure.Services.DailyReport;
using AsbCloudInfrastructure.Services.DetectOperations;
using AsbCloudInfrastructure.Services.DrillingProgram;
-using AsbCloudInfrastructure.Services.PlannedTrajectory;
using AsbCloudInfrastructure.Services.ProcessMap;
using AsbCloudInfrastructure.Services.SAUB;
using AsbCloudInfrastructure.Services.Subsystems;
+using AsbCloudInfrastructure.Services.Trajectory;
using AsbCloudInfrastructure.Services.WellOperationService;
using AsbCloudInfrastructure.Validators;
using FluentValidation.AspNetCore;
diff --git a/AsbCloudInfrastructure/Services/PlannedTrajectory/PlannedTrajectoryImportService.cs b/AsbCloudInfrastructure/Services/Trajectory/PlannedTrajectoryImportService.cs
similarity index 96%
rename from AsbCloudInfrastructure/Services/PlannedTrajectory/PlannedTrajectoryImportService.cs
rename to AsbCloudInfrastructure/Services/Trajectory/PlannedTrajectoryImportService.cs
index 0bf97365..810530d5 100644
--- a/AsbCloudInfrastructure/Services/PlannedTrajectory/PlannedTrajectoryImportService.cs
+++ b/AsbCloudInfrastructure/Services/Trajectory/PlannedTrajectoryImportService.cs
@@ -9,7 +9,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-namespace AsbCloudInfrastructure.Services.PlannedTrajectory
+namespace AsbCloudInfrastructure.Services.Trajectory
{
#nullable enable
public class PlannedTrajectoryImportService : IPlannedTrajectoryImportService
@@ -17,7 +17,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
/*
* password for PlannedTrajectoryTemplate.xlsx is Drill2022
*/
-
+
private readonly IWellService wellService;
private readonly IPlannedTrajectoryRepository plannedTrajectoryService;
@@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
public PlannedTrajectoryImportService(IWellService wellService, IPlannedTrajectoryRepository plannedTrajectoryService)
{
-
+
this.wellService = wellService;
this.plannedTrajectoryService = plannedTrajectoryService;
}
@@ -57,21 +57,21 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
return stream;
}
- public async Task GetFileNameAsync (int idWell, CancellationToken token)
+ public async Task GetFileNameAsync(int idWell, CancellationToken token)
{
var fileName = await wellService.GetWellCaptionByIdAsync(idWell, token) + "_plannedTrajectory.xlsx";
return fileName;
}
public async Task ExportAsync(int idWell, CancellationToken token)
- {
- var plannedTrajectorys = await plannedTrajectoryService.GetAsync(idWell, token);
+ {
+ var plannedTrajectorys = await plannedTrajectoryService.GetAsync(idWell, token);
return MakeExelFileStream(plannedTrajectorys);
}
private Stream MakeExelFileStream(IEnumerable plannedTrajectories)
{
- using Stream ecxelTemplateStream = GetTemplateFile();
+ using Stream ecxelTemplateStream = GetTemplateFile();
using var workbook = new XLWorkbook(ecxelTemplateStream, XLEventTracking.Disabled);
AddPlannedTrajecoryToWorkbook(workbook, plannedTrajectories);
MemoryStream memoryStream = new MemoryStream();
@@ -124,12 +124,12 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
using var workbook = new XLWorkbook(stream, XLEventTracking.Disabled);
var trajectoryRows = ParseFileStream(stream);
foreach (var row in trajectoryRows)
- {
- row.IdWell = idWell;
+ {
+ row.IdWell = idWell;
row.IdUser = idUser;
}
- var rowsCount = await SavePlannedTrajectoryAsync(idWell,trajectoryRows, deletePrevRows, token);
+ var rowsCount = await SavePlannedTrajectoryAsync(idWell, trajectoryRows, deletePrevRows, token);
return rowsCount;
}
@@ -206,9 +206,9 @@ namespace AsbCloudInfrastructure.Services.PlannedTrajectory
var _comment = row.Cell(ColumnComment).Value;
var trajectoryRow = new PlannedTrajectoryDto();
-
+
static double getDoubleValue(object value, string nameParam, IXLRow row)
- {
+ {
if (value is double _value)
return _value;
throw new FileFormatException($"Лист {row.Worksheet.Name}. Строка {row.RowNumber()} - некорректные данные - {nameParam}");
diff --git a/AsbCloudInfrastructure/Services/PlannedTrajectory/PlannedTrajectoryTemplate.xlsx b/AsbCloudInfrastructure/Services/Trajectory/PlannedTrajectoryTemplate.xlsx
similarity index 100%
rename from AsbCloudInfrastructure/Services/PlannedTrajectory/PlannedTrajectoryTemplate.xlsx
rename to AsbCloudInfrastructure/Services/Trajectory/PlannedTrajectoryTemplate.xlsx
diff --git a/AsbCloudInfrastructure/Services/Trajectory/TrajectoryVisualizationService.cs b/AsbCloudInfrastructure/Services/Trajectory/TrajectoryVisualizationService.cs
new file mode 100644
index 00000000..d8a30c7d
--- /dev/null
+++ b/AsbCloudInfrastructure/Services/Trajectory/TrajectoryVisualizationService.cs
@@ -0,0 +1,57 @@
+using AsbCloudApp.Data;
+using AsbCloudApp.Repositories;
+using AsbCloudApp.Services;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace AsbCloudInfrastructure.Services.Trajectory
+{
+#nullable enable
+ public class TrajectoryVisualizationService : ITrajectoryVisualizationService
+ {
+ private readonly IPlannedTrajectoryRepository repository;
+
+ public TrajectoryVisualizationService(IPlannedTrajectoryRepository repository)
+ {
+ this.repository = repository;
+ }
+
+ public async Task> GetTrajectoryAsync(int idWell, CancellationToken token)
+ {
+ var geoCoordinates = (await repository.GetAsync(idWell, token)).ToArray();
+
+ if (geoCoordinates.Length < 2)
+ return Enumerable.Empty();
+
+ var cartesianCoordinates = new List(geoCoordinates.Length) {
+ new (),
+ };
+
+ for (var i = 1; i < geoCoordinates.Length; i++)
+ {
+ var intervalGeoParams = geoCoordinates[i - 1];
+ var deltaWellLength = geoCoordinates[i].WellboreDepth - intervalGeoParams.WellboreDepth;
+ var projectionLengthToXYSurface = deltaWellLength * Math.Sin(intervalGeoParams.ZenithAngle * 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 preCoordinates = cartesianCoordinates[i - 1];
+ var coordinates = new TrajectoryVisualizationDto
+ {
+ Z = preCoordinates.Z + dz,
+ X = preCoordinates.X + dx,
+ Y = preCoordinates.Y + dy,
+ };
+
+ cartesianCoordinates.Add(coordinates);
+ }
+
+ return cartesianCoordinates;
+ }
+ }
+}
diff --git a/AsbCloudInfrastructure/Services/TrajectoryVisualizationService.cs b/AsbCloudInfrastructure/Services/TrajectoryVisualizationService.cs
deleted file mode 100644
index dc54f49d..00000000
--- a/AsbCloudInfrastructure/Services/TrajectoryVisualizationService.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using AsbCloudApp.Data;
-using AsbCloudApp.Repositories;
-using AsbCloudApp.Services;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace AsbCloudInfrastructure.Services
-{
- public class TrajectoryVisualizationService : ITrajectoryVisualizationService
- {
- private readonly IPlannedTrajectoryRepository repository;
-
- public TrajectoryVisualizationService(IPlannedTrajectoryRepository repository)
- {
- this.repository = repository;
- }
-
- public async Task> GetTrajectoryAsync(int idWell, CancellationToken token)
- {
- var result = new List {
- new ()
- };
- var dtos = (await repository.GetAsync(idWell, token)).ToArray();
-
- var prevData = dtos[0];
- var prevCoordinates = new TrajectoryVisualizationDto();
-
- for (var i = 1; i < dtos.Length; i++)
- {
- var data = dtos[i];
- var flat = GetFlat(data.WellboreDepth, prevData.WellboreDepth, prevData.ZenithAngle);
- var x = prevCoordinates.X = GetX(prevData.AzimuthGeo, flat, prevCoordinates.X);
- var y = prevCoordinates.Y = GetY(prevData.AzimuthGeo, flat, prevCoordinates.X);
- var z = prevCoordinates.Z = GetZ(data.WellboreDepth, prevData.WellboreDepth, prevData.ZenithAngle, prevCoordinates.Z);
- prevData = data;
-
- var coordinates = new TrajectoryVisualizationDto
- {
- X = x,
- Y = y,
- Z = z
- };
-
- result.Add(coordinates);
- }
-
- return result;
- }
-
- private double GetFlat(double depthEnd, double depthStart, double zenit) =>
- (depthEnd - depthStart) * Math.Sin(zenit * Math.PI / 180);
-
- private double GetX(double azimuth, double flat, double prev) =>
- prev + flat * Math.Sin(azimuth * Math.PI / 180);
-
- private double GetY(double azimuth, double flat, double prev) =>
- prev + flat * Math.Cos(azimuth * Math.PI / 180);
-
- private double GetZ(double depthEnd, double depthStart, double zenit, double prev) =>
- prev + (depthEnd - depthStart) * Math.Cos(zenit * Math.PI / 180);
- }
-}