コード例 #1
0
        //---------------------------------------------------------------------------
        public bool GenereItem(
            object obj,
            double fLat1,
            double fLong1,
            double fLat2,
            double fLong2,
            CMapLayer layer)
        {
            CResultAErreur result             = CResultAErreur.True;
            CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(this.m_mapLineGenerator);

            if (FormuleCondition != null && !(FormuleCondition is C2iExpressionVrai))
            {
                result = FormuleCondition.Eval(ctx);
                if (!result || result.Data == null)
                {
                    return(false);
                }
                bool?bResult = CUtilBool.BoolFromString(result.Data.ToString());
                if (bResult == null || !bResult.Value)
                {
                    return(false);
                }
            }
            string strLibelle = "";

            if (FormuleToolTip != null)
            {
                result = FormuleToolTip.Eval(ctx);
                if (result && result.Data != null)
                {
                    strLibelle = result.Data.ToString();
                }
            }


            CMapItemPath line = new CMapItemPath(layer);

            line.LineColor        = LineColor;
            line.LineWidth        = LineWidth;
            line.ToolTip          = strLibelle;
            line.PermanentToolTip = m_bPermanentToolTip;
            line.Tag = obj;
            List <SLatLong> lstPts = new List <SLatLong>();

            lstPts.Add(new SLatLong(fLat1, fLong1));
            //lstPts.Add(new SLatLong((fLat1 + fLat2) / 2, (fLong1 + fLong2) / 2));
            lstPts.Add(new SLatLong(fLat2, fLong2));
            line.Points = lstPts;

            if (LineGenerator.ActionSurClick != null)
            {
                line.MouseClicked += new MapItemClickEventHandler(OnMouseClick);
            }


            return(true);
        }
コード例 #2
0
        //------------------------------------------------------------------
        public CWin32MapItemPath(CMapItemPath item)
            : base(GetPointsLatLng(item.Points), item.ToolTip)

        {
            m_item = item;
            if (item.HasOnClick && item.Points.Count() >= 2)
            {
                IsHitTestVisible = true;
            }
        }
コード例 #3
0
ファイル: CGPSLine.cs プロジェクト: ykebaili/Timos
        //---------------------------------------------------------------------------
        public IEnumerable <IMapItem> FindMapItems(CMapDatabase database)
        {
            CGPSLineTrace   trace    = DetailLigne;
            List <IMapItem> lstPaths = new List <IMapItem>();

            foreach (CGPSLineSegment segment in trace.Segments)
            {
                CMapItemPath path = database.FindItemFromTag(segment) as CMapItemPath;
                if (path != null)
                {
                    lstPaths.Add(path);
                }
            }
            return(lstPaths.AsReadOnly());
        }
コード例 #4
0
ファイル: CGPSLine.cs プロジェクト: ykebaili/Timos
        public IEnumerable <IMapItem> CreateMapItems(CMapLayer layer)
        {
            List <IMapItem> lstItems  = new List <IMapItem>();
            CGPSLineTrace   trace     = DetailLigne;
            SLatLong        lastPoint = trace.PointDepart;

            foreach (CGPSLineSegment segment in trace.Segments)
            {
                CMapItemPath path = new CMapItemPath(layer);
                path.Points      = new SLatLong[] { lastPoint, segment.PointDestination };
                path.LineColor   = segment.Couleur;
                path.LineWidth   = segment.Width;
                path.Tag         = segment;
                path.ToolTip     = segment.Libelle;
                path.EnableClick = true;
                lstItems.Add(path);
                lastPoint = segment.PointDestination;
            }
            return(lstItems.AsReadOnly());
        }
コード例 #5
0
ファイル: CGPSLine.cs プロジェクト: ykebaili/Timos
        //---------------------------------------------------------------------------
        public IEnumerable <IMapItem> UpdateMapItems(CMapDatabase database, List <IMapItem> itemsToDelete)
        {
            CGPSLineTrace   trace     = DetailLigne;
            SLatLong        lastPoint = trace.PointDepart;
            List <IMapItem> lstPaths  = new List <IMapItem>();

            foreach (CGPSLineSegment segment in trace.Segments)
            {
                CMapItemPath path = database.FindItemFromTag(segment) as CMapItemPath;
                if (path != null)
                {
                    path.Points    = new SLatLong[] { lastPoint, segment.PointDestination };
                    path.LineColor = segment.Couleur;
                    path.LineWidth = segment.Width;
                    path.Tag       = segment;
                    path.ToolTip   = segment.Libelle;
                    lstPaths.Add(path);
                    lastPoint = segment.PointDestination;
                }
            }
            return(lstPaths.AsReadOnly());
        }
