EDUTEK Posted January 9 Report Share Posted January 9 Boa tarde Alguém tem algum exemplo de como pegar a localização tendo a latitude e longitude. Tenho um programa de ponto de motorista, cada marcação ele grava a latitude e longitude, preciso informar pelo menos aproximadamente o local que ele efetuou a marcação. O programa do Tablet que ele faz a marcação não fui eu que desenvolvi, só montei o projeto, mas a parte da retaguarda é minha a programação. ai queria saber por exemplo onde ele encerrou a jornada do dia dele. Alguém tem um exemplo ? Grato. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted January 9 Report Share Posted January 9 https://www.fivetechsoft.com/forums/viewtopic.php?t=36454 Quote Link to comment Share on other sites More sharing options...
EDUTEK Posted January 9 Author Report Share Posted January 9 eu quero o contrario tenho a lat e long - quero o endereço aproximado Quote Link to comment Share on other sites More sharing options...
EDUTEK Posted January 10 Author Report Share Posted January 10 conforme o João passou, procurei lá e consegui achar uma forma segue abaixo function orion_jornada_AchaEndereco(mLat, mLong) local cGoogleURL := "https://nominatim.openstreetmap.org/reverse?format=xml&" local cAddress := "lat="+alltrim(mLat)+"&lon="+alltrim(mLong) local aReturn, i, cTxt := "" if empty(mLat) mLat := jornada->latitudegps mLong := Jornada->longitudegps cAddress := "lat="+alltrim(mLat)+"&lon="+alltrim(mLong) endif // aReturn := hb_jsonDecode( WebPageContents( cGoogleURL + cAddress) ) // *** Change this *** cDocXML := WebPageContents( cGoogleURL + cAddress) * hb_jsondecode( aReturn, @aReturn ) && se lá na URL vc colocar format "json" - eu uso "XML" if !empty(cDocXML) mRodovia := LerTag(cDocxml, "road") mCidade := LerTag(cDocxml, "town") mArea := LerTag(cDocxml, "municipality") mEstado := LerTag(cDocxml, "state") mRegiao := LerTag(cDocxml, "region") mRodovia := iif(len(rtrim(mrodovia))>0,mRodovia+", ","") mCidade := iif(len(rtrim(mCidade))>0,mCidade+", ","") mestado := iif(len(rtrim(mEstado))>0,mEstado+", ","") mRegiao := iif(len(rtrim(mRegiao))>0,mRegiao+", ","") cTxt1 := mRodovia + mcidade + mEstado + mRegiao + mArea cTXT := U8ToUni(cTXT1,"UTYPE_ANSI") if len(alltrim(ctxt)) < 10 cTxt:="Localização não Encontrada" endif else cTxt:="Localização não Encontrada" endif dbselectarea("jornada") mregistro := jornada->( recno()) grava_dados("A","jornada",{ "local" }, { cTxt }, alias(), "S") return nil Theotokos 1 Quote Link to comment Share on other sites More sharing options...
kapiaba Posted January 10 Report Share Posted January 10 Good, que eu informo aqui: mLat, mLong ??? Quote Link to comment Share on other sites More sharing options...
EDUTEK Posted January 10 Author Report Share Posted January 10 5 horas atrás, kapiaba disse: Good, que eu informo aqui: mLat, mLong ??? Latitude e longitude e: -22.63458 , -47,30005 - pois minha aplicação recebe essas informações dos tablets nos caminhões, e ai pro pessoal de controle aqui eles necessitam saber onde foi o apontamento, ai converto isso num endereço. Quote Link to comment Share on other sites More sharing options...
Jmsilva Posted January 10 Report Share Posted January 10 Seria isso ? #include "fivewin.ch" Function Main() Orion_jornada_AchaEndereco('-23.820724', '-45.370145') //LATITUDE E LONGITUDE Return Nil Function orion_jornada_AchaEndereco(mLat, mLong) local cGoogleURL := "https://nominatim.openstreetmap.org/reverse?format=xml&" local cAddress := "lat="+alltrim(mLat)+"&lon="+alltrim(mLong) local cXml := WebPageContents( cGoogleURL + cAddress) XBrowseXML(cXml) //fw23.07 Return Nil Quote Link to comment Share on other sites More sharing options...
kapiaba Posted January 11 Report Share Posted January 11 Edutek, faça isso funcionar corretamente, PSL. Seu exemplo não está nada bom... [code] #include "fivewin.ch" FUNCTION Main() LOCAL mLat, mLong // Latitude e longitude e: -22.63458 , -47,30005 mLat := "-22.63458" mLong := "-47,30005" orion_jornada_AchaEndereco( mLat, mLong ) RETURN NIL FUNCTION orion_jornada_AchaEndereco( mLat, mLong ) LOCAL CDOCXML, MRODOVIA, MCIDADE, MAREA, MESTADO, MREGIAO, CTXT1, ; MREGISTRO, NI, CTEMP LOCAL cGoogleURL := "https://nominatim.openstreetmap.org/reverse?format=xml&" LOCAL cAddress := "lat=" + AllTrim( mLat ) + "&lon=" + AllTrim( mLong ) LOCAL aReturn, i, cTxt := "" IF Empty( mLat ) mLat := jornada->latitudegps mLong := Jornada->longitudegps cAddress := "lat=" + AllTrim( mLat ) + "&lon=" + AllTrim( mLong ) ENDIF // aReturn := hb_jsonDecode( WebPageContents( cGoogleURL + cAddress) ) // *** Change this *** cDocXML := WebPageContents( cGoogleURL + cAddress ) // hb_jsondecode( aReturn, @aReturn ) && se lá na URL vc colocar format "json" - eu uso "XML" IF .NOT. Empty( cDocXML ) ? cDocXML // NAO RETORNOU POHHA NENHUMA. kkkkkk mRodovia := LerTag( cDocxml, "road" ) mCidade := LerTag( cDocxml, "town" ) mArea := LerTag( cDocxml, "municipality" ) mEstado := LerTag( cDocxml, "state" ) mRegiao := LerTag( cDocxml, "region" ) mRodovia := iif( Len( RTrim( mrodovia ) ) > 0, mRodovia + ", ", "" ) mCidade := iif( Len( RTrim( mCidade ) ) > 0, mCidade + ", ", "" ) mestado := iif( Len( RTrim( mEstado ) ) > 0, mEstado + ", ", "" ) mRegiao := iif( Len( RTrim( mRegiao ) ) > 0, mRegiao + ", ", "" ) cTxt1 := mRodovia + mcidade + mEstado + mRegiao + mArea // QUE POHHA E ESSA? // cTXT := U8ToUni( cTXT1, "UTYPE_ANSI" ) IF Len( AllTrim( ctxt ) ) < 10 cTxt := "Localização não Encontrada" ENDIF ELSE cTxt := "Localização não Encontrada" ENDIF /* QUAL A ESTRUTURA DESTE BANCO DE DADOS? dbSelectArea( "jornada" ) mregistro := jornada->( RecNo() ) */ grava_dados( "A", "jornada", { "local" }, { cTxt }, Alias(), "S" ) XBROWSE( cTxt1 ) RETURN NI FUNCTION LERTAG( MsgRetWs, cNode ) // ESTA CORRETO? LOCAL cData:="" LOCAL nPos,nPos1,cTempo, CTEMP WHILE( .T. ) SYSREFRESH() nPos := At("<"+cNode+">",MsgRetWs) cTemp:=Substr(MsgRetWs,nPos+len(cNode)+2) If At("<"+cNode+">",cTemp)!=0 nPos1 := At("</"+cNode+">",cTemp) cTemp := Substr(cTemp,nPos1+len(cNode)+3) MsgRetWs := cTemp Else Exit Endif SysRefresh() ENDDO nPos1 := At("</"+cNode+">",MsgRetWs) If nPos!=-0.and.nPos1!=0 cData := Substr(MsgRetWs,nPos+Len(cNode)+2,nPos1-(nPos+Len(cNode)+2)) Endif RETURN( cData ) FUNCTION GRAVA_DADOS() // PONHA A ORIGINAL RETURN NIL // FIN / END [/code] Regards, saludos. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.