|
Accueil → WINDEV 25 → WX - Função GEO IP, localize pelo IP o "Local Aproximado" (Endereço, Latitude e Longitude) |
WX - Função GEO IP, localize pelo IP o "Local Aproximado" (Endereço, Latitude e Longitude) |
Débuté par adrianoboller, 15 juil. 2015 17:39 - 4 réponses |
| |
| | | |
|
| |
Membre enregistré 3 655 messages Popularité : +175 (223 votes) |
|
Posté le 15 juillet 2015 - 17:39 |
Procedure WS_GeoIpLatitudeLongitude(LOCAL IP, LOCAL DebugSn)
ok is boolean = False
Url is string = "http://www.geoiptool.com/pt/"+ IP
Inicio, Fim is int = 0
sXml, Latitude, Longitude, Busca, sBuscaTD is string = ""
HTTPTimeOut(GloHTTPTimeOut)
ok = HTTPRequest(Url)
IF ok = True THEN
sXml = HTTPGetResult(httpResult)
sXml = Replace(sXml,"Matriz,","") sXml = Replace(sXml,"Matriz","")
IF Length(sXml) > 0 THEN
Busca = "Longitude:"
Inicio = PositionOccurrence(sXml,Busca,firstRank)
Busca = "Latitude:"
Fim = PositionOccurrence(sXml,Busca,firstRank) + 100
sXml = Middle(sXml,Inicio, Fim-Inicio)
sXml = Replace(sXml, " ", "")
sXml = Replace(sXml, "<10>", "")
sXml = Replace(sXml, "<br>", "")
sXml = Replace(sXml, Charact(13), "")
sXml = Replace(sXml, Charact(10), "")
sXml = Replace(sXml, Charact(34), "")
sXml = Replace(sXml, Charact(13)+Charact(10), "")
sXml = Replace(sXml, "</span></td><tdalign=leftclass=arial_bold>", "")
sXml = Replace(sXml, "</td></tr><tr><tdalign=right><spanclass=arial>", "; ")
sXml = Replace(sXml, "</td>", "")
Inicio = PositionOccurrence(sXml,"Latitude:",firstRank,IgnoreCase)
Longitude = Middle(sXml,11,Inicio-13)
Latitude = Middle(sXml,Inicio+9,Length(sXml))
GloVoceLatitude = Latitude
GloVoceLongitude = Longitude
sXml = Latitude +"; "+ Longitude
IF DebugSn = "S" fSaveText("c:\latlong.txt",sXml) END
END
END
RESULT(sXml) |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 3 655 messages Popularité : +175 (223 votes) |
|
Posté le 15 juillet 2015 - 17:40 |
Procedure WS_CEP_EnderecoDasCoordenadas(LOCAL pLatitude is string, LOCAL pLongitude is string, LOCAL DebugSN)
IF GloDebugSN = "S" THEN Info("WS_CEP_EnderecoDasCoordenadas") DebugSN = "S" END
NextTitle("Atenção")
ok is boolean = False GloEnderecoOK = False
Endereco, RetJson is string = "" IF pLatitude <> 0 AND pLongitude <> 0 AND pLatitude <> Null AND pLongitude <> Null THEN
Url is string = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + pLatitude + "," + pLongitude + "&sensor=true"
IF DebugSN = "S" Info("01",Url) END
HTTPTimeOut(GloHTTPTimeOut)
ok = HTTPRequest(Url)
IF ok = True THEN
ChangeCharset(charsetOccidental)
RetJson = WS_Android_IOS_HTTPGetResult() IF Length(RetJson) = 0 THEN
ok= False ELSE
IF DebugSN = "S" Info(Url,RetJson) END
TagEnd is string = """formatted_address"" :" i is int = PositionOccurrence(RetJson, TagEnd, firstRank, IgnoreCase ) + Length(TagEnd) Endereco =""
IF i> 0 THEN Endereco = ExtractString(RetJson[[i TO]],2,"""") GloEnderecoOK = True
END
IF Endereco = "" OR RetJson = "ERRO" THEN
GloEnderecoOK = False Url = "http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + pLatitude + "," + pLongitude + "&sensor=true"
IF DebugSN = "S" Info("02",Url) END
HTTPTimeOut(GloHTTPTimeOut)
ok = HTTPRequest(Url) IF ok = True THEN
RetXml is string = WS_Android_IOS_HTTPGetResult()
IF Length(RetXml) = 0 THEN
ok= False ELSE
IF DebugSN = "S" Info("Xml:",RetXml) END
IF PositionOccurrence(RetXml,"<formatted_address>",firstRank) > 0 THEN
nPosicaoInicial is int = PositionOccurrence(RetXml,"<formatted_address>",firstRank) + Length("<formatted_address>") nPosicaoFinal is int = PositionOccurrence(RetXml,"</formatted_address>",firstRank) + Length("</formatted_address>") nPosicaoFinal = nPosicaoFinal - nPosicaoInicial Endereco = Middle(RetXml,nPosicaoInicial,nPosicaoFinal) GloEnderecoOK = True
END END END END END END
IF ok = False THEN Popup(GloMsgSemInternet,"L") END
Endereco = WS_RemoveAcentos(Endereco)
END
RESULT (Endereco) |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 3 655 messages Popularité : +175 (223 votes) |
|
Posté le 15 juillet 2015 - 17:41 |
Procedure WS_CEP_EnderecoRetornaLatLonGoogleMaps(LOCAL Endereco, LOCAL OrigemDestino, LOCAL DebugSN)
IF GloDebugSN = "S" THEN Info("WS_CEP_EnderecoRetornaLatLonGoogleMaps") DebugSN = "S" END
ok is boolean = False
GloOutrasTelas = "S"
Retorno is string = ""
ChangeCharset(charsetOccidental)
inicio, fim is int = 0
Endereco = NoAccent(Endereco)
Endereco = Replace(Endereco," ","+")
Endereco = "http://maps.google.com/maps/api/geocode/xml?address="+Endereco+"&sensor=true"
HTTPTimeOut(GloHTTPTimeOut)
IF DebugSN = "S" Info("Envio: "+Endereco) END
ok = HTTPRequest(Endereco)
IF ok = True THEN
Retorno = HTTPGetResult(httpResult)
ChangeCharset(charsetOccidental)
Retorno = Capitalize(WS_RemoveAcentos(Retorno))
Retorno = Replace(Retorno,"Matriz,","")
Retorno = Replace(Retorno,"Matriz","")
IF DebugSN = "S" Info("Retorno: "+Retorno) END
IF DebugSN = "S" AND InSimulatorMode() = False THEN IF InAndroidMode() = True fSaveText("/mnt/sdcard/TaxiFv/Arquivos/WS_CEP_EnderecoRetornaLatLonGoogleMaps.txt",Retorno) END END
IF Retorno <> Null THEN
Retorno = Replace(Retorno,Charact(34),"")
IF PositionOccurrence(Retorno,"OVER_QUERY_LIMIT",firstRank,FromBeginning) > 0 AND DebugSN = "S" THEN NextTitle("Atenção") Info("Excedeu a quantidade de pesquisas no google maps.") ELSE
IF PositionOccurrence(Retorno,"<formatted_address>",firstRank,IgnoreCase) > 0 THEN inicio = PositionOccurrence(Retorno,"<formatted_address>",firstRank,IgnoreCase) + 19 fim = PositionOccurrence(Retorno,"</formatted_address>",firstRank,IgnoreCase) IF OrigemDestino = "O" GloVoceEnderecoLongo = Middle(Retorno,inicio,fim-inicio) ELSE IF OrigemDestino = "D" GloDestinoEnderecoLongo = Middle(Retorno,inicio,fim-inicio) END END
IF PositionOccurrence(Retorno,"<lat>",firstRank,IgnoreCase) > 0 THEN inicio = PositionOccurrence(Retorno,"<lat>",firstRank,IgnoreCase) + 5 fim = PositionOccurrence(Retorno,"</lat>",firstRank,IgnoreCase) - 1 GloLatitudeLocalizada = Val(Middle(Retorno,inicio,fim-inicio),"d") IF OrigemDestino = "O" GloVoceLatitude = GloLatitudeLocalizada ELSE IF OrigemDestino = "D" GloDestinoLatitude = GloLatitudeLocalizada END END
IF PositionOccurrence(Retorno,"<lng>",firstRank,IgnoreCase) > 0 THEN inicio = PositionOccurrence(Retorno,"<lng>",firstRank,IgnoreCase) + 5 fim = PositionOccurrence(Retorno,"</lng>",firstRank,IgnoreCase) - 1 GloLongitudeLocalizada = Val(Middle(Retorno,inicio,fim-inicio),"d") IF OrigemDestino = "O" GloVoceLongitude = GloLongitudeLocalizada ELSE IF OrigemDestino = "D" GloDestinoLongitude = GloLongitudeLocalizada END END
IF OrigemDestino = "O" THEN Retorno = GloVoceLatitude +";"+ GloVoceLongitude ELSE IF OrigemDestino = "D" Retorno = GloDestinoLatitude +";"+ GloDestinoLongitude END
END
END
IF DebugSN = "S" Info("Retorno", Retorno) END
END
GloOutrasTelas = ""
RESULT(Retorno) |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 3 655 messages Popularité : +175 (223 votes) |
|
Posté le 18 juillet 2015 - 17:46 |
| |
| |
| | | |
|
| | |
| |
Membre enregistré 3 655 messages Popularité : +175 (223 votes) |
|
Posté le 17 octobre 2019 - 21:37 |
Procedure New_Capitalize(Texto)
x is int = 0
Nome, newNome is string =""
IF Texto <> "" THEN nQtdeEspaco is int = StringCount(Texto," ") LOOP(nQtdeEspaco) x++ Nome = ExtractString(Texto,x," ",FromBeginning) Nome = Upper(Middle(Nome,1,1)) + Middle(Nome,2,Length(Nome)) + " " newNome += Nome END newNome = Replace(newNome," Da ", " da ") newNome = Replace(newNome," Das ", " das ") newNome = Replace(newNome," De ", " de ") newNome = Replace(newNome," Do ", " do ") newNome = Replace(newNome," Dos ", " dos ") END
RESULT newNome
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 99949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.com.br/ |
| |
| |
| | | |
|
| | | | |
| | |
|