Esempio n. 1
0
        private static void Main()
        {
            // reading of channels tree from file:
            var channelsTree = CgInteraction.ReadChannelsTreeFromCg(Dir.Data("channels.cg"));

            // calculating stats:
            var floodMap   = GrdInteraction.ReadGridMapFromGrd(Dir.Data("only_territory_flood_frequency0.grd"));
            var typeUseMap = GrdInteraction.ReadGridMapFromGrd(Dir.Data("TypeUseWithNonCadastr.grd"));
            var hozValues  = new HashSet <double> {
                37, 38, 39, 43, 44, 45
            };
            var socValues = new HashSet <double> {
                58, 61, 63, 66, 171, 186, 195, 203, 207
            };
            var nonCadastrId = 8888d;
            var r            = 10;
            var stats        = StatsAggregation.GetStats(channelsTree, floodMap, typeUseMap, hozValues, socValues, nonCadastrId, r);


            /* Usage of donors-acceptors algorithm */

            // read flood series for Q=23 and t=[20, 39]:
            var floodSeries = GrdInteraction.ReadFloodSeriesFromZip(Dir.Data("flood/23.zip"), 20, 39);

            // read eco targets map
            var ecoTargetMap = GrdInteraction.ReadGridMapFromGrd(Dir.Data("frequencies/add_frequency_from_0,65_to_0,85.grd"));

            // initialization of algo:
            var donorsAcceptors = new DonorsAcceptors(
                DonorsAcceptors.RatingStrategy.TargetCount, channelsTree, ecoTargetMap, floodSeries);

            // on each iteration call method Run with CofinanceInfo:
            var cofinanceInfo = new CofinanceInfo(0, null);
            var projectPlan   = donorsAcceptors.Run(cofinanceInfo);
        }
Esempio n. 2
0
 static void Main(string[] args)
 {
     Parser.Default.ParseArguments <Options>(args).WithParsed(o =>
     {
         var channels    = CgInteraction.ReadChannelsTreeFromCg(o.ChannelsGraphFile);
         var floodSeries = FloodseriesZip.Read(o.FloodSeriesFile, o.StartDay, o.EndDay);
         Dir.RequireClearDirectory(o.OutputDir);
         foreach (var day in floodSeries.Days)
         {
             var bitmap = DrawDirectionsBitmap(channels, day.VxMap, day.VyMap);
             bitmap.Save($"{o.OutputDir}/{day.T}.png");
         }
     });
     System.Console.WriteLine("Press any key to continue...");
     System.Console.ReadKey();
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var channels = CgInteraction.ReadChannelsTreeFromCg(Dir.Data("channels_all.cg"));

            RestoreHoles(channels);
            RestoreChildren(channels);
            CheckChannels(channels);
            CgInteraction.WriteChannelsTreeToCg(Dir.Data("channels.cg"), channels);
            BinarizeChannels(channels);
            var bitmap = Drawing.DrawBitmap(944, 944, g =>
            {
                Drawing.DrawChannels(g, channels.GetAllChannels(), new SolidBrush(Color.Black), true);
            });

            bitmap.Save(Dir.Data("restoration_debug.png"));
            Console.WriteLine(channels.GetAllChannels().Count());
            CgInteraction.WriteChannelsTreeToCg(Dir.Data("channels_binarized.cg"), channels);
        }
Esempio n. 4
0
        private static void Run(Options options)
        {
            var relief      = Grd.Read(options.ReliefFile);
            var targetMap   = Grd.Read(options.TargetMapFile);
            var floodSeries = FloodseriesZip.Read(options.FloodSeriesFile, options.StartDay, options.EndDay);
            var channels    = CgInteraction.ReadChannelsTreeFromCg(options.ChannelsGraphFile);

            var drawingsDir = $"{options.OutputDir}/vis";
            var mapsDir     = $"{options.OutputDir}/maps";

            Dir.RequireClearDirectory(drawingsDir);
            Dir.RequireClearDirectory(mapsDir);

            var floodMap = DrawFloodMapWithTargets(floodSeries, targetMap, options.TargetValue);

            floodMap.Save($"{options.OutputDir}/floodmap.png");

            var strategies = new[]
Esempio n. 5
0
        private static void Run(Options options)
        {
            var graph = CgInteraction.ReadChannelsTreeFromCg(options.CgPath);

            var contrastColors = new[]
            {
                Color.DeepPink,
                Color.LightGreen,
                Color.Black,
                Color.Violet,
                Color.Blue,
                Color.Cyan,
                Color.Magenta,
                Color.Aqua,
                Color.Azure,
                Color.Coral,
                Color.DarkSalmon,
                Color.Firebrick,
                Color.Green,
                Color.Red,
                Color.LightGreen,
                Color.Black,
                Color.Violet,
                Color.DeepSkyBlue,
                Color.DodgerBlue
            };

            Console.WriteLine($"Components count: {graph.Root.Connecions.Count}");

            var bitmap = Drawing.DrawBitmap(944, 944, g =>
            {
                foreach ((var color, var baseChannel) in graph.Root.Connecions.Zip(
                             contrastColors, (color, channel) => (channel, color)))
                {
                    var channels = new List <Channel>();
                    graph.VisitChannelsDepthFromTop(baseChannel, (channel, depth) =>
                    {
                        channels.Add(channel);
                    });
                    Drawing.DrawChannels(g, channels, new SolidBrush(color));
                }
            });