Skip to content

Commit

Permalink
Dependencies is counter productive
Browse files Browse the repository at this point in the history
  • Loading branch information
jetelain committed Aug 23, 2024
1 parent 7df46e4 commit a1ec325
Show file tree
Hide file tree
Showing 27 changed files with 6 additions and 145 deletions.
5 changes: 0 additions & 5 deletions GameRealisticMap/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ private Task<T> CreateDataTask<T>(IProgressScope? parentScope) where T : class
var builder = catalog.Get<T>();
return Task.Run(async () =>
{
var tasks = builder.Dependencies.Select(d => d.PreAcquire(this, parentScope)).ToArray();
if (tasks.Length > 0)
{
await Task.WhenAll(tasks).ConfigureAwait(false);
}
using (var scope = (parentScope ?? rootScope).CreateScope(builder.GetType().Name.Replace("Builder", "")))
{
if (builder is IDataBuilderAsync<T> asyncBuilder)
Expand Down
8 changes: 0 additions & 8 deletions GameRealisticMap/Conditions/ConditionEvaluatorBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ namespace GameRealisticMap.Conditions
{
internal class ConditionEvaluatorBuilder : IDataBuilderAsync<ConditionEvaluator>
{
public IEnumerable<IDataDependency> Dependencies => [
new DataDependency<CategoryAreaData>(),
new DataDependency<CitiesData>(),
new DataDependency<ElevationData>(),
new DataDependency<OceanData>(),
new DataDependency<RoadsData>()
];

public Task<ConditionEvaluator> BuildAsync(IBuildContext context, IProgressScope scope)
{
return ConditionEvaluator.CreateAsync(context);
Expand Down
14 changes: 0 additions & 14 deletions GameRealisticMap/DataDependency.cs

This file was deleted.

8 changes: 0 additions & 8 deletions GameRealisticMap/ElevationModel/ElevationWithLakesBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ public ElevationWithLakesBuilder()
this.processors = new IElevationProcessorStage1[] { new AerowaysElevationProcessor() };
}

public IEnumerable<IDataDependency> Dependencies => [
new DataDependency<RawElevationData>(),
new DataDependency<LakesData>(),
new DataDependency<BuildingsData>(),
new DataDependency<RoadsData>(),
new DataDependency<RailwaysData>(),
new DataDependency<AerowaysData>()];

public ElevationWithLakesData Build(IBuildContext context, IProgressScope scope)
{
var raw = context.GetData<RawElevationData>();
Expand Down
2 changes: 0 additions & 2 deletions GameRealisticMap/IDataBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ namespace GameRealisticMap
{
public interface IDataBuilder<out T> where T : class
{
IEnumerable<IDataDependency> Dependencies => Enumerable.Empty<IDataDependency>();

T Build(IBuildContext context, IProgressScope scope);
}
}
11 changes: 0 additions & 11 deletions GameRealisticMap/IDataDependency.cs

This file was deleted.

6 changes: 0 additions & 6 deletions GameRealisticMap/ManMade/Farmlands/FarmlandsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
.Concat(context.GetData<ForestData>().Polygons);
}

public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<VineyardData>(),
new DataDependency<OrchardData>(),
new DataDependency<ForestData>()
]);

protected override List<TerrainPolygon> MergeIfRequired(List<TerrainPolygon> polygons, IProgressScope scope)
{
return polygons; // Do not merge, to be able to place objects at edges and to be able to post-process satellite image
Expand Down
5 changes: 0 additions & 5 deletions GameRealisticMap/ManMade/Farmlands/OrchardBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
.Concat(context.GetData<ForestData>().Polygons);
}

public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<VineyardData>(),
new DataDependency<ForestData>()
]);

protected override List<TerrainPolygon> MergeIfRequired(List<TerrainPolygon> polygons, IProgressScope scope)
{
return polygons; // Do not merge, to be able to place objects at edges and to be able to post-process satellite image
Expand Down
2 changes: 0 additions & 2 deletions GameRealisticMap/ManMade/Farmlands/VineyardBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
.Concat(context.GetData<ForestData>().Polygons);
}

public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([new DataDependency<ForestData>()]);

protected override List<TerrainPolygon> MergeIfRequired(List<TerrainPolygon> polygons, IProgressScope scope)
{
return polygons; // Do not merge, to be able to place objects at edges and to be able to post-process satellite image
Expand Down
1 change: 1 addition & 0 deletions GameRealisticMap/ManMade/Objects/OrientedObjectBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using GameRealisticMap.Algorithms;
using GameRealisticMap.Geometries;
using GameRealisticMap.ManMade.Railways;
using GameRealisticMap.ManMade.Roads;
using GameRealisticMap.Osm;
using OsmSharp.Geo;
Expand Down
5 changes: 0 additions & 5 deletions GameRealisticMap/ManMade/Surfaces/AsphaltBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
return context.GetData<ForestData>().Polygons;
}

public override IEnumerable<IDataDependency> Dependencies => [
new DataDependency<ForestData>(),
new DataDependency<AerowaysData>()
];

public override AsphaltData Build(IBuildContext context, IProgressScope scope)
{
return CreateWrapper(GetPolygons(context,
Expand Down
7 changes: 0 additions & 7 deletions GameRealisticMap/Nature/BasicBuilderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
.Concat(lakes.Lakes.Select(l => l.TerrainPolygon));
}

public virtual IEnumerable<IDataDependency> Dependencies => [
new DataDependency<RoadsData>(),
new DataDependency<RailwaysData>(),
new DataDependency<ElevationWithLakesData>(),
new DataDependency<BuildingsData>()
];

protected abstract T CreateWrapper(List<TerrainPolygon> polygons);

public virtual T Build(IBuildContext context, IProgressScope scope)
Expand Down
17 changes: 0 additions & 17 deletions GameRealisticMap/Nature/BasicRadialBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,6 @@ protected virtual IEnumerable<TerrainPolygon> GetPriority(IBuildContext context)
.Concat(context.GetData<VineyardData>().Polygons);
}

public virtual IEnumerable<IDataDependency> Dependencies => [
new DataDependency<BuildingsData>(),
new DataDependency<RoadsData>(),
new DataDependency<RailwaysData>(),
new DataDependency<ElevationWithLakesData>(),
new DataDependency<ForestData>(),
new DataDependency<ScrubData>(),
new DataDependency<RocksData>(),
new DataDependency<MeadowsData>(),
new DataDependency<FarmlandsData>(),
new DataDependency<CategoryAreaData>(),
new DataDependency<OceanData>(),
new DataDependency<OrchardData>(),
new DataDependency<VineyardData>(),
new DataDependency<TSource>()
];

public TEdge Build(IBuildContext context, IProgressScope scope)
{
var forest = context.GetData<TSource>();
Expand Down
2 changes: 0 additions & 2 deletions GameRealisticMap/Nature/Forests/ForestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
return base.GetPriority(context)
.Concat(cutlines.Polygons);
}

public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([new DataDependency<CutlinesData>()]);
}
}
6 changes: 0 additions & 6 deletions GameRealisticMap/Nature/Forests/ForestEdgeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ namespace GameRealisticMap.Nature.Forests
{
internal class ForestEdgeBuilder : IDataBuilder<ForestEdgeData>
{
public IEnumerable<IDataDependency> Dependencies => [
new DataDependency<RoadsData>(),
new DataDependency<ForestData>(),
new DataDependency<BuildingsData>()
];

public ForestEdgeData Build(IBuildContext context, IProgressScope scope)
{
var roads = context.GetData<RoadsData>().Roads;
Expand Down
3 changes: 0 additions & 3 deletions GameRealisticMap/Nature/Forests/ForestRadialBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
return base.GetPriority(context)
.Concat(cutlines.Polygons);
}
public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<CutlinesData>()
]);

