添加部分功能,以及等高线模型
This commit is contained in:
1 parent
6d4d098681
commit
4f5beb5109
19 files changed
+1200
-20
No files matched your search
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using EarthModelStudio.ModelSdk;
|
||||
|
||||
namespace NeoRF.ContourMap;
|
||||
|
||||
/// <summary>等高线模型入口(清单里的 type 指向这里)。</summary>
|
||||
public sealed class ContourMapFactory : IModelFactory
|
||||
{
|
||||
public int ApiVersion => 1;
|
||||
public IModelRuntime Create() => new ContourMapRuntime();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等高线模型运行时。
|
||||
/// 依据人教版七年级上册「地形图的判读」:海拔与相对高度、等高线与等高距、
|
||||
/// 山峰/山脊/山谷/鞍部/陡崖的判读、坡度陡缓与等高线疏密的关系。
|
||||
/// </summary>
|
||||
public sealed class ContourMapRuntime : IModelRuntime
|
||||
{
|
||||
private TerrainField? _field;
|
||||
private Dictionary<string, string>? _texts;
|
||||
|
||||
public void Prepare(IModelContext context)
|
||||
{
|
||||
context.ReportProgress(0.15, "生成地形高度场");
|
||||
_field = new TerrainField(192);
|
||||
|
||||
context.ReportProgress(0.70, "提取等高线");
|
||||
_texts = LoadTexts(context.DataDirectory, context.Language);
|
||||
|
||||
context.ReportProgress(0.92, "准备界面");
|
||||
context.Log($"[contour-map] 地形 {_field.Size}×{_field.Size}," +
|
||||
$"海拔 {_field.MinHeight:0}~{_field.MaxHeight:0} m,等高距 {_field.Interval:0} m");
|
||||
}
|
||||
|
||||
public Control CreateView(IModelContext context)
|
||||
{
|
||||
_field ??= new TerrainField(192);
|
||||
_texts ??= LoadTexts(context.DataDirectory, context.Language);
|
||||
return new ContourPage(_field, _texts).Build();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_field = null;
|
||||
_texts = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> LoadTexts(string dataDir, string language)
|
||||
{
|
||||
var map = new Dictionary<string, string>(DefaultTexts.Zh);
|
||||
var isEn = language.StartsWith("en", StringComparison.OrdinalIgnoreCase);
|
||||
if (isEn) foreach (var kv in DefaultTexts.En) map[kv.Key] = kv.Value;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user