Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GeoProfiles/Features/Auth/Login/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion GeoProfiles/Features/Auth/Refresh/Refresh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion GeoProfiles/Features/Profiles/Create/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion GeoProfiles/Features/Profiles/Create/ProfileResponse.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion GeoProfiles/Features/Profiles/Get/FullProfileResponse.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion GeoProfiles/Features/Profiles/Get/Get.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion GeoProfiles/Features/Projects/Create/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GeoProfiles.Infrastructure.Services;
using GeoProfiles.Services;

namespace GeoProfiles.Infrastructure.Extensions;

Expand Down
2 changes: 1 addition & 1 deletion GeoProfiles/Infrastructure/Extensions/JwtExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -20,7 +20,7 @@

var sp = services.BuildServiceProvider();
var http = sp.GetRequiredService<IHttpClientFactory>().CreateClient();
var jwksJson = http.GetStringAsync(settings.SigningJwksUri).GetAwaiter().GetResult();

Check warning on line 23 in GeoProfiles/Infrastructure/Extensions/JwtExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 23 in GeoProfiles/Infrastructure/Extensions/JwtExtensions.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 23 in GeoProfiles/Infrastructure/Extensions/JwtExtensions.cs

View workflow job for this annotation

GitHub Actions / test-app-pr

Dereference of a possibly null reference.

Check warning on line 23 in GeoProfiles/Infrastructure/Extensions/JwtExtensions.cs

View workflow job for this annotation

GitHub Actions / test-app-pr

Dereference of a possibly null reference.
var jwkSet = new JsonWebKeySet(jwksJson);

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GeoProfiles.Infrastructure.Services;
using GeoProfiles.Services;

namespace GeoProfiles.Infrastructure.Extensions;

Expand Down
2 changes: 1 addition & 1 deletion GeoProfiles/Infrastructure/Modules/IsolineModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GeoProfiles.Infrastructure.Services;
using GeoProfiles.Services;

namespace GeoProfiles.Infrastructure.Modules;

Expand Down
2 changes: 2 additions & 0 deletions GeoProfiles/Migrations/V9__Add_Isoline_Direction.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table isolines
add column direction int;
1 change: 1 addition & 0 deletions GeoProfiles/Model/Generated/GeoProfilesContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions GeoProfiles/Model/Generated/Isolines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
}
8 changes: 8 additions & 0 deletions GeoProfiles/Model/IsolineDirections.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace GeoProfiles.Model;

public static class IsolineDirections
{
public const int Up = 1;

public const int Down = 2;
}
1 change: 0 additions & 1 deletion GeoProfiles/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions GeoProfiles/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GeoProfiles.Infrastructure.Services;
namespace GeoProfiles.Services;

public interface IInterpolator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -137,6 +130,7 @@ await Parallel.ForEachAsync(
{
double xx = totalDistM * i / (OutN - 1);
xs[i] = xx;

ys[i] = spline.Interpolate(xx);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<IEnumerable<Polygon>> GenerateAsync(
BoundingBox bbox, int levels = 12, Guid? seed = null)
Expand Down Expand Up @@ -71,7 +67,6 @@

private Geometry CreateStableTerrain(BoundingBox bbox, Random rnd)
{
double minDim = Math.Min(bbox.Width, bbox.Height);
var features = new List<Geometry>();

var mountain = CreateMountain(bbox, rnd);
Expand Down Expand Up @@ -129,7 +124,7 @@

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;
Expand All @@ -152,7 +147,7 @@

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;
Expand All @@ -167,11 +162,11 @@

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)
{
Expand All @@ -185,8 +180,8 @@
{
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);
Expand Down Expand Up @@ -250,7 +245,7 @@
}
catch
{
return null;

Check warning on line 248 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 248 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 248 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / test-app-pr

Possible null reference return.

Check warning on line 248 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / test-app-pr

Possible null reference return.
}
}

Expand Down Expand Up @@ -283,7 +278,7 @@
try
{
var exterior = SmoothRing(poly.ExteriorRing, iterations);
if (exterior == null) return null;

Check warning on line 281 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 281 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 281 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / test-app-pr

Possible null reference return.

Check warning on line 281 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / test-app-pr

Possible null reference return.

var holes = new List<LinearRing>();
for (int i = 0; i < poly.NumInteriorRings; i++)
Expand All @@ -296,7 +291,7 @@
}
catch
{
return null;

Check warning on line 294 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.

Check warning on line 294 in GeoProfiles/Services/IsolineGeneratorService.cs

View workflow job for this annotation

GitHub Actions / test-app-pr

Possible null reference return.
}
}

Expand Down Expand Up @@ -341,14 +336,13 @@
}

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<Polygon> Flatten(Geometry g)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;

namespace GeoProfiles.Infrastructure.Services;
namespace GeoProfiles.Services;

public interface IJwtTokenService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using GeoProfiles.Model;
using Microsoft.Extensions.Options;

namespace GeoProfiles.Infrastructure.Services;
namespace GeoProfiles.Services;

public interface ITokenService
{
Expand All @@ -14,7 +14,7 @@
public class TokenService(
IJwtTokenService jwt,
GeoProfilesContext db,
IOptions<JwtSettings> opts)

Check warning on line 17 in GeoProfiles/Services/TokenService.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'opts' is unread.

Check warning on line 17 in GeoProfiles/Services/TokenService.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'opts' is unread.

Check warning on line 17 in GeoProfiles/Services/TokenService.cs

View workflow job for this annotation

GitHub Actions / test-app-pr

Parameter 'opts' is unread.

Check warning on line 17 in GeoProfiles/Services/TokenService.cs

View workflow job for this annotation

GitHub Actions / test-app-pr

Parameter 'opts' is unread.
: ITokenService
{
public (string AccessToken, string RefreshToken) GenerateTokens(Guid userId, string username, string email,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
"test": "jest --testTimeout=10000"
},
"repository": {
"type": "git",
Expand Down
Loading