protected override ForestRadialData CreateWrapper(List<TerrainPolygon> polygons)
{
Expand Down
4 changes: 0 additions & 4 deletions GameRealisticMap/Nature/Lakes/LakesBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,5 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
.SelectMany(s => s.Path.ToTerrainPolygon(s.Width + embankmentMargin))
.ToList();
}

public override IEnumerable<IDataDependency> Dependencies => [
new DataDependency<RoadsData>()
];
}
}
5 changes: 0 additions & 5 deletions GameRealisticMap/Nature/RockAreas/RocksBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,5 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
.Concat(context.GetData<ForestData>().Polygons)
.Concat(context.GetData<ScrubData>().Polygons);
}

public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<ForestData>(),
new DataDependency<ScrubData>()
]);
}
}
7 changes: 0 additions & 7 deletions GameRealisticMap/Nature/RockAreas/ScreeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,5 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
.Concat(context.GetData<RocksData>().Polygons)
.Concat(context.GetData<ScrubData>().Polygons);
}

public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<ForestData>(),
new DataDependency<RocksData>(),
new DataDependency<ScrubData>()
]);

}
}
4 changes: 0 additions & 4 deletions GameRealisticMap/Nature/Scrubs/ScrubBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,5 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
return base.GetPriority(context)
.Concat(context.GetData<ForestData>().Polygons);
}

