コード例 #1
0
ファイル: Program.cs プロジェクト: CorselloResearch/DEM.Net
        static void SpatialTrace_GeometryWithDEMGrid(ElevationService elevationService, IGeoTiffService geoTiffService, string wktBbox, DEMDataSet dataSet)
        {
            SpatialTrace.Enable();
            DEM.Net.Lib.BoundingBox bbox = null;
            if (wktBbox != null)
            {
                SqlGeometry geom = GeometryService.ParseWKTAsGeometry(wktBbox);
                SpatialTrace.TraceGeometry(geom, "Bbox");
                bbox = geom.ToGeography().STBuffer(60).GetBoundingBox();

                //SpatialTrace.Indent("Line Segments");
                //int i = 0;
                //foreach (var seg in geom.Segments())
                //{
                //	i++;
                //	Color color = (i % 2 == 0) ? Colors.Blue : Colors.Red;
                //	SpatialTrace.SetLineColor(color);
                //	SpatialTrace.TraceGeometry(seg, "Seg" + i, "Seg" + i);
                //}

                SpatialTrace.Unindent();
            }



            Dictionary <string, DemFileReport> tiles = geoTiffService.GenerateReport(dataSet, bbox);

            SpatialTrace.Indent("DEM tiles");
            SpatialTrace.SetLineColor(Colors.Black);
            foreach (var tile in tiles)
            {
                SpatialTrace.SetFillColor(tile.Value.IsExistingLocally ? Color.FromArgb(128, 0, 255, 0) : Color.FromArgb(128, 255, 0, 0));

                SqlGeometry tileBbox = tile.Value.Source.BBox.AsGeomety();
                SpatialTrace.TraceGeometry(tileBbox, $"{tile.ToString()}");
            }
            SpatialTrace.Unindent();

            // View spatial trace in bin\debug with spatial trace viewer
            SpatialTrace.ShowDialog();
            SpatialTrace.Disable();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: CorselloResearch/DEM.Net
        static void LineDEMTest(ElevationService elevationService, DEMDataSet dataSet, string wkt, int numSamples)
        {
            Stopwatch sw = Stopwatch.StartNew();

            elevationService.DownloadMissingFiles(dataSet, GetBoundingBox(wkt));

            var lineElevationData         = elevationService.GetLineGeometryElevation(wkt, dataSet, InterpolationMode.Bilinear);
            ElevationMetrics metrics      = GeometryService.ComputeMetrics(ref lineElevationData);
            var lineElevationData_Reduced = DouglasPeucker.DouglasPeuckerReduction(lineElevationData, (metrics.MaxElevation - metrics.MinElevation) / numSamples);

            sw.Stop();
            Console.WriteLine($"LineDEMTest performed in {sw.Elapsed:g}.");

            SpatialTrace.Enable();
            SpatialTrace.Clear();
            SpatialTraceLine(lineElevationData, $"Full resolution line ({lineElevationData.Count} points)");


            SpatialTraceLine(lineElevationData_Reduced, $"Reduced line ({lineElevationData_Reduced.Count} points)");

            SpatialTrace.ShowDialog();
        }
コード例 #3
0
        public void ShowStopAreasOnMap(SncfRepository _sncfRepo, IGNRepository _ignRepo, string wkt = null)
        {
            SqlGeography            polyQuery = wkt == null ? null : SqlGeography.STGeomFromText(new SqlChars(new SqlString(wkt)), 4326);
            Dictionary <int, Noeud> noeuds    = _ignRepo.GetAllNoeuds_LatLon(polyQuery);


            Dictionary <string, SqlGeography> geogListStopAreas = new Dictionary <string, SqlGeography>();
            IEnumerable <StopArea>            stopAreas         = _sncfRepo.StopAreas;

            if (polyQuery != null)
            {
                stopAreas = stopAreas.Where(s => FromCoordToGeography(s.Coord).STIntersects(polyQuery).IsTrue);
            }
            foreach (var sp in stopAreas)
            {
                geogListStopAreas.Add(sp.Name + " " + sp.Id, FromCoordToGeography(sp.Coord));
            }
            Dictionary <string, SqlGeography> geogListStopPoints = new Dictionary <string, SqlGeography>();
            IEnumerable <StopPoint>           stopPoints         = _sncfRepo.StopPoints;

            if (polyQuery != null)
            {
                stopPoints = stopPoints.Where(s => FromCoordToGeography(s.Coord).STIntersects(polyQuery).IsTrue);
            }
            foreach (var sp in stopPoints)
            {
                geogListStopPoints.Add(sp.Name + " " + sp.Id, FromCoordToGeography(sp.Coord));
            }


            SpatialTrace.Enable();
            int i = 0;

            foreach (var g in noeuds)
            {
                if (i % 2 == 0)
                {
                    SpatialTrace.SetLineColor(Colors.Blue);
                }
                else
                {
                    SpatialTrace.SetLineColor(Colors.Red);
                }
                SpatialTrace.TraceGeometry(g.Value.Geometry, $"{g.Value.Id}: {g.Value.Toponyme}", $"{g.Value.Id}: {g.Value.Toponyme}");
                i++;
            }


            //SpatialTrace.SetLineColor(Colors.Red);
            //SpatialTrace.TraceGeometry(geogList120, "Lignes 120", "Lignes 120");


            SpatialTrace.Indent("Stop areas");
            SpatialTrace.SetFillColor(Colors.Green);
            foreach (var kvp in geogListStopAreas)
            {
                SpatialTrace.TraceGeometry(kvp.Value, kvp.Key, kvp.Key);
            }

            SpatialTrace.Unindent();
            SpatialTrace.Indent("Stop points");
            SpatialTrace.SetFillColor(Colors.Violet);
            foreach (var kvp in geogListStopPoints)
            {
                SpatialTrace.TraceGeometry(kvp.Value, kvp.Key, kvp.Key);
            }
            SpatialTrace.Unindent();

            SpatialTrace.ShowDialog();
            SpatialTrace.Disable();
        }