Beispiel #1
0
        internal List <BeanPoint_internal> GetPointsTestsXY_RepartitionReguliere(BeanParamGenerationAutoDePointsTests p_paramGenerationPointsTest)
        {
            List <BeanPoint_internal> v_pointsToTest = new List <BeanPoint_internal>();

            try
            {
                BeanPoint_internal v_point;
                double[]           v_coord;

                double v_coordX = p_paramGenerationPointsTest.p11_pointBasGaucheX;
                double v_coordY = p_paramGenerationPointsTest.p12_pointBasGaucheY;
                while (v_coordX < p_paramGenerationPointsTest.p13_pointHautDroitX)
                {
                    v_coordY = p_paramGenerationPointsTest.p12_pointBasGaucheY;
                    while (v_coordY < p_paramGenerationPointsTest.p14_pointHautDroitY)
                    {
                        v_coord    = new double[3];
                        v_coord[0] = v_coordX;
                        v_coord[1] = v_coordY;
                        v_point    = new BeanPoint_internal(v_coord, p_paramGenerationPointsTest.p10_srid);
                        v_pointsToTest.Add(v_point);
                        //
                        v_coordY += p_paramGenerationPointsTest.p32_pasEntrePointsEnM;
                    }
                    v_coordX += p_paramGenerationPointsTest.p32_pasEntrePointsEnM;
                    v_coordY  = p_paramGenerationPointsTest.p12_pointBasGaucheY;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(v_pointsToTest);
        }
Beispiel #2
0
        public void GetVisuPoint2D(BeanPoint_internal p_point, string p_label, Color p_couleurCourante, int p_taillePoint)
        {
            Color param_couleurContour = Color.FromArgb(125, 125, 125);

            if (p_taillePoint <= 0)
            {
                p_taillePoint = 1;
            }
            //
            //SpatialTrace.Enable();
            string   v_message = "";
            Geometry v_pointGeom;

            //SpatialTrace.SetFillColor(p_couleurCourante);
            //SpatialTrace.SetLineColor(param_couleurContour);

            v_message = "Pt " + p_point.p00_id + " (" + p_point.p10_coord[2] + " m)";
            if (p_label != "")
            {
                v_message += " " + p_label;
            }
            v_pointGeom = FLabServices.createUtilitaires().ConstructPoint(p_point.p10_coord[0], p_point.p10_coord[1], p_point.p11_srid).Buffer(p_taillePoint);
            //SpatialTrace.TraceGeometry(v_pointGeom, v_message, v_message);

            //SpatialTrace.Disable();
        }
Beispiel #3
0
        public void TestChangementReferentiel2D(IEnumerable <BeanPoint_internal> p_points, double[] p_vecteurDeDecalage)
        {
            Color  v_couleurObjet;
            string v_label;

            //POINTS REF
            double[]           v_coordCentroide = FServicesApplicatifs.createCalculServicesMedium_testDivers().GetCentroide(p_points);
            BeanPoint_internal v_centroide      = new BeanPoint_internal(v_coordCentroide, 2154);

            //
            double[] p_coordPointX = new double[3];
            p_coordPointX[0] = v_coordCentroide[0] + p_vecteurDeDecalage[0];
            p_coordPointX[1] = v_coordCentroide[1] + p_vecteurDeDecalage[1];
            p_coordPointX[2] = 0;
            BeanPoint_internal p_pointX = new BeanPoint_internal(p_coordPointX, 2154);

            //VISU POINTS REF
            v_couleurObjet = Color.FromArgb(255, 0, 0, 255);
            FVisualisationServices.createVisualisationSpatialTraceServices().GetVisuPoint2D(v_centroide, "Pt0", v_couleurObjet, 20);
            v_couleurObjet = Color.FromArgb(255, 0, 255, 0);
            FVisualisationServices.createVisualisationSpatialTraceServices().GetVisuPoint2D(p_pointX, "Pt1", v_couleurObjet, 20);
            //FIN VISU POINTS REF



            Dictionary <int, double[]> v_coordDansRef;

            v_coordDansRef = FServicesApplicatifs.createCalculServicesMedium_testDivers().GetCoordonneesDansNewReferentiel2D(p_points, v_coordCentroide, p_coordPointX, null);



            Dictionary <int, BeanPoint_internal> v_dicoPoints = p_points.ToDictionary(c => c.p00_id, c => c);

            //VISU COORD
            int param_arrondi = 2;

            v_couleurObjet = Color.FromArgb(255, 0, 0, 255);
            List <int> v_idPointsOrdonnes = v_coordDansRef.OrderBy(c => c.Value[1]).Select(c => c.Key).ToList();

            foreach (int v_id in v_idPointsOrdonnes)
            {
                v_label = "Pt: " + v_id + " => " + Math.Round(v_coordDansRef[v_id][0], param_arrondi) + " / " + Math.Round(v_coordDansRef[v_id][1], param_arrondi);
                FVisualisationServices.createVisualisationSpatialTraceServices().GetVisuPoint2D(v_dicoPoints[v_id], v_label, v_couleurObjet, 10);
            }
            FVisualisationServices.createVisualisationSpatialTraceServices().AfficheVisu();
            //FIN VISU COORD
        }
Beispiel #4
0
        internal List <BeanPoint_internal> GetPointsTestsXY_RepartitionUniforme(BeanParamGenerationAutoDePointsTests p_paramGenerationPointsTest)
        {
            List <BeanPoint_internal> v_pointsToTest = new List <BeanPoint_internal>();

            try
            {
                Random   v_random = new Random(p_paramGenerationPointsTest.p32_seed);
                double[] v_coord;
                //[Attention: nécessité de passer en int)
                int v_minX = Convert.ToInt32(Math.Round(p_paramGenerationPointsTest.p11_pointBasGaucheX, 0));
                int v_maxX = Convert.ToInt32(Math.Round(p_paramGenerationPointsTest.p13_pointHautDroitX, 0));
                int v_minY = Convert.ToInt32(Math.Round(p_paramGenerationPointsTest.p12_pointBasGaucheY, 0));
                int v_maxY = Convert.ToInt32(Math.Round(p_paramGenerationPointsTest.p14_pointHautDroitY, 0));
                //
                HashSet <string> p_codes = new HashSet <string>();
                string           p_code;
                int v_no = 0;
                for (v_no = 1; v_no <= p_paramGenerationPointsTest.p31_nbrePoints;)
                {
                    v_coord    = new double[3];
                    v_coord[0] = v_random.Next(v_minX, v_maxX);
                    v_coord[1] = v_random.Next(v_minY, v_maxY);
                    v_coord[2] = 0;
                    //
                    BeanPoint_internal v_point = new BeanPoint_internal(v_coord, p_paramGenerationPointsTest.p10_srid);
                    // p_code = FLabServices.createUtilitaires().GethCodeGeogPoint(v_coord);
                    p_code = FLabServices.createUtilitaires().GetHCodeGeogPoint(v_coord);
                    //(On évite les doublons)
                    if (!p_codes.Contains(p_code))
                    {
                        p_codes.Add(p_code);
                        v_pointsToTest.Add(v_point);
                        v_no++;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(v_pointsToTest);
        }
Beispiel #5
0
        public BeanPoint_internal GetPointInternalFromGeoPoint(GeoPoint p_geoPoint, int p_srid)
        {
            BeanPoint_internal v_ptInternal = new BeanPoint_internal(p_geoPoint.Longitude, p_geoPoint.Latitude, p_geoPoint.Elevation.GetValueOrDefault(0), p_srid);

            return(v_ptInternal);
        }
Beispiel #6
0
        public BeanTopologieFacettes GetBeanTopologieByVoronoiGraph(VoronoiGraph p_voronoiGraph, BeanAlimentationVoronoi p_beanAlimentationVoronoi)
        {
            BeanTopologieFacettes v_topologie = new BeanTopologieFacettes();

            try
            {
                List <BeanArc_internal> v_arcsVoronoi = new List <BeanArc_internal>();
                Dictionary <string, BeanArc_internal> v_arcsParHCode = new Dictionary <string, BeanArc_internal>();
                int v_srid = p_beanAlimentationVoronoi.p11_srid;
                //
                Dictionary <string, BeanPoint_internal> v_pointsDesArcsByCode = new Dictionary <string, BeanPoint_internal>();
                Dictionary <int, BeanArc_internal>      v_arcs      = new Dictionary <int, BeanArc_internal>();
                Dictionary <int, int> v_DicoPointSourceGaucheParArc = new Dictionary <int, int>();
                Dictionary <int, int> v_DicoPointSourceDroitParArc  = new Dictionary <int, int>();
                //

                //Création du réseau
                double v_vorX_Left;
                double v_vorY_Left;
                double v_vorX_Right;
                double v_vorY_Right;
                double v_OrigX_Left;
                double v_OrigY_Left;
                double v_OrigX_Right;
                double v_OrigY_Right;
                double v_CorrectionX = 0;
                double v_CorrectionY = 0;

                ITopologieService v_topologieService = new TopologieService();
                int v_KeyArc = 0;
                HashSet <string> v_testDoublesLignes = new HashSet <string>();

                if (p_beanAlimentationVoronoi.p12_parametrage.reductionCoordonneesVf)
                {
                    v_CorrectionX = (double)p_beanAlimentationVoronoi.p55_origineXCorrigee;
                    v_CorrectionY = (double)p_beanAlimentationVoronoi.p56_origineYCorrigee;
                }

                BeanPoint_internal v_pt1;
                BeanPoint_internal v_pt2;
                BeanArc_internal   v_arc;

                //On créé une facette/ilot pour chaque point;
                BeanFacette_internal v_facette;
                Dictionary <int, BeanFacette_internal> v_toutesFacettes;

                v_toutesFacettes = p_beanAlimentationVoronoi.p10_dicoDesPointsSources.ToDictionary(c => c.Key, c => new BeanFacette_internal());
                //[ATTENTION! On doit mettre à jour l'id
                foreach (KeyValuePair <int, BeanFacette_internal> v_fac in v_toutesFacettes)
                {
                    v_fac.Value.p00_idFacette = v_fac.Key;
                }

                //On parcourt les arcs:
                string v_hcodePt1;
                string v_hcodePt2;
                string v_hcodeGraineVoronoiAGauche;
                string v_hcodeGraineVoronoiADroite;
                int    v_idIlotAGauche;
                int    v_idIlotADroite;
                foreach (VoronoiEdge v_Edges in p_voronoiGraph.Edges)
                {
                    if (!v_Edges.IsInfinite && !v_Edges.IsPartlyInfinite)
                    {
                        v_KeyArc++;

                        //L'arc voronoi
                        v_vorX_Left  = v_Edges.VVertexA[0] + v_CorrectionX;
                        v_vorY_Left  = v_Edges.VVertexA[1] + v_CorrectionY;
                        v_vorX_Right = v_Edges.VVertexB[0] + v_CorrectionX;
                        v_vorY_Right = v_Edges.VVertexB[1] + v_CorrectionY;
                        //
                        v_hcodePt1 = FLabServices.createUtilitaires().GetHCodeGeogPoint(new double[2] {
                            v_vorX_Left, v_vorY_Left
                        });
                        if (v_pointsDesArcsByCode.ContainsKey(v_hcodePt1))
                        {
                            v_pt1 = v_pointsDesArcsByCode[v_hcodePt1];
                        }
                        else
                        {
                            v_pt1 = new BeanPoint_internal(v_vorX_Left, v_vorY_Left, 0, v_srid);
                            v_pointsDesArcsByCode.Add(v_hcodePt1, v_pt1);
                        }
                        //
                        v_hcodePt2 = FLabServices.createUtilitaires().GetHCodeGeogPoint(new double[2] {
                            v_vorX_Right, v_vorY_Right
                        });
                        if (v_pointsDesArcsByCode.ContainsKey(v_hcodePt2))
                        {
                            v_pt2 = v_pointsDesArcsByCode[v_hcodePt2];
                        }
                        else
                        {
                            v_pt2 = new BeanPoint_internal(v_vorX_Right, v_vorY_Right, 0, v_srid);
                            v_pointsDesArcsByCode.Add(v_hcodePt2, v_pt2);
                        }

                        //
                        v_arc = new BeanArc_internal(v_pt1, v_pt2);
                        //
                        if (!v_arcsParHCode.ContainsKey(v_arc.p01_hcodeArc))
                        {
                            v_arcsParHCode.Add(v_arc.p01_hcodeArc, v_arc);
                        }

                        //On référence les points 'graines' voronoi à droite et à gauche
                        v_OrigX_Left  = v_Edges.LeftData[0] + v_CorrectionX;
                        v_OrigY_Left  = v_Edges.LeftData[1] + v_CorrectionY;
                        v_OrigX_Right = v_Edges.RightData[0] + v_CorrectionX;
                        v_OrigY_Right = v_Edges.RightData[1] + v_CorrectionY;
                        //
                        v_hcodeGraineVoronoiAGauche = FLabServices.createUtilitaires().GetHCodeGeogPoint(new double[2] {
                            v_OrigX_Left, v_OrigY_Left
                        });
                        v_hcodeGraineVoronoiADroite = FLabServices.createUtilitaires().GetHCodeGeogPoint(new double[2] {
                            v_OrigX_Right, v_OrigY_Right
                        });
                        //
                        v_facette = null;
                        if (p_beanAlimentationVoronoi.p31_correspondanceHCodePointvsIdPoint.ContainsKey(v_hcodeGraineVoronoiAGauche))
                        {
                            v_idIlotAGauche = p_beanAlimentationVoronoi.p31_correspondanceHCodePointvsIdPoint[v_hcodeGraineVoronoiAGauche];
                            v_facette       = v_toutesFacettes[v_idIlotAGauche];
                            v_facette.p02_arcs.Add(v_arc);
                            v_arc.p21_facetteGauche = v_facette;
                        }
                        else
                        {
                            v_arc.p20_statutArc = enumStatutArc.arcExterne;
                        }
                        v_facette = null;
                        if (p_beanAlimentationVoronoi.p31_correspondanceHCodePointvsIdPoint.ContainsKey(v_hcodeGraineVoronoiADroite))
                        {
                            v_idIlotADroite = p_beanAlimentationVoronoi.p31_correspondanceHCodePointvsIdPoint[v_hcodeGraineVoronoiADroite];
                            v_facette       = v_toutesFacettes[v_idIlotADroite];
                            v_facette.p02_arcs.Add(v_arc);
                            v_arc.p21_facetteGauche = v_facette;
                        }
                        else
                        {
                            v_arc.p20_statutArc = enumStatutArc.arcExterne;
                        }
                    } //Fin if (!v_Edges.IsInfinite && !v_Edges.IsPartlyInfinite)
                }     //Fin foreach
                 //Création de la topologie
                v_arcsVoronoi = v_arcsParHCode.Values.OrderBy(c => c.p01_hcodeArc).ToList();

                //On actualise les points des facettes:
                foreach (KeyValuePair <int, BeanFacette_internal> v_fac in v_toutesFacettes)
                {
                    List <BeanPoint_internal> v_points = v_fac.Value.p02_arcs.Select(c => c.p11_pointDbt).ToList();
                    v_points.AddRange(v_fac.Value.p02_arcs.Select(c => c.p12_pointFin).ToList());
                    HashSet <string> v_pointsDeja = new HashSet <string>();
                    foreach (BeanPoint_internal v_pt in v_points)
                    {
                        if (!v_pointsDeja.Contains(v_pt.p01_hCodeGeog))
                        {
                            v_fac.Value.p01_pointsDeFacette.Add(v_pt);
                            v_pointsDeja.Add(v_pt.p01_hCodeGeog);
                        }
                    }
                }

                //
                v_topologie = new BeanTopologieFacettes(v_arcsVoronoi);
                v_topologie.p13_facettesById = v_toutesFacettes;
                //On supprime les éventuelles facettes sans dimension
                List <int> v_idFacettesASupprimer;
                v_idFacettesASupprimer = v_toutesFacettes.Where(c => c.Value.p02_arcs.Count < 3).Select(c => c.Key).ToList();
                BeanFacette_internal v_facetteASupprimer;
                foreach (int v_idFacASuppr in v_idFacettesASupprimer)
                {
                    v_facetteASupprimer = v_topologie.p13_facettesById[v_idFacASuppr];
                    v_topologie.FacetteSupprimer(v_facetteASupprimer);
                }


                //Géométrie:
                List <int>           v_idFacettes = v_topologie.p13_facettesById.Keys.ToList();
                IGeometry            v_geomFacette;
                BeanFacette_internal v_facettePourGeom;
                foreach (int v_idFac in v_idFacettes)
                {
                    v_facettePourGeom = v_topologie.p13_facettesById[v_idFac];
                    v_geomFacette     = FLabServices.createCalculMedium().GetGeometryPolygoneFacetteEtOrdonnePointsFacette(ref v_facettePourGeom, ref v_topologie);
                    v_facettePourGeom.p04_geomFacette = v_geomFacette;
                }
            }
            catch (Exception v_ex)
            {
                throw v_ex;
            }
            return(v_topologie);
        }
Beispiel #7
0
        public void GetVisuPoint2D(BeanPoint_internal p_point, string p_label, int p_taillePoint)
        {
            Color p_couleur = Color.FromArgb(125, 125, 125);

            GetVisuPoint2D(p_point, p_label, p_couleur, p_taillePoint);
        }