private void TestTrace()
        {
            SpatialTrace.Enable();

            SpatialTrace.TraceText("Simple geometries");
            SpatialTrace.Indent();

            SqlGeometry points = Sample_Points(4326);

            SpatialTrace.TraceGeometry(points, "Points");

            SqlGeometry poly = Sample_Polygon(4326);

            SpatialTrace.TraceGeometry(poly, "Polygon");

            SqlGeography geog = Sample_PolygonGeography();

            SpatialTrace.TraceGeometry(geog, "Polygon (geography)");

            SpatialTrace.Unindent();

            SpatialTrace.TraceText("Composite geometries");
            SpatialTrace.Indent();

            SpatialTrace.TraceGeometry(poly.STUnion(points), "poly.STUnion(points)");

            SpatialTrace.TraceGeometry(poly.STUnion(points).STConvexHull(), "poly.STUnion(points).STConvexHull()");

            SpatialTrace.Unindent();

            SpatialTrace.Disable();
        }
Пример #2
0
        static void TestWorld(bool useLabels = false, bool useIndents = false)
        {
            SpatialTrace.Enable();
            SpatialTrace.Clear();

            List <Country> v_countries = GetCountries();

            SpatialTrace.Enable();
            foreach (var countryByContinent in v_countries.GroupBy(p => p.Continent))
            {
                if (useIndents)
                {
                    SpatialTrace.Indent(countryByContinent.Key);
                }

                foreach (var country in countryByContinent)
                {
                    SpatialTrace.TraceGeometry(country.Geometry, country.Name, country.Name);
                }

                if (useIndents)
                {
                    SpatialTrace.Unindent();
                }
            }

            //SpatialTrace.ShowDialog();
        }
