forked from ddrilling/AsbCloudServer
#8636739 Визуализация траектории 3D
This commit is contained in:
parent
d4d3041a14
commit
d47fa1b09c
41
AsbCloudApp/Data/TrajectoryVisualizationDataDto.cs
Normal file
41
AsbCloudApp/Data/TrajectoryVisualizationDataDto.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
namespace AsbCloudDb.Model
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
/// <summary>
|
||||||
|
/// Данные для визуализации траектории
|
||||||
|
/// </summary>
|
||||||
|
public class TrajectoryVisualizationDataDto
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Глубина по стволу
|
||||||
|
/// </summary>
|
||||||
|
public double WellboreDepth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Зенит
|
||||||
|
/// </summary>
|
||||||
|
public double Zenith { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Азимут
|
||||||
|
/// </summary>
|
||||||
|
public double Azimuth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Координаты по оси X
|
||||||
|
/// </summary>
|
||||||
|
public double X { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Координаты по оси Y
|
||||||
|
/// </summary>
|
||||||
|
public double Y { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Координаты по оси Z
|
||||||
|
/// </summary>
|
||||||
|
public double Z { get; set; }
|
||||||
|
}
|
||||||
|
#nullable disable
|
||||||
|
}
|
32
AsbCloudApp/Data/TrajectoryVisualizationDto.cs
Normal file
32
AsbCloudApp/Data/TrajectoryVisualizationDto.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Визуализация траектории 3D
|
||||||
|
/// </summary>
|
||||||
|
public class TrajectoryVisualizationDto : IWellRelated
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Плоскость
|
||||||
|
/// </summary>
|
||||||
|
public double Flat { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Координаты по оси X
|
||||||
|
/// </summary>
|
||||||
|
public double X { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Координаты по оси Y
|
||||||
|
/// </summary>
|
||||||
|
public double Y { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Координаты по оси Z
|
||||||
|
/// </summary>
|
||||||
|
public double Z { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using AsbCloudDb.Model;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Repositories
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
/// <summary>
|
||||||
|
/// Визуализация траектории 3D
|
||||||
|
/// </summary>
|
||||||
|
public interface ITrajectoryVisualizationRepository
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение данных для расчета
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<TrajectoryVisualizationDataDto>> GetAllAsync(int idWell, CancellationToken token);
|
||||||
|
}
|
||||||
|
#nullable disable
|
||||||
|
}
|
23
AsbCloudApp/Services/ITrajectoryVisualizationService.cs
Normal file
23
AsbCloudApp/Services/ITrajectoryVisualizationService.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Services
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
/// <summary>
|
||||||
|
/// Сервис "Визуализация траектории 3D"
|
||||||
|
/// </summary>
|
||||||
|
public interface ITrajectoryVisualizationService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение траектории по скважине
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<TrajectoryVisualizationDto>> GetTrajectoryAsync(int idWell, CancellationToken token);
|
||||||
|
}
|
||||||
|
#nullable disable
|
||||||
|
}
|
@ -72,4 +72,8 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EditorConfigFiles Remove="D:\Source\AsbCloudInfrastructure\Repository\.editorconfig" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -140,6 +140,7 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<ILimitingParameterService, LimitingParameterService>();
|
services.AddTransient<ILimitingParameterService, LimitingParameterService>();
|
||||||
services.AddTransient<IProcessMapReportService, ProcessMapReportService>();
|
services.AddTransient<IProcessMapReportService, ProcessMapReportService>();
|
||||||
services.AddTransient<IProcessMapService, ProcessMapService>();
|
services.AddTransient<IProcessMapService, ProcessMapService>();
|
||||||
|
services.AddTransient<ITrajectoryVisualizationService, TrajectoryVisualizationService>();
|
||||||
|
|
||||||
// admin crud services:
|
// admin crud services:
|
||||||
services.AddTransient<ICrudRepository<TelemetryDto>, CrudCacheRepositoryBase<TelemetryDto, Telemetry>>(s =>
|
services.AddTransient<ICrudRepository<TelemetryDto>, CrudCacheRepositoryBase<TelemetryDto, Telemetry>>(s =>
|
||||||
@ -177,6 +178,7 @@ namespace AsbCloudInfrastructure
|
|||||||
services.AddTransient<ILimitingParameterRepository, LimitingParameterRepository>();
|
services.AddTransient<ILimitingParameterRepository, LimitingParameterRepository>();
|
||||||
services.AddTransient<ITelemetryWirelineRunOutRepository, TelemetryWirelineRunOutRepository>();
|
services.AddTransient<ITelemetryWirelineRunOutRepository, TelemetryWirelineRunOutRepository>();
|
||||||
services.AddTransient<IWellFinalDocumentsRepository, WellFinalDocumentsRepository>();
|
services.AddTransient<IWellFinalDocumentsRepository, WellFinalDocumentsRepository>();
|
||||||
|
services.AddTransient<ITrajectoryVisualizationRepository, TrajectoryVisualizationRepository>();
|
||||||
|
|
||||||
// Subsystem service
|
// Subsystem service
|
||||||
services.AddTransient<ICrudRepository<SubsystemDto>, CrudCacheRepositoryBase<SubsystemDto, Subsystem>>();
|
services.AddTransient<ICrudRepository<SubsystemDto>, CrudCacheRepositoryBase<SubsystemDto, Subsystem>>();
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
using AsbCloudApp.Repositories;
|
||||||
|
using AsbCloudDb.Model;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AsbCloudInfrastructure.Repository
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
public class TrajectoryVisualizationRepository : ITrajectoryVisualizationRepository
|
||||||
|
{
|
||||||
|
private readonly IAsbCloudDbContext context;
|
||||||
|
|
||||||
|
public TrajectoryVisualizationRepository(IAsbCloudDbContext context)
|
||||||
|
{
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<IEnumerable<TrajectoryVisualizationDataDto>> GetAllAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var dtos = await context.PlannedTrajectories
|
||||||
|
.Where(t => t.IdWell == idWell)
|
||||||
|
.OrderBy(x => x.UpdateDate)
|
||||||
|
.Select(x => Convert(x))
|
||||||
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TrajectoryVisualizationDataDto Convert(PlannedTrajectory dto)
|
||||||
|
{
|
||||||
|
return new TrajectoryVisualizationDataDto {
|
||||||
|
WellboreDepth = dto.WellboreDepth,
|
||||||
|
Azimuth = dto.AzimuthGeo,
|
||||||
|
Zenith = dto.ZenithAngle
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#nullable disable
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
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 ITrajectoryVisualizationRepository repository;
|
||||||
|
|
||||||
|
public TrajectoryVisualizationService(ITrajectoryVisualizationRepository repository)
|
||||||
|
{
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<TrajectoryVisualizationDto>> GetTrajectoryAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = new List<TrajectoryVisualizationDto>();
|
||||||
|
var dto = (await repository.GetAllAsync(idWell, token)).ToArray();
|
||||||
|
|
||||||
|
var prevData = dto[0];
|
||||||
|
for (var i = 1; i < dto.Length; i++)
|
||||||
|
{
|
||||||
|
var data = dto[i];
|
||||||
|
var flat = GetFlat(data.WellboreDepth, prevData.WellboreDepth, data.Zenith);
|
||||||
|
var x = data.X = GetX(data.Azimuth, flat, prevData.X);
|
||||||
|
var y = data.Y = GetY(data.Azimuth, flat, prevData.Y);
|
||||||
|
var z = data.Z = GetZ(data.WellboreDepth, prevData.WellboreDepth, data.Zenith, prevData.Z);
|
||||||
|
prevData = data;
|
||||||
|
|
||||||
|
var coordinates = new TrajectoryVisualizationDto
|
||||||
|
{
|
||||||
|
IdWell = idWell,
|
||||||
|
Flat = flat,
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
using AsbCloudApp.Data;
|
||||||
|
using AsbCloudApp.Services;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AsbCloudWebApi.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Визуализация траектории 3D
|
||||||
|
/// </summary>
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class TrajectoryVisualizationController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ITrajectoryVisualizationService service;
|
||||||
|
|
||||||
|
public TrajectoryVisualizationController(ITrajectoryVisualizationService service)
|
||||||
|
{
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResponseType(typeof(IEnumerable<TrajectoryVisualizationDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> GetTrajectoryAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = await service.GetTrajectoryAsync(idWell, token);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user