有没有人呀,兄弟们呀,帮帮忙了!!

解决方案 »

  1.   

    有谁知道吗?兄弟们呀,帮帮忙了!! 
      

  2.   

    我知道。请看下面的例子:查找距离某城市最近的商店。如不明白:email:[email protected]
    procedure TDataBindTestForm.Button21Click(Sender: TObject);
    var
      I : Integer;
      CityLr,Lr : Layer;
      Vbs : CMapXVariables;
    //  F,Fs : OleVariant;
      CityFs : CMapXFeatures;
      F : CMapXFeature;
      Slc : OleVariant;
      MinDistance : Double;
      SearchTimes : Integer;
    begin
      ListBox2.Clear;
      CityLr := Map1.Layers.Item('US City_20');
      Lr := Map1.Layers.Item('Shops');
      Slc := Lr.Selection;
      Slc.ClearSelection;  Vbs := CoVariables.Create;
      Vbs.Add('Var1',Edit4.Text);
      CityFs := CityLr.Search('City=Var1',Vbs);
      if CityFs.Count = 0 then
        begin
          MessageBox(Handle,'无此城市,请重新查找。','警告',MB_OK);
          Exit;
        end;  MinDistance := 10;
      SearchTimes := 1;
      repeat
        Lr.Selection.SelectByRadius(CityFs.Item(1).CenterX,CityFs.Item(1).CenterX,
                        MinDistance,miSelectionNew);
        MinDistance := MinDistance * 2;
        SearchTimes := SearchTimes + 1;
      until (Lr.Selection.Count > 0) or (SearchTimes > 11);  if Lr.Selection.Count <> 0 then
        begin
          F := Lr.Selection.Item(1);
          MinDistance := Map1.Distance(Lr.Selection.Item(1).CenterX,Lr.Selection.Item(1).CenterY,
                                  CityFs.Item(1).CenterX,CityFs.Item(1).CenterY);
          for I := 1 to Lr.Selection.Count do
            if MinDistance > Map1.Distance(Lr.Selection.Item(I).CenterX,Lr.Selection.Item(I).CenterY,
                                  CityFs.Item(1).CenterX,CityFs.Item(1).CenterY) then
              begin
                MinDistance := Map1.Distance(Lr.Selection.Item(I).CenterX,Lr.Selection.Item(I).CenterY,
                                  CityFs.Item(1).CenterX,CityFs.Item(1).CenterY);
                F := Lr.Selection.Item(I);
              end;
          Slc.Replace(F);
          ListBox2.Items.Add(F.KeyValue);
        end
      else
        MessageBox(Handle,'未找到精确匹配结果。','提示',MB_OK);
    end;
      

  3.   

    呵呵,以前在学校时用C写过。你可以找一本运筹算法的书看看啊。