1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68:
| Function GetTempDir:String; var p:Pchar; begin p:=stralloc(255); GetTempPath(255,p); Result:=p; strdispose(p); end;
Function CleanUrl(const s:String):String; begin Result :=StringReplace( StringReplace( StringReplace( StringReplace(s,'ß','ss',[rfReplaceAll]) ,'ä','ae',[rfReplaceAll]) ,'ü','ue',[rfReplaceAll]) ,'ö','oe',[rfReplaceAll]) end;
Function GetLatLng(AURL:String;var lat,lng:Double):Boolean; var
i:Integer; sl:TStringList; IsIntrest:Boolean; LFilename:String; begin sl:=TStringList.create; Result := false; try LFileName := IncludeTrailingBackSlash(GetTempDir)+'~tmp.xml'; with TDownLoadURL.Create(nil) do begin Filename := LFileName; URL := CleanUrl(AUrl); try ExecuteTarget(nil); except end; free; sl.LoadFromFile(LFileName); end;
IsIntrest := false; for I := 0 to sl.Count - 1 do begin if pos('</location>',sl[i])>0 then IsIntrest := false; if IsIntrest then begin try if pos('<lat>',sl[i])>0 then lat := StrToFloat(Stringreplace(Stringreplace(Stringreplace(Trim(sl[i]),'<lat>','',[]),'</lat>','',[]),'.',',',[])) else if pos('<lng>',sl[i])>0 then lng := StrToFloat(Stringreplace(Stringreplace(Stringreplace(Trim(sl[i]),'<lng>','',[]),'</lng>','',[]),'.',',',[])); Result := (lat<>0) or (lng<>0); except end; end; if pos('<location>',sl[i])>0 then IsIntrest := true; end;
finally sl.Free; end;
end; |