public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<ForestData>()
]);
}
}
4 changes: 0 additions & 4 deletions GameRealisticMap/Nature/Scrubs/ScrubRadialBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
.Concat(forestEdge.Polygons);
}

public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<ForestRadialData>()
]);

protected override ScrubRadialData CreateWrapper(List<TerrainPolygon> polygons)
{
return new ScrubRadialData(polygons);
Expand Down
3 changes: 0 additions & 3 deletions GameRealisticMap/Nature/Surfaces/GrassBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
return base.GetPriority(context)
.Concat(context.GetData<ForestData>().Polygons);
}
public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<ForestData>()
]);

public override GrassData Build(IBuildContext context, IProgressScope scope)
{
Expand Down
7 changes: 0 additions & 7 deletions GameRealisticMap/Nature/Surfaces/IceSurfaceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,5 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
.Concat(context.GetData<ScrubData>().Polygons)
.Concat(context.GetData<ScreeData>().Polygons);
}

public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<ForestData>(),
new DataDependency<RocksData>(),
new DataDependency<ScrubData>(),
new DataDependency<ScreeData>()
]);
}
}
3 changes: 0 additions & 3 deletions GameRealisticMap/Nature/Surfaces/MeadowsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,5 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
return base.GetPriority(context)
.Concat(context.GetData<ForestData>().Polygons);
}
public override IEnumerable<IDataDependency> Dependencies => base.Dependencies.Concat([
new DataDependency<ForestData>()
]);
}
}
3 changes: 0 additions & 3 deletions GameRealisticMap/Nature/Surfaces/SandSurfacesBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ protected override IEnumerable<TerrainPolygon> GetPriority(IBuildContext context
{
return Enumerable.Empty<TerrainPolygon>();
}

public override IEnumerable<IDataDependency> Dependencies => Enumerable.Empty<IDataDependency>();

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using GameRealisticMap.Geometries;
using GameRealisticMap.ManMade;
using GameRealisticMap.ManMade.Roads;
using GameRealisticMap.Nature.Forests;
using GameRealisticMap.Nature.Lakes;
using GeoAPI.Geometries;
using OsmSharp;
Expand Down
8 changes: 4 additions & 4 deletions GameRealisticMap/Satellite/RawSatelliteImageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace GameRealisticMap.Satellite
{
internal class RawSatelliteImageBuilder : IDataBuilder<RawSatelliteImageData>, IDataSerializer<RawSatelliteImageData>
internal class RawSatelliteImageBuilder : IDataBuilderAsync<RawSatelliteImageData>, IDataSerializer<RawSatelliteImageData>
{
private readonly ISourceLocations sources;

Expand All @@ -19,7 +19,7 @@ public RawSatelliteImageBuilder(ISourceLocations sources)
this.sources = sources;
}

public RawSatelliteImageData Build(IBuildContext context, IProgressScope scope)
public async Task<RawSatelliteImageData> BuildAsync(IBuildContext context, IProgressScope scope)
{
//Image<Rgb24> image;

Expand All @@ -37,8 +37,8 @@ public RawSatelliteImageData Build(IBuildContext context, IProgressScope scope)
using var src = new S2Cloudless(report2, sources);
foreach (var part in himage.Parts)
{
LoadPart(context, totalSize, part, report2, src).Wait();
himage.OffloadAsync().Wait();
await LoadPart(context, totalSize, part, report2, src).ConfigureAwait(false);
await himage.OffloadAsync().ConfigureAwait(false);
}
}

Expand Down

0 comments on commit a1ec325

Please sign in to comment.