diff --git a/GeoProfiles/Features/Auth/Login/Login.cs b/GeoProfiles/Features/Auth/Login/Login.cs index 88031b4..53c55ac 100644 --- a/GeoProfiles/Features/Auth/Login/Login.cs +++ b/GeoProfiles/Features/Auth/Login/Login.cs @@ -3,8 +3,8 @@ using GeoProfiles.Features.Auth.Register; using GeoProfiles.Infrastructure; using GeoProfiles.Infrastructure.Examples; -using GeoProfiles.Infrastructure.Services; using GeoProfiles.Model.Dto; +using GeoProfiles.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Swashbuckle.AspNetCore.Filters; diff --git a/GeoProfiles/Features/Auth/Refresh/Refresh.cs b/GeoProfiles/Features/Auth/Refresh/Refresh.cs index 72e5a08..f6503f0 100644 --- a/GeoProfiles/Features/Auth/Refresh/Refresh.cs +++ b/GeoProfiles/Features/Auth/Refresh/Refresh.cs @@ -2,8 +2,8 @@ using FluentValidation; using GeoProfiles.Infrastructure; using GeoProfiles.Infrastructure.Examples; -using GeoProfiles.Infrastructure.Services; using GeoProfiles.Model.Dto; +using GeoProfiles.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Swashbuckle.AspNetCore.Filters; diff --git a/GeoProfiles/Features/Profiles/Create/Create.cs b/GeoProfiles/Features/Profiles/Create/Create.cs index 1192905..b1dc61c 100644 --- a/GeoProfiles/Features/Profiles/Create/Create.cs +++ b/GeoProfiles/Features/Profiles/Create/Create.cs @@ -3,7 +3,7 @@ using GeoProfiles.Application.Auth; using GeoProfiles.Infrastructure; using GeoProfiles.Infrastructure.Examples; -using GeoProfiles.Infrastructure.Services; +using GeoProfiles.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/GeoProfiles/Features/Profiles/Create/ProfileResponse.cs b/GeoProfiles/Features/Profiles/Create/ProfileResponse.cs index 645c741..6248b00 100644 --- a/GeoProfiles/Features/Profiles/Create/ProfileResponse.cs +++ b/GeoProfiles/Features/Profiles/Create/ProfileResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using GeoProfiles.Infrastructure.Services; +using GeoProfiles.Services; using Swashbuckle.AspNetCore.Filters; namespace GeoProfiles.Features.Profiles.Create; diff --git a/GeoProfiles/Features/Profiles/Get/FullProfileResponse.cs b/GeoProfiles/Features/Profiles/Get/FullProfileResponse.cs index 6bac5bd..3b2e565 100644 --- a/GeoProfiles/Features/Profiles/Get/FullProfileResponse.cs +++ b/GeoProfiles/Features/Profiles/Get/FullProfileResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using GeoProfiles.Infrastructure.Services; +using GeoProfiles.Services; using Swashbuckle.AspNetCore.Filters; namespace GeoProfiles.Features.Profiles.Get; diff --git a/GeoProfiles/Features/Profiles/Get/Get.cs b/GeoProfiles/Features/Profiles/Get/Get.cs index f4b998f..b68aeaf 100644 --- a/GeoProfiles/Features/Profiles/Get/Get.cs +++ b/GeoProfiles/Features/Profiles/Get/Get.cs @@ -3,7 +3,7 @@ using GeoProfiles.Application.Auth; using GeoProfiles.Infrastructure; using GeoProfiles.Infrastructure.Examples; -using GeoProfiles.Infrastructure.Services; +using GeoProfiles.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/GeoProfiles/Features/Projects/Create/Create.cs b/GeoProfiles/Features/Projects/Create/Create.cs index 7a4db7b..e10a533 100644 --- a/GeoProfiles/Features/Projects/Create/Create.cs +++ b/GeoProfiles/Features/Projects/Create/Create.cs @@ -2,8 +2,8 @@ using FluentValidation; using GeoProfiles.Application.Auth; using GeoProfiles.Infrastructure; -using GeoProfiles.Infrastructure.Services; using GeoProfiles.Model.Dto; +using GeoProfiles.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/GeoProfiles/Infrastructure/Extensions/ElevationExtensions.cs b/GeoProfiles/Infrastructure/Extensions/ElevationExtensions.cs index 16cbc4e..d8709aa 100644 --- a/GeoProfiles/Infrastructure/Extensions/ElevationExtensions.cs +++ b/GeoProfiles/Infrastructure/Extensions/ElevationExtensions.cs @@ -1,4 +1,4 @@ -using GeoProfiles.Infrastructure.Services; +using GeoProfiles.Services; namespace GeoProfiles.Infrastructure.Extensions; diff --git a/GeoProfiles/Infrastructure/Extensions/JwtExtensions.cs b/GeoProfiles/Infrastructure/Extensions/JwtExtensions.cs index 5b308bb..93d6f03 100644 --- a/GeoProfiles/Infrastructure/Extensions/JwtExtensions.cs +++ b/GeoProfiles/Infrastructure/Extensions/JwtExtensions.cs @@ -1,9 +1,9 @@ -using GeoProfiles.Infrastructure.Services; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Protocols; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using GeoProfiles.Infrastructure.Settings; +using GeoProfiles.Services; namespace GeoProfiles.Infrastructure.Extensions; diff --git a/GeoProfiles/Infrastructure/Extensions/ProfilesExtensions.cs b/GeoProfiles/Infrastructure/Extensions/ProfilesExtensions.cs index b17b7af..0bfd5bb 100644 --- a/GeoProfiles/Infrastructure/Extensions/ProfilesExtensions.cs +++ b/GeoProfiles/Infrastructure/Extensions/ProfilesExtensions.cs @@ -1,4 +1,4 @@ -using GeoProfiles.Infrastructure.Services; +using GeoProfiles.Services; namespace GeoProfiles.Infrastructure.Extensions; diff --git a/GeoProfiles/Infrastructure/Modules/IsolineModule.cs b/GeoProfiles/Infrastructure/Modules/IsolineModule.cs index 88f4a94..20fc9ba 100644 --- a/GeoProfiles/Infrastructure/Modules/IsolineModule.cs +++ b/GeoProfiles/Infrastructure/Modules/IsolineModule.cs @@ -1,4 +1,4 @@ -using GeoProfiles.Infrastructure.Services; +using GeoProfiles.Services; namespace GeoProfiles.Infrastructure.Modules; diff --git a/GeoProfiles/Migrations/V9__Add_Isoline_Direction.sql b/GeoProfiles/Migrations/V9__Add_Isoline_Direction.sql new file mode 100644 index 0000000..97c13b4 --- /dev/null +++ b/GeoProfiles/Migrations/V9__Add_Isoline_Direction.sql @@ -0,0 +1,2 @@ +alter table isolines + add column direction int; \ No newline at end of file diff --git a/GeoProfiles/Model/Generated/GeoProfilesContext.cs b/GeoProfiles/Model/Generated/GeoProfilesContext.cs index d9d9f2d..ce763cf 100644 --- a/GeoProfiles/Model/Generated/GeoProfilesContext.cs +++ b/GeoProfiles/Model/Generated/GeoProfilesContext.cs @@ -105,6 +105,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.Property(e => e.CreatedAt) .HasDefaultValueSql("now()") .HasColumnName("created_at"); + entity.Property(e => e.Direction).HasColumnName("direction"); entity.Property(e => e.Geom) .HasColumnType("geometry(Polygon,4326)") .HasColumnName("geom"); diff --git a/GeoProfiles/Model/Generated/Isolines.cs b/GeoProfiles/Model/Generated/Isolines.cs index 11c72bc..61e3005 100644 --- a/GeoProfiles/Model/Generated/Isolines.cs +++ b/GeoProfiles/Model/Generated/Isolines.cs @@ -18,5 +18,7 @@ public partial class Isolines public DateTime UpdatedAt { get; set; } + public int? Direction { get; set; } + public virtual Projects Project { get; set; } = null!; } diff --git a/GeoProfiles/Model/IsolineDirections.cs b/GeoProfiles/Model/IsolineDirections.cs new file mode 100644 index 0000000..09070a9 --- /dev/null +++ b/GeoProfiles/Model/IsolineDirections.cs @@ -0,0 +1,8 @@ +namespace GeoProfiles.Model; + +public static class IsolineDirections +{ + public const int Up = 1; + + public const int Down = 2; +} \ No newline at end of file diff --git a/GeoProfiles/Program.cs b/GeoProfiles/Program.cs index e9b3c4b..8bd5093 100644 --- a/GeoProfiles/Program.cs +++ b/GeoProfiles/Program.cs @@ -3,7 +3,6 @@ using GeoProfiles.Infrastructure.Middlewares; using Microsoft.EntityFrameworkCore; using GeoProfiles.Infrastructure.Modules; -using GeoProfiles.Infrastructure.Services; using static Microsoft.AspNetCore.Builder.WebApplication; var builder = CreateBuilder(args); diff --git a/GeoProfiles/Properties/launchSettings.json b/GeoProfiles/Properties/launchSettings.json index ad3b15f..d46795b 100644 --- a/GeoProfiles/Properties/launchSettings.json +++ b/GeoProfiles/Properties/launchSettings.json @@ -19,6 +19,26 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, + "Demo BMSTU": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "launchUrl": "swagger", + "applicationUrl": "http://172.28.19.209:8080", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Demo home": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://192.168.1.81:8080", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, "https": { "commandName": "Project", "dotnetRunMessages": true, diff --git a/GeoProfiles/Infrastructure/Services/IInterpolator.cs b/GeoProfiles/Services/IInterpolator.cs similarity index 97% rename from GeoProfiles/Infrastructure/Services/IInterpolator.cs rename to GeoProfiles/Services/IInterpolator.cs index 28a01b1..aee8ba6 100644 --- a/GeoProfiles/Infrastructure/Services/IInterpolator.cs +++ b/GeoProfiles/Services/IInterpolator.cs @@ -1,4 +1,4 @@ -namespace GeoProfiles.Infrastructure.Services; +namespace GeoProfiles.Services; public interface IInterpolator { diff --git a/GeoProfiles/Infrastructure/Services/ITerrainProfileService.cs b/GeoProfiles/Services/ITerrainProfileService.cs similarity index 96% rename from GeoProfiles/Infrastructure/Services/ITerrainProfileService.cs rename to GeoProfiles/Services/ITerrainProfileService.cs index 3e43bb0..ff16412 100644 --- a/GeoProfiles/Infrastructure/Services/ITerrainProfileService.cs +++ b/GeoProfiles/Services/ITerrainProfileService.cs @@ -1,18 +1,12 @@ -using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using GeoProfiles.Model; -using GeoProfiles.Model.Dto; using Microsoft.EntityFrameworkCore; using NetTopologySuite.Geometries; using NetTopologySuite.LinearReferencing; using ProjNet.CoordinateSystems; using ProjNet.CoordinateSystems.Transformations; -namespace GeoProfiles.Infrastructure.Services +namespace GeoProfiles.Services { public readonly record struct ProfilePoint(double Distance, double Elevation); @@ -52,9 +46,8 @@ public class TerrainProfileService( private const double DefaultSampleM = 10; private const int MaxRawPoints = 20_000; - private const int OutN = 400; // Финализированная константа + private const int OutN = 400; - // Кэш коэффициентов Савицкого-Голая private static readonly ConcurrentDictionary<(int, int), double[]> SavGolCoefficientsCache = new(); private static Point ToMercator(Point p) @@ -137,6 +130,7 @@ await Parallel.ForEachAsync( { double xx = totalDistM * i / (OutN - 1); xs[i] = xx; + ys[i] = spline.Interpolate(xx); } diff --git a/GeoProfiles/Infrastructure/Services/IsolineGeneratorService.cs b/GeoProfiles/Services/IsolineGeneratorService.cs similarity index 94% rename from GeoProfiles/Infrastructure/Services/IsolineGeneratorService.cs rename to GeoProfiles/Services/IsolineGeneratorService.cs index 164fe0d..26c9e08 100644 --- a/GeoProfiles/Infrastructure/Services/IsolineGeneratorService.cs +++ b/GeoProfiles/Services/IsolineGeneratorService.cs @@ -1,20 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using NetTopologySuite.Geometries; using NetTopologySuite.Geometries.Implementation; using NetTopologySuite.Operation.Buffer; using NetTopologySuite.Operation.Union; -namespace GeoProfiles.Infrastructure.Services +namespace GeoProfiles.Services { public sealed class IsolineGeneratorService : IIsolineGeneratorService { private static readonly GeometryFactory Gf = new(new PrecisionModel(PrecisionModels.Floating), 4326, CoordinateArraySequenceFactory.Instance); - private const double TAU = Math.PI * 2; + private const double Tau = Math.PI * 2; public Task> GenerateAsync( BoundingBox bbox, int levels = 12, Guid? seed = null) @@ -71,7 +67,6 @@ public Task> GenerateAsync( private Geometry CreateStableTerrain(BoundingBox bbox, Random rnd) { - double minDim = Math.Min(bbox.Width, bbox.Height); var features = new List(); var mountain = CreateMountain(bbox, rnd); @@ -129,7 +124,7 @@ private IEnumerable CreatePeaks(BoundingBox bbox, Geometry mountain, R for (int i = 0; i < count; i++) { - double angle = rnd.NextDouble() * TAU; + double angle = rnd.NextDouble() * Tau; double distance = rnd.NextDouble() * minDim * 0.2; double x = centroid.X + Math.Cos(angle) * distance; double y = centroid.Y + Math.Sin(angle) * distance; @@ -152,7 +147,7 @@ private IEnumerable CreateHills(BoundingBox bbox, Random rnd, int coun for (int i = 0; i < count; i++) { - double angle = rnd.NextDouble() * TAU; + double angle = rnd.NextDouble() * Tau; double distance = minDim * (0.3 + rnd.NextDouble() * 0.25); double x = bbox.CenterX + Math.Cos(angle) * distance; double y = bbox.CenterY + Math.Sin(angle) * distance; @@ -167,11 +162,11 @@ private IEnumerable CreateHills(BoundingBox bbox, Random rnd, int coun private Polygon CreateEllipse(double x, double y, double a, double b, int points, Random rnd) { - if (points < 36) points = 36; + if (points < 36) points = 36; var coords = new Coordinate[points + 1]; - double angleStep = TAU / points; - double noiseIntensity = 0.18; + double angleStep = Tau / points; + double noiseIntensity = 0.18; double SmoothNoise(double seed, double angle, double frequency) { @@ -185,8 +180,8 @@ double SmoothNoise(double seed, double angle, double frequency) { double angle = i * angleStep; - double noiseFactor = 1.0 + - SmoothNoise(seed1, angle, 3.0) + + double noiseFactor = 1.0 + + SmoothNoise(seed1, angle, 3.0) + SmoothNoise(seed2, angle, 8.0) * 0.5; double effectiveA = a * noiseFactor * (0.92 + rnd.NextDouble() * 0.16); @@ -341,14 +336,13 @@ private LinearRing SmoothRing(LineString ring, int iterations) } private static Polygon BboxPolygon(BoundingBox b) => - Gf.CreatePolygon(new[] - { + Gf.CreatePolygon([ new Coordinate(b.MinX, b.MinY), new Coordinate(b.MaxX, b.MinY), new Coordinate(b.MaxX, b.MaxY), new Coordinate(b.MinX, b.MaxY), new Coordinate(b.MinX, b.MinY) - }); + ]); private static IEnumerable Flatten(Geometry g) { diff --git a/GeoProfiles/Infrastructure/Services/JwtTokenService.cs b/GeoProfiles/Services/JwtTokenService.cs similarity index 98% rename from GeoProfiles/Infrastructure/Services/JwtTokenService.cs rename to GeoProfiles/Services/JwtTokenService.cs index 6f7b692..cbfe3f9 100644 --- a/GeoProfiles/Infrastructure/Services/JwtTokenService.cs +++ b/GeoProfiles/Services/JwtTokenService.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; -namespace GeoProfiles.Infrastructure.Services; +namespace GeoProfiles.Services; public interface IJwtTokenService { diff --git a/GeoProfiles/Infrastructure/Services/MockElevationProvider.cs b/GeoProfiles/Services/MockElevationProvider.cs similarity index 95% rename from GeoProfiles/Infrastructure/Services/MockElevationProvider.cs rename to GeoProfiles/Services/MockElevationProvider.cs index 86b90a4..0884e79 100644 --- a/GeoProfiles/Infrastructure/Services/MockElevationProvider.cs +++ b/GeoProfiles/Services/MockElevationProvider.cs @@ -1,16 +1,11 @@ -using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using NetTopologySuite.Geometries; using NetTopologySuite.Index.Strtree; using NetTopologySuite.Operation.Distance; -namespace GeoProfiles.Infrastructure.Services +namespace GeoProfiles.Services { public class MockDemOptions { @@ -124,7 +119,7 @@ private double CalculateR(Contour inner, Point boundaryPoint, Contour? outer, Po boundaryPoint.X + directionVector.X * 10, boundaryPoint.Y + directionVector.Y * 10); - var ray = new LineString(new[] { boundaryPoint.Coordinate, rayEnd }); + var ray = new LineString([boundaryPoint.Coordinate, rayEnd]); var intersection = ray.Intersection(outer.Poly); return !intersection.IsEmpty diff --git a/GeoProfiles/Infrastructure/Services/TokenService.cs b/GeoProfiles/Services/TokenService.cs similarity index 95% rename from GeoProfiles/Infrastructure/Services/TokenService.cs rename to GeoProfiles/Services/TokenService.cs index 4ac8582..305a655 100644 --- a/GeoProfiles/Infrastructure/Services/TokenService.cs +++ b/GeoProfiles/Services/TokenService.cs @@ -3,7 +3,7 @@ using GeoProfiles.Model; using Microsoft.Extensions.Options; -namespace GeoProfiles.Infrastructure.Services; +namespace GeoProfiles.Services; public interface ITokenService { diff --git a/package.json b/package.json index 2fc4f9e..6fc5a7e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "test": "jest" + "test": "jest --testTimeout=10000" }, "repository": { "type": "git",