mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:06:30 +00:00
add map support for gps denied
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CsvHelper" Version="33.0.1" />
|
||||
<PackageReference Include="linq2db.SQLite" Version="5.4.1" />
|
||||
<PackageReference Include="MediatR" Version="12.4.1" />
|
||||
<PackageReference Include="MessagePack" Version="3.1.0" />
|
||||
|
||||
@@ -90,4 +90,5 @@ public class Constants
|
||||
|
||||
#endregion
|
||||
|
||||
public const string CSV_PATH = "D:\\matches.csv";
|
||||
}
|
||||
@@ -8,17 +8,19 @@ namespace Azaion.Common.DTO.Config;
|
||||
|
||||
public class AppConfig
|
||||
{
|
||||
public PythonConfig PythonConfig { get; set; } = null!;
|
||||
public PythonConfig PythonConfig { get; set; } = null!;
|
||||
|
||||
public QueueConfig QueueConfig { get; set; } = null!;
|
||||
public QueueConfig QueueConfig { get; set; } = null!;
|
||||
|
||||
public DirectoriesConfig DirectoriesConfig { get; set; } = null!;
|
||||
public DirectoriesConfig DirectoriesConfig { get; set; } = null!;
|
||||
|
||||
public AnnotationConfig AnnotationConfig { get; set; } = null!;
|
||||
public AnnotationConfig AnnotationConfig { get; set; } = null!;
|
||||
|
||||
public AIRecognitionConfig AIRecognitionConfig { get; set; } = null!;
|
||||
|
||||
public ThumbnailConfig ThumbnailConfig { get; set; } = null!;
|
||||
public ThumbnailConfig ThumbnailConfig { get; set; } = null!;
|
||||
|
||||
public MapConfig MapConfig{ get; set; } = null!;
|
||||
}
|
||||
|
||||
public interface IConfigUpdater
|
||||
@@ -80,6 +82,16 @@ public class ConfigUpdater : IConfigUpdater
|
||||
|
||||
public void Save(AppConfig config)
|
||||
{
|
||||
File.WriteAllText(SecurityConstants.CONFIG_PATH, JsonConvert.SerializeObject(config, Formatting.Indented), Encoding.UTF8);
|
||||
//Save without sensitive info
|
||||
var publicConfig = new
|
||||
{
|
||||
PythonConfig = config.PythonConfig,
|
||||
DirectoriesConfig = config.DirectoriesConfig,
|
||||
AnnotationConfig = config.AnnotationConfig,
|
||||
AIRecognitionConfig = config.AIRecognitionConfig,
|
||||
ThumbnailConfig = config.ThumbnailConfig
|
||||
};
|
||||
|
||||
File.WriteAllText(SecurityConstants.CONFIG_PATH, JsonConvert.SerializeObject(publicConfig, Formatting.Indented), Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Azaion.Common.DTO.Config;
|
||||
|
||||
public class MapConfig
|
||||
{
|
||||
public string Service { get; set; }
|
||||
public string ApiKey { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
namespace Azaion.Common.DTO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
public class GpsCsvResult
|
||||
{
|
||||
public string Image { get; set; }
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public int Keypoints { get; set; }
|
||||
public int Rotation { get; set; }
|
||||
public string MatchType { get; set; }
|
||||
|
||||
public static List<GpsCsvResult> ReadFromCsv(string csvFilePath)
|
||||
{
|
||||
var imageDatas = new List<GpsCsvResult>();
|
||||
|
||||
using var reader = new StreamReader(csvFilePath);
|
||||
//read header
|
||||
reader.ReadLine();
|
||||
if (reader.EndOfStream)
|
||||
return new List<GpsCsvResult>();
|
||||
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
continue;
|
||||
var values = line.Split(',');
|
||||
if (values.Length == 6)
|
||||
{
|
||||
imageDatas.Add(new GpsCsvResult
|
||||
{
|
||||
Image = GetFilename(values[0]),
|
||||
Latitude = double.Parse(values[1]),
|
||||
Longitude = double.Parse(values[2]),
|
||||
Keypoints = int.Parse(values[3]),
|
||||
Rotation = int.Parse(values[4]),
|
||||
MatchType = values[5]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return imageDatas;
|
||||
}
|
||||
|
||||
private static string GetFilename(string imagePath) =>
|
||||
Path.GetFileNameWithoutExtension(imagePath)
|
||||
.Replace("-small", "");
|
||||
}
|
||||
Reference in New Issue
Block a user