Skip to content

Commit 812c3cb

Browse files
committed
Preserve validated local dataset paths
1 parent 30bb682 commit 812c3cb

3 files changed

Lines changed: 7 additions & 17 deletions

File tree

src/PlateauResoniteLink/Application/Importing/PlateauImportRequestValidator.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -348,24 +348,14 @@ private static PlateauImportRequest NormalizeRawRequest(PlateauImportRequest req
348348
{
349349
Dataset = TrimToEmpty(request.Dataset),
350350
MeshCode = TrimToEmpty(request.MeshCode),
351-
CityGmlSource = NormalizeDatasetLocation(request.CityGmlSource),
352-
DemTextureSource = request.DemTextureSource is null ? null : NormalizeDatasetLocation(request.DemTextureSource),
351+
CityGmlSource = request.CityGmlSource,
352+
DemTextureSource = request.DemTextureSource,
353353
PackageNames = request.PackageNames is null
354354
? null
355355
: request.PackageNames.Select(static packageName => TrimToEmpty(packageName)).ToArray(),
356356
};
357357
}
358358

359-
private static DatasetLocation NormalizeDatasetLocation(DatasetLocation source)
360-
{
361-
return source switch
362-
{
363-
LocalDatasetLocation localSource => new LocalDatasetLocation(localSource.LocalSourcePath.Trim()),
364-
RemoteDatasetLocation remoteSource => remoteSource,
365-
_ => source,
366-
};
367-
}
368-
369359
private static Dictionary<string, IReadOnlySet<int>> NormalizePackageExclusionMap(
370360
IReadOnlyDictionary<string, IReadOnlySet<int>> exclusionsByPackage)
371361
{

src/PlateauResoniteLink/Application/Importing/ValidatedDatasetLocation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public ValidatedLocalDatasetLocation(string localSourcePath)
2222
: base(DatasetSourceKind.Local)
2323
{
2424
ArgumentException.ThrowIfNullOrWhiteSpace(localSourcePath);
25-
LocalSourcePath = localSourcePath.Trim();
25+
LocalSourcePath = localSourcePath;
2626
}
2727

2828
public string LocalSourcePath { get; }

tests/PlateauResoniteLink.Tests/Application/PlateauImportRequestValidatorTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void DatasetLocationFactoriesRequireSourcePayload()
1919
Assert.Throws<ArgumentNullException>(() => new ValidatedRemoteDatasetLocation(null!));
2020
Assert.Throws<ArgumentException>(() => new ValidatedRemoteDatasetLocation(new Uri("/dataset.zip", UriKind.Relative)));
2121
Assert.Throws<ArgumentException>(() => new ValidatedRemoteDatasetLocation(new Uri("ftp://example.invalid/dataset.zip")));
22-
Assert.Equal("C:/dataset", new ValidatedLocalDatasetLocation(" C:/dataset ").LocalSourcePath);
22+
Assert.Equal(" C:/dataset ", new ValidatedLocalDatasetLocation(" C:/dataset ").LocalSourcePath);
2323
}
2424

2525
[Fact]
@@ -137,7 +137,7 @@ public void ValidateRejectsLocalCityGmlSourceThatIsOnlyTerrainRaster()
137137
}
138138

139139
[Fact]
140-
public void TryNormalizeAndValidateTrimsAndNormalizesRequestData()
140+
public void TryNormalizeAndValidateNormalizesRequestData()
141141
{
142142
using TemporaryDirectory sourceRoot = new();
143143
string geoTiffPath = Path.Combine(sourceRoot.Path, "53394525.tif");
@@ -146,8 +146,8 @@ public void TryNormalizeAndValidateTrimsAndNormalizesRequestData()
146146
PlateauImportRequest request = new(
147147
Dataset: " tokyo23ku ",
148148
MeshCode: " 53394525 ",
149-
CityGmlSource: DatasetLocation.Local($" {sourceRoot.Path} "),
150-
DemTextureSource: DatasetLocation.Local($" {geoTiffPath} "),
149+
CityGmlSource: DatasetLocation.Local(sourceRoot.Path),
150+
DemTextureSource: DatasetLocation.Local(geoTiffPath),
151151
PackageNames: [" waterbody ", " tran "]);
152152

153153
bool success = PlateauImportRequestValidator.TryNormalizeAndValidate(

0 commit comments

Comments
 (0)