Example #1
0
 //取消监控
 private void RemoveWatching(Team team)
 {
     //删除所有信息点
     try
     {
         StringBuilder stb = new StringBuilder("1<>0");
         foreach (Car car in team.Cars)
         {
             stb.Append(" or ID='").Append(car.CarID).Append("'");
             try
             {
                 listViewWatching.Items.Remove(car.ItemInWatch);
             }
             catch { }
             car.ItemInWatch = null;
             car.IsWatched   = false;
             if (car.ItemInList != null)
             {
                 car.ItemInList.Checked = false;
                 if (car.ItemInList.ForeColor == COLOR_CAR_IN_WATCH)
                 {
                     car.ItemInList.ForeColor = COLOR_CAR_NORMAL;
                 }
             }
         }
         MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere(stb.ToString());
         si.QueryDefinition.Columns = new string[] { "*" };
         MapInfo.Data.Feature ftr = MapInfo.Engine.Session.Current.Catalog.SearchForFeature(tableWatching, si);
         if (ftr != null)
         {
             tableWatching.DeleteFeature(ftr);
         }
     }
     catch { }
 }
Example #2
0
 //取消监控
 private void RemoveWatching(Car car)
 {
     //删除信息点
     try
     {
         try
         {
             listViewWatching.Items.Remove(car.ItemInWatch);
         }
         catch { }
         car.ItemInWatch = null;
         car.IsWatched   = false;
         if (car.ItemInList != null)
         {
             car.ItemInList.Checked = false;
             if (car.ItemInList.ForeColor == COLOR_CAR_IN_WATCH)
             {
                 car.ItemInList.ForeColor = COLOR_CAR_NORMAL;
             }
         }
         MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("ID='" + car.CarID.ToString() + "'");
         si.QueryDefinition.Columns = new string[] { "*" };
         MapInfo.Data.Feature ftr = MapInfo.Engine.Session.Current.Catalog.SearchForFeature(tableWatching, si);
         if (ftr != null)
         {
             tableWatching.DeleteFeature(ftr);
         }
     }
     catch { }
 }
Example #3
0
        //查询矩形区域内的地物
        private List <String> GetPlacesInRect(DPoint dpt1, DPoint dpt2, String lName)
        {
            List <String> list = new List <string>();

            try
            {
                MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWithinRect(new DRect(dpt1, dpt2), mapControl.Map.GetDisplayCoordSys(), ContainsType.Centroid);
                si.QueryDefinition.Columns = new string[] { "*" };
                IResultSetFeatureCollection fc = MapInfo.Engine.Session.Current.Catalog.Search(Session.Current.Catalog.GetTable(lName), si);
                foreach (Feature ftr in fc)
                {
                    list.Add(ftr["Name"].ToString());
                }
            }
            catch { }
            return(list);
        }
Example #4
0
        //查询附近地物
        private String FindMapNearInfo(double x, double y, String tableName, String colName, int meter)
        {
            String ret = "";

            try
            {
                MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchNearest(new DPoint(x, y), mapControl.Map.GetDisplayCoordSys(), new Distance(meter, DistanceUnit.Meter));
                si.QueryDefinition.Columns = null;
                (si.SearchResultProcessor as ClosestSearchResultProcessor).Options = ClosestSearchOptions.StopAtFirstMatch;
                MapInfo.Data.IResultSetFeatureCollection irfc = MapInfo.Engine.Session.Current.Catalog.Search(tableName, si);
                if (irfc.Count > 0)
                {
                    ret = irfc[0][colName].ToString();
                }
                irfc.Close();
            }
            catch { }
            return(ret);
        }
Example #5
0
 //刷新监控车辆信息
 private void RefreshWatching(Car car)
 {
     if (car != null && car.Pos != null)
     {
         //删除原信息点
         try
         {
             MapInfo.Data.SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("ID='" + car.CarID.ToString() + "'");
             si.QueryDefinition.Columns = new string[] { "*" };
             MapInfo.Data.Feature ftr = MapInfo.Engine.Session.Current.Catalog.SearchForFeature(tableWatching, si);
             if (ftr != null)
             {
                 tableWatching.DeleteFeature(ftr);
             }
             //添加新信息点
             Feature ftr1 = new Feature(tableWatching.TableInfo.Columns);
             ftr1.Geometry = new MapInfo.Geometry.Point(mapControl.Map.GetDisplayCoordSys(), new DPoint(car.Pos.Lo, car.Pos.La)) as FeatureGeometry;
             //ftr1.Style = new SimpleVectorPointStyle(46, Color.Green, 16);
             if (car.Pos.AlarmHandle != 0)
             {
                 ftr1.Style = new MapInfo.Styles.BitmapPointStyle("red_" + car.Pos.Direction.ToString() + ".bmp", BitmapStyles.NativeSize, Color.Green, 16);
             }
             else if (car.Pos.Pointed == 0)
             {
                 ftr1.Style = new MapInfo.Styles.BitmapPointStyle("yellow_" + car.Pos.Direction.ToString() + ".bmp", BitmapStyles.NativeSize, Color.Green, 16);
             }
             else
             {
                 ftr1.Style = new MapInfo.Styles.BitmapPointStyle("green_" + car.Pos.Direction.ToString() + ".bmp", BitmapStyles.NativeSize, Color.Red, 16);
             }
             ftr1["ID"]    = car.CarID.ToString();
             ftr1["Label"] = car.CarNO + " [" + car.Pos.Speed.ToString() + "km/h]";
             tableWatching.InsertFeature(ftr1);
             tableWatching.Refresh();
         }
         catch { }
     }
 }