forked from ddrilling/AsbCloudServer
добавлен отдельный файл для TrajectoryDto, добавлен интерфейс ITrajectoryRepository и его реализация для плановой и фактической траектории
This commit is contained in:
parent
2201b6582d
commit
37399f74a7
13
AsbCloudApp/Data/TrajectoryDto.cs
Normal file
13
AsbCloudApp/Data/TrajectoryDto.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace AsbCloudApp.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Формирование визуализации траектории 3D
|
||||
/// </summary>
|
||||
/// <param name="WellboreDepth">Глубина ствола</param>
|
||||
/// <param name="ZenithAngle">Зенитный угол</param>
|
||||
/// <param name="AzimuthGeo">Азимут географиеский</param>
|
||||
public record TrajectoryDto(
|
||||
double WellboreDepth,
|
||||
double ZenithAngle,
|
||||
double AzimuthGeo);
|
||||
}
|
@ -10,7 +10,7 @@ namespace AsbCloudApp.Repositories
|
||||
/// CRUD для работы с фактической траекторией из клиента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public interface IFactualTrajectoryRepository
|
||||
public interface IFactualTrajectoryRepository : ITrajectoryRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить все добавленные по скважине координаты фактической траектории
|
||||
|
@ -9,7 +9,7 @@ namespace AsbCloudApp.Repositories
|
||||
/// CRUD для работы с плановой траекторией из клиента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public interface IPlannedTrajectoryRepository
|
||||
public interface IPlannedTrajectoryRepository : ITrajectoryRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить все добавленные по скважине координаты плановой траектории
|
||||
|
24
AsbCloudApp/Repositories/ITrajectoryRepository.cs
Normal file
24
AsbCloudApp/Repositories/ITrajectoryRepository.cs
Normal file
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Репозиторий по работе с траекторией
|
||||
/// </summary>
|
||||
public interface ITrajectoryRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Получение траектории для 3D-визуализации
|
||||
/// </summary>
|
||||
/// <param name="idWell">ключ скважины</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<TrajectoryDto[]> GetTrajectoryAsync(int idWell, CancellationToken token);
|
||||
}
|
||||
}
|
@ -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<Record7Dto>());
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<TrajectoryDto[]> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,13 @@ namespace AsbCloudInfrastructure.Repository
|
||||
entity.UpdateDate = DateTime.Now.ToUtcDateTimeOffset(offsetHours);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<TrajectoryDto[]> GetTrajectoryAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
return (await GetAsync(idWell, token))
|
||||
.Select(coord => new TrajectoryDto(coord.WellboreDepth, coord.ZenithAngle, coord.AzimuthGeo))
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,12 +33,8 @@ namespace AsbCloudInfrastructure.Services.Trajectory
|
||||
{
|
||||
var result = new PlanFactBase<IEnumerable<TrajectoryVisualizationDto>>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Класс для формирования визуализации траектории 3D
|
||||
/// </summary>
|
||||
internal class TrajectoryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Глубина ствола
|
||||
/// </summary>
|
||||
public double? WellboreDepth { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Зенитный угол
|
||||
/// </summary>
|
||||
public double? ZenithAngle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Азимут географиеский
|
||||
/// </summary>
|
||||
public double? AzimuthGeo { get; }
|
||||
|
||||
public TrajectoryDto(double? wellboreDepth, double? zenithAngle, double? azimuthGeo)
|
||||
{
|
||||
WellboreDepth = wellboreDepth;
|
||||
ZenithAngle = zenithAngle;
|
||||
AzimuthGeo = azimuthGeo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user