コード例 #6
0
ファイル: CMapRouteFromQuery.cs プロジェクト: ykebaili/Timos
        //---------------------------------------------
        public CResultAErreur GenereItems(CMapDatabase database, CContexteDonnee ctxDonnee)
        {
            CResultAErreur result = CResultAErreur.True;
            //Calcule les éléments à générer
            DataTable table     = Query.GetTable(NomTableSource, m_listeSources);
            double?   fLastLat  = null;
            double?   fLastLong = null;
            CMapLayer layer     = database.GetLayer(Generator.LayerId, true);

            if (table != null)
            {
                DataColumn colLat  = null;
                DataColumn colLong = null;
                DataColumn colLib  = null;
                DataColumn colElt  = null;
                foreach (DataColumn col in table.Columns)
                {
                    if (col.ColumnName == ChampCleElement)
                    {
                        colElt = col;
                    }
                    if (col.ColumnName == ChampLatitude)
                    {
                        colLat = col;
                    }
                    if (col.ColumnName == ChampLibelle)
                    {
                        colLib = col;
                    }
                    if (col.ColumnName == ChampLongitude)
                    {
                        colLong = col;
                    }
                }
                if (colLong == null || colLat == null)
                {
                    result.EmpileErreur(I.T("Can not find columns @1 and @2 in data source|20024",
                                            ChampLongitude,
                                            ChampLatitude));
                }
                Dictionary <object, List <DataRow> > dicRowsParElement = new Dictionary <object, List <DataRow> >();
                if (colElt != null)
                {
                    object         lastElt = null;
                    List <DataRow> lstRows = null;
                    foreach (DataRow row in table.Rows)
                    {
                        object v = row[colElt];
                        if (v != lastElt || lstRows == null)
                        {
                            lastElt = v;
                            if (!dicRowsParElement.TryGetValue(v, out lstRows))
                            {
                                lstRows = new List <DataRow>();
                                dicRowsParElement[v] = lstRows;
                            }
                        }
                        lstRows.Add(row);
                    }
                }
                else
                {
                    List <DataRow> lstRows = new List <DataRow>();
                    foreach (DataRow row in table.Rows)
                    {
                        lstRows.Add(row);
                    }
                    dicRowsParElement[DBNull.Value] = lstRows;
                }

                foreach (KeyValuePair <object, List <DataRow> > kv in dicRowsParElement)
                {
                    List <DataRow>  lstRows   = kv.Value;
                    List <SLatLong> lstPoints = new List <SLatLong>();
                    int             nNb       = kv.Value.Count;
                    int             nIndex    = 0;
                    foreach (DataRow row in kv.Value)
                    {
                        try
                        {
                            double fLat     = Convert.ToDouble(row[colLat]);
                            double fLong    = Convert.ToDouble(row[colLong]);
                            string strLabel = colLib != null ?row[colLib] as string:null;
                            if (strLabel == null || strLabel.Length == 0)
                            {
                                strLabel = "";
                            }
                            bool bPrendre = true;
                            if (strLabel == "" && fLastLong != null && fLastLat != null && MetresEntrePoints > 0)
                            {
                                //contrôle la distance
                                double fDist = GetGpsDist(fLastLong.Value, fLong, fLastLat.Value, fLat);
                                bPrendre = fDist >= MetresEntrePoints;
                            }
                            if (nIndex == nNb - 1)
                            {
                                bPrendre = true;
                            }
                            if (bPrendre)
                            {
                                fLastLat  = fLat;
                                fLastLong = fLong;
                                SLatLong pt = new SLatLong(fLat, fLong);
                                lstPoints.Add(pt);
                            }
                            if (strLabel != null && strLabel.Trim().Length > 0)
                            {
                                CMapItemSimple item = new CMapItemSimple(layer, fLat, fLong, EMapMarkerType.blue_dot);
                                item.ToolTip = strLabel;
                                layer.AddItem(item);
                            }
                        }
                        catch { }
                    }
                    CMapItemPath path = new CMapItemPath(layer);
                    path.Points = lstPoints.ToArray();
                    layer.AddItem(path);
                }
            }
            return(result);
        }