Пример #3
0
        private void SpatialTrace_Connexions(List <Troncon> connectedTroncons, KeyValuePair <int, TopoNode> topoNode)
        {
            SpatialTrace.Enable();
            SpatialTrace.Indent(connectedTroncons.Count.ToString() + " connections - node " + topoNode.Key.ToString());
            foreach (var trn in connectedTroncons)
            {
                SpatialTrace.TraceGeometry(trn.Geometry, trn.Id.ToString(), trn.Id.ToString());
            }

            foreach (var troncon in connectedTroncons)
            {
                foreach (var tronconOther in connectedTroncons.Where(t => t.Id != troncon.Id))
                {
                    var         angle           = Geometry.AngleBetweenLines(troncon.Geometry, tronconOther.Geometry);
                    SqlGeometry connectionPoint = troncon.Geometry.STIntersection(tronconOther.Geometry);

                    SqlGeometry segment1 = Geometry.FirstSegmentFrom(troncon.Geometry, connectionPoint);
                    SqlGeometry segment2 = Geometry.FirstSegmentFrom(tronconOther.Geometry, connectionPoint);
                    SpatialTrace.TraceGeometry(segment1.STUnion(segment2), $"{troncon.Id}<->{tronconOther.Id} - angle: {angle * 180 / Math.PI}", $"angle: {angle}");
                }
            }
            SpatialTrace.TraceGeometry(topoNode.Value.Geometry.STBuffer(50), "node " + topoNode.Value.Id.ToString(), "node " + topoNode.Value.Id.ToString());
            SpatialTrace.Unindent();
            SpatialTrace.Disable();
        }
        public void GetVisuCreteEtTalweg(BeanTopologieFacettes p_topologieFacettes, HashSet <enum_qualificationMorpho_arc> p_nePasAfficher = null)
        {
            Color v_couleur;

            SpatialTrace.Enable();

            // GetVisuTopologieFacettes(p_topologieFacettes,  false, false);

            //On actualise les arcs, pour contrôle
            foreach (string v_cleArc in  p_topologieFacettes.p12_arcsByCode.Keys)
            {
                p_topologieFacettes.p12_arcsByCode[v_cleArc].getQualifMorphoDeLArc();
                //FLabServices.createGeomorphoServices().SetLignesCretesEtTalwegByRefByArc(p_topologieFacettes, v_cleArc);
            }

            //
            if (!p_nePasAfficher.Contains(enum_qualificationMorpho_arc.crete))
            {
                SpatialTrace.Indent("Cretes");
                List <BeanArc_internal> v_arcsCretes;
                v_arcsCretes = p_topologieFacettes.p12_arcsByCode.Values.Where(c => c.getQualifMorphoDeLArc() == enum_qualificationMorpho_arc.crete).ToList();
                v_couleur    = Color.Red;
                foreach (BeanArc_internal v_arc in v_arcsCretes)
                {
                    GetVisuArc2D(v_arc, "Crete", v_couleur);
                }
            }


            if (!p_nePasAfficher.Contains(enum_qualificationMorpho_arc.talweg))
            {
                SpatialTrace.Unindent();
                SpatialTrace.Indent("Talwegs");
                List <BeanArc_internal> v_arcsTalweg;
                v_arcsTalweg = p_topologieFacettes.p12_arcsByCode.Values.Where(c => c.getQualifMorphoDeLArc() == enum_qualificationMorpho_arc.talweg).ToList();
                v_couleur    = Color.Blue;
                foreach (BeanArc_internal v_arc in v_arcsTalweg)
                {
                    GetVisuArc2D(v_arc, "Talweg", v_couleur);
                }
            }


            if (!p_nePasAfficher.Contains(enum_qualificationMorpho_arc.autre))
            {
                SpatialTrace.Unindent();
                SpatialTrace.Indent("Autres");
                List <BeanArc_internal> v_arcsAutres;
                v_arcsAutres = p_topologieFacettes.p12_arcsByCode.Values.Where(c => c.getQualifMorphoDeLArc() == enum_qualificationMorpho_arc.autre).ToList();
                v_couleur    = Color.LightGray;
                foreach (BeanArc_internal v_arc in v_arcsAutres)
                {
                    GetVisuArc2D(v_arc, "Autre", v_couleur);
                }
            }
            SpatialTrace.Unindent();
            SpatialTrace.Disable();
        }
        private void TestCommunes()
        {
            List <SqlGeometry> geom = new List <SqlGeometry>();

            SpatialTrace.Enable();
            SpatialTrace.TraceText("Open DB connection");
            SpatialTrace.Indent();

            using (SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=SampleSpatialData;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False"))
            {
                con.Open();

                using (SqlCommand com = new SqlCommand("SELECT geom, INSEE_COM + ' ' + NOM_COM FROM dbo.COMMUNE --WHERE geom2154.STNumInteriorRing() > 0", con))
                {
                    int i = 0;

                    using (SqlDataReader reader = com.ExecuteReader())
                    {
                        SpatialTrace.TraceText("Reading results DB\t\t connection");
                        SpatialTrace.Indent();
                        while (reader.Read())
                        {
                            i++;

                            // workaround https://msdn.microsoft.com/fr-fr/library/ms143179(v=sql.120).aspx
                            // In version 11.0 only
                            SqlGeometry curGeom = SqlGeometry.Deserialize(reader.GetSqlBytes(0));

                            //// In version 10.0 or 11.0
                            //curGeom = new SqlGeometry();
                            //curGeom.Read(new BinaryReader(reader.GetSqlBytes(0).Stream));


                            geom.Add(curGeom);

                            SpatialTrace.SetFillColor(GetRandomColor());
                            SpatialTrace.SetLineColor(GetRandomColor());
                            SpatialTrace.SetLineWidth(GetRandomStrokeWidth());
                            SpatialTrace.TraceGeometry(curGeom, reader[1].ToString());
                        }

                        SpatialTrace.Unindent();
                    }
                }
            }

            SpatialTrace.Unindent();

            ((ISpatialViewer)viewer).SetGeometry(SqlGeomStyledFactory.Create(geom, null, null, null, "Sample"));
        }
Пример #6
0
        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();
        }
Пример #7
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();
        }