mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 21:46:30 +00:00
253f811125
lat lon -> geopoint correct location for gps if small keypoints number
99 lines
3.2 KiB
C#
99 lines
3.2 KiB
C#
using System.IO;
|
|
using System.Text;
|
|
using Azaion.Common.Extensions;
|
|
using Azaion.CommonSecurity;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Azaion.Common.DTO.Config;
|
|
|
|
public class AppConfig
|
|
{
|
|
public LoaderClientConfig LoaderClientConfig { get; set; } = null!;
|
|
|
|
public InferenceClientConfig InferenceClientConfig { get; set; } = null!;
|
|
|
|
public GpsDeniedClientConfig GpsDeniedClientConfig { get; set; } = null!;
|
|
|
|
public QueueConfig QueueConfig { get; set; } = null!;
|
|
|
|
public DirectoriesConfig DirectoriesConfig { get; set; } = null!;
|
|
|
|
public AnnotationConfig AnnotationConfig { get; set; } = null!;
|
|
|
|
public UIConfig UIConfig { get; set; } = null!;
|
|
|
|
public AIRecognitionConfig AIRecognitionConfig { get; set; } = null!;
|
|
|
|
public ThumbnailConfig ThumbnailConfig { get; set; } = null!;
|
|
|
|
public MapConfig MapConfig{ get; set; } = null!;
|
|
|
|
public GpsDeniedConfig GpsDeniedConfig { get; set; } = null!;
|
|
}
|
|
|
|
public interface IConfigUpdater
|
|
{
|
|
void CheckConfig();
|
|
void Save(AppConfig config);
|
|
}
|
|
|
|
public class ConfigUpdater : IConfigUpdater
|
|
{
|
|
private static readonly Guid SaveConfigTaskId = Guid.NewGuid();
|
|
|
|
public void CheckConfig()
|
|
{
|
|
var exePath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory)!;
|
|
var configFilePath = Path.Combine(exePath, SecurityConstants.CONFIG_PATH);
|
|
|
|
if (File.Exists(configFilePath))
|
|
return;
|
|
|
|
var appConfig = new AppConfig
|
|
{
|
|
AnnotationConfig = Constants.DefaultAnnotationConfig,
|
|
|
|
UIConfig = new UIConfig
|
|
{
|
|
LeftPanelWidth = Constants.DEFAULT_LEFT_PANEL_WIDTH,
|
|
RightPanelWidth = Constants.DEFAULT_RIGHT_PANEL_WIDTH,
|
|
GenerateAnnotatedImage = false
|
|
},
|
|
|
|
DirectoriesConfig = new DirectoriesConfig
|
|
{
|
|
VideosDirectory = Constants.DEFAULT_VIDEO_DIR,
|
|
ImagesDirectory = Constants.DEFAULT_IMAGES_DIR,
|
|
LabelsDirectory = Constants.DEFAULT_LABELS_DIR,
|
|
ResultsDirectory = Constants.DEFAULT_RESULTS_DIR,
|
|
ThumbnailsDirectory = Constants.DEFAULT_THUMBNAILS_DIR,
|
|
GpsSatDirectory = Constants.DEFAULT_GPS_SAT_DIRECTORY,
|
|
GpsRouteDirectory = Constants.DEFAULT_GPS_ROUTE_DIRECTORY
|
|
},
|
|
|
|
ThumbnailConfig = Constants.DefaultThumbnailConfig,
|
|
AIRecognitionConfig = Constants.DefaultAIRecognitionConfig,
|
|
GpsDeniedConfig = Constants.DefaultGpsDeniedConfig,
|
|
};
|
|
Save(appConfig);
|
|
}
|
|
|
|
public void Save(AppConfig config)
|
|
{
|
|
ThrottleExt.Throttle(async () =>
|
|
{
|
|
var publicConfig = new
|
|
{
|
|
config.LoaderClientConfig,
|
|
config.InferenceClientConfig,
|
|
config.GpsDeniedClientConfig,
|
|
config.DirectoriesConfig,
|
|
config.UIConfig
|
|
};
|
|
|
|
await File.WriteAllTextAsync(SecurityConstants.CONFIG_PATH, JsonConvert.SerializeObject(publicConfig, Formatting.Indented), Encoding.UTF8);
|
|
}, SaveConfigTaskId, TimeSpan.FromSeconds(5));
|
|
|
|
}
|
|
}
|