Пример #1
0
 public MainWindowViewModel(AxMapControl axMapControl)
 {
     _axMapControl = axMapControl;
     _shapeOp=new ShapeOp(string.Empty);
     _mapIndex=new Dictionary<string, int>(5);
     InitializeCommand();
 }
 public RasterTimeCostViewModel(string landuse, string traffice)
 {
     _landUseFilePath = landuse;
     _trafficRoadFilePath = traffice;
     CellSize = 1000;
     TimeCostName = "时间成本";
     _shapeOp=new ShapeOp(string.Empty);
     FillShapeName();
     InitSpeed();
     InitializeCommand();
 }
 private void InitPop()
 {
     _popDic=new Dictionary<string, float>();
     if (String.IsNullOrEmpty(_selectedPopIndex)) return;
     ShapeOp op=new ShapeOp(CityFilePath);
     var pFeatureClass = op.OpenFeatureClass();
     var res = op.FindValue(pFeatureClass,"Name", SelectedPopIndex);
     foreach (var re in res)
     {
         _popDic.Add(re.Key,Convert.ToSingle(re.Value));
     }
 }
Пример #4
0
 public static IEnumerable<City> ReadCities(string filePath)
 {
     _shapeOp=new ShapeOp(filePath);
     var pFeatureClass = _shapeOp.OpenFeatureClass();
     if (!pFeatureClass.FieldExistCheck("Name")
         ||!pFeatureClass.FieldExistCheck("是否为站点"))
             throw new ArgumentException("部分字段不存在");
     IFeatureCursor pFeaureCursor = pFeatureClass.Search(null, false);
     IFeature pFeature;
     int nameIndex = pFeatureClass.Fields.FindField("Name");
     int typeIndex = pFeatureClass.Fields.FindField("是否为站点");
     while ((pFeature = pFeaureCursor.NextFeature()) != null)
     {
         var name = Convert.ToString(pFeature.Value[nameIndex]);
         IPoint point = pFeature.Shape as IPoint;
         yield return new City(point.X, point.Y, name, pFeature.Value[typeIndex].ToString().Trim());
     }
     Marshal.ReleaseComObject(pFeaureCursor);
 }
Пример #5
0
 public static IEnumerable<HighTrainPath> ReadRailway(string filePath)
 {
     _shapeOp=new ShapeOp(filePath);
     var pFeatureClass = _shapeOp.OpenFeatureClass();
     if (!pFeatureClass.FieldExistCheck( "Speed", "起点", "终点"))
         throw new ArgumentException("部分字段不存在");
     IFeatureCursor pFeaureCursor=pFeatureClass.Search(null, false);
     IFeature pFeature;
     int speedIndex = pFeatureClass.Fields.FindField("Speed");
     int startIndex = pFeatureClass.Fields.FindField("起点");
     int stopIndex = pFeatureClass.Fields.FindField("终点");
     while ((pFeature=pFeaureCursor.NextFeature())!=null)
     {
         var speed = Convert.ToSingle(pFeature.Value[speedIndex]);
         var start = Convert.ToString(pFeature.Value[startIndex]);
         var stop = Convert.ToString(pFeature.Value[stopIndex]);
         IPolyline polyline = pFeature.Shape as IPolyline;
         var distance = (float)polyline.Length;
         yield return new HighTrainPath(start, stop, distance, speed);
     }
     Marshal.ReleaseComObject(pFeaureCursor);
 }
Пример #6
0
 private void InitControls()
 {
     Cities = new ObservableCollection<CalculatorCity>();
     try
     {
         var cities = NetWorkUtil.ReadCities(CityFilePath);
         foreach (var city in cities)
         {
             Cities.Add(new CalculatorCity(city));
         }
         ShapeOp shapeOp=new ShapeOp(CityFilePath);
         Indexes = shapeOp.OpenFeatureClass().NumbericFieldsName();
     }
     catch (ArgumentException e)
     {
         Messenger.Default.Send(new GenericMessage<string>(e.Message), "Exception");
     }
     catch (Exception e)
     {
         _log.Error(e.Message+e.StackTrace);
     }
 }
Пример #7
0
 private void InitDic()
 {
     ShapeOp shapeOp = new ShapeOp(CityFilePath);
     IFeatureClass pFeatureClass = shapeOp.OpenFeatureClass();
     var res = shapeOp.FindValue(pFeatureClass, "Name", SelectedIndex);
     foreach (var re in res)
     {
         CityValues.Add(re.Key,Convert.ToSingle(re.Value));
     }
 }