Bala okanye Buza umgama oMkhulu weSangqa phakathi kweeNqaku zoBude kunye noBunde usebenzisa iFomula yeHaversine (PHP, Python, MySQL, MSSQL Imizekelo)

Ifomula yeHaversine - Umgama oMkhulu weSangqa - PHP, Python, MySQL

Kule nyanga bendicwangcise kancinci kwi-PHP nakwi-MySQL ngokubhekisele kwi-GIS. Ukulala ujikeleze umnatha, bendinobunzima ekufumaneni ezinye ze Ubalo lwejografi ukufumana umgama phakathi kweendawo ezimbini ke ndifuna ukwabelana ngazo apha.

Imephu yokubhabha eYurophu ngokuHamba ngeSangqa

Indlela elula yokubala umgama phakathi kwamanqaku amabini isebenzisa ifomula yePythagorean ukubala i-hypotenuse kanxantathu (A² + B² = C²). Oku kwaziwa njenge Umgama we-Euclidean.

Esi sisiqalo esinomdla kodwa asisebenzi ngeJografi kuba umgama phakathi kwemigca yobude nobude imigama engalinganiyo ngaphandle. Njengokuba usondela kwiikhweyitha, imigca yesibanzi iya isiba phakathi. Ukuba usebenzisa uhlobo oluthile lwe-equation triangulation elula, inokulinganisa umgama ngokuchanekileyo kwindawo enye kwaye iphosakele kwenye, ngenxa yomjikelo woMhlaba.

Umjikelo omkhulu weSangqa

Iindlela ezihamba umgama omde ujikeleze uMhlaba zaziwa njenge Umjikelo omkhulu weSangqa. Oko kukuthi... owona mgama umfutshane phakathi kwamanqaku amabini kwingqukuva wahlukile kunamanqaku akwimephu ethe tyaba. Dibanisa loo nto nento yokuba imigca yesibanzi neside ayilingani… kwaye unezibalo ezinzima.

Nantsi ingcaciso emnandi yevidiyo yendlela esebenza ngayo iSangqa esiKhulu

Ifomula yeHaversine

Umgama usebenzisa ukugobeka komhlaba ubandakanyiwe Ifomula yeHaversine, esebenzisa itrigonometri ukuvumela ukugobeka komhlaba. Xa ufumana umgama phakathi kweendawo ezi-2 emhlabeni (njengoko inomyayi ubhabha), umgca othe tye uyi-arc.

Oku kuyasebenza kwindiza yenqwelomoya-ukhe wajonga kwimephu yeenqwelo moya kwaye waqaphela ukuba zi-arched? Kungenxa yokuba mfutshane ukubhabha kwi-arch phakathi kwamanqaku amabini kunokuya ngqo kwindawo.

I-PHP: Bala umgama phakathi kwamanqaku ama-2 e-Latitude kunye ne-Longitude

Nantsi ifomula ye-PHP yokubala umgama phakathi kwamanqaku amabini (kunye ne-Mile vs. Ukuguqulwa kweKilomitha) ijikelezwe kwiindawo ezimbini zedesimali.

function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2, $unit = 'miles') {
  $theta = $longitude1 - $longitude2; 
  $distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); 
  $distance = acos($distance); 
  $distance = rad2deg($distance); 
  $distance = $distance * 60 * 1.1515; 
  switch($unit) { 
    case 'miles': 
      break; 
    case 'kilometers' : 
      $distance = $distance * 1.609344; 
  } 
  return (round($distance,2)); 
}

Izinto eziguquguqukayo zezi:

  • $ Isibanzi1 – into eguquguqukayo yesibanzi sendawo yakho yokuqala.
  • $Ubude1 – into eguquguqukayo yelongitude yendawo yakho yokuqala
  • $ Isibanzi2 – into eguquguqukayo yesibanzi sendawo yakho yesibini.
  • $Ubude2 – into eguquguqukayo yelongitude yendawo yakho yesibini.
  • Iyunithi ye-$ – umntu omiselweyo mawaka. Oku kungahlaziywa okanye kugqithiswe njenge iikhilomitha.

IPython: Bala umgama phakathi kwamanqaku ama-2 obude kunye nobude

Ngapha koko, nantsi ifomula yePython yokubala umgama phakathi kwamanqaku amabini (kunye neMile vs. Ukuguqulwa kweKilomitha) isondezwe kwiindawo ezimbini zedesimali. Ityala kunyana wam, uBill Karr oyiNzululwazi yeDatha OpenINIGHTS, yekhowudi.

from numpy import sin, cos, arccos, pi, round

def rad2deg(radians):
    degrees = radians * 180 / pi
    return degrees

def deg2rad(degrees):
    radians = degrees * pi / 180
    return radians

def getDistanceBetweenPointsNew(latitude1, longitude1, latitude2, longitude2, unit = 'miles'):
    
    theta = longitude1 - longitude2
    
    distance = 60 * 1.1515 * rad2deg(
        arccos(
            (sin(deg2rad(latitude1)) * sin(deg2rad(latitude2))) + 
            (cos(deg2rad(latitude1)) * cos(deg2rad(latitude2)) * cos(deg2rad(theta)))
        )
    )
    
    if unit == 'miles':
        return round(distance, 2)
    if unit == 'kilometers':
        return round(distance * 1.609344, 2)

Izinto eziguquguqukayo zezi:

  • isibanzi1 -utshintsho lwendawo yakho yokuqala ububanzi.
  • ubude1 -utshintsho lwendawo yakho yokuqala ubude
  • isibanzi2 -utshintsho lwendawo yakho yesibini ububanzi.
  • ubude2 -utshintsho lwendawo yakho yesibini ubude.
  • iyunithi – umntu omiselweyo mawaka. Oku kungahlaziywa okanye kugqithiswe njenge iikhilomitha.

I-MySQL: Ukubuyisela zonke iiRekhodi ngaphakathi koLuhlu ngokubala umgama kwii-Miles usebenzisa i-Latitude kunye ne-Longitude

Kuyenzeka ukuba usebenzise i-SQL ukwenza ukubala ukufumana zonke iirekhodi kumgama othile. Kulo mzekelo, ndiza kubuza i-MyTable kwi-MySQL ukufumana zonke iirekhodi ezingaphantsi okanye ezilinganayo kumgama oguqulweyo weedola (kwiiMayile) kwindawo endikuyo kububanzi be- $ nobude be- $:

Umbuzo wokufumana kwakhona zonke iirekhodi ngaphakathi kwendawo ethile umgama ngokubala umgama kwiimayile phakathi kwamanqaku amabini obude nobude:

$query = "SELECT *, (((acos(sin((".$latitude."*pi()/180)) * sin((`latitude`*pi()/180)) + cos((".$latitude."*pi()/180)) * cos((`latitude`*pi()/180)) * cos(((".$longitude."- `longitude`)*pi()/180)))) * 180/pi()) * 60 * 1.1515) as distance FROM `table` WHERE distance <= ".$distance."

Kuya kufuneka ukuba wenze ngokwezifiso oku:

  • $ ubude -Ukuhluka kwe-PHP apho ndidlula kubude benqaku.
  • $ Ububanzi -Ukuhluka kwe-PHP apho ndidlula kubude benqaku.
  • $ Umgama - lo ngumgama ongathanda ukufumana iirekhodi ezingaphantsi okanye ezilinganayo.
  • itafile - le yitafile… uya kufuna ukuyibuyisela ngegama lakho letafile.
  • ububanzi -Le yintsimi yesibanzi sakho.
  • ubude - le yintsimi yobude bakho.

I-MySQL: Ukubuyisela zonke iiRekhodi ngaphakathi koLuhlu ngokubala umgama kwiikhilomitha usebenzisa i-Latitude kunye ne-Longitude

Nanku umbuzo we-SQL usebenzisa iikhilomitha kwi-MySQL:

$query = "SELECT *, (((acos(sin((".$latitude."*pi()/180)) * sin((`latitude`*pi()/180)) + cos((".$latitude."*pi()/180)) * cos((`latitude`*pi()/180)) * cos(((".$longitude."- `longitude`) * pi()/180)))) * 180/pi()) * 60 * 1.1515 * 1.609344) as distance FROM `table` WHERE distance <= ".$distance."

Kuya kufuneka ukuba wenze ngokwezifiso oku:

  • $ ubude -Ukuhluka kwe-PHP apho ndidlula kubude benqaku.
  • $ Ububanzi -Ukuhluka kwe-PHP apho ndidlula kubude benqaku.
  • $ Umgama - lo ngumgama ongathanda ukufumana iirekhodi ezingaphantsi okanye ezilinganayo.
  • itafile - le yitafile… uya kufuna ukuyibuyisela ngegama lakho letafile.
  • ububanzi -Le yintsimi yesibanzi sakho.
  • ubude - le yintsimi yobude bakho.

Ndisebenzise le khowudi kwiqonga lemephu yeshishini esalisebenzisa kwivenkile ethengisa ngeendawo ezingaphezu kwe-1,000 XNUMX kuMntla Merika kwaye yasebenza kakuhle.

Umgama weJografi weMicrosoft SQL Server: STDistance

Ukuba usebenzisa iMicrosoft SQL Server, babonelela ngomsebenzi wabo, STDistance ekubaleni umgama phakathi kwamanqaku amabini kusetyenziswa uhlobo lwedatha yeJografi.

DECLARE @g geography;  
DECLARE @h geography;  
SET @g = geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326);  
SET @h = geography::STGeomFromText('POINT(-122.34900 47.65100)', 4326);  
SELECT @g.STDistance(@h);  

Ingcebiso yomnqwazi kuManash Sahoo, iVP kunye noMyili we Highbridge.

77 Comments

  1. 1

    Enkosi kakhulu ngokwabelana. Lo ibingumsebenzi olula wokukhuphela kwaye uncamathisele kwaye usebenza kakuhle. Undigcine ixesha elininzi.
    I-FYI kuye nabani na othumela ku-C:
    i-deg2rad ephindwe kabini (i-double deg) {i-deg yokubuyela * (3.14159265358979323846 / 180.0); }

  2. 2

    Isiqwenga esihle kakhulu sokuposa - sisebenze kakuhle kakhulu - kuye kwafuneka nditshintshe igama letafile ebambe i-lat-long. Isebenza ngokukhawuleza uku.. Ndinenani elincinane elinengqiqo le-lat-longs (< 400) kodwa ndicinga ukuba oku kungalinganisa kakuhle. Indawo entle kakhulu-ndiye ndayifaka kwiakhawunti yam ye-del.icio.us kwaye ndiya kuphinda ndijonge rhoqo.

  3. 4
  4. 5
  5. 8

    Ndicinga ukuba iSQL yakho idinga ukuba nengxelo.
    endaweni yokuba APHO umgama <= $umgama onokuwufuna
    sebenzisa UKUBA nomgama <= $umgama

    kungenjalo ndiyabulela ngokundigcinela ixesha elininzi namandla.

  6. 10
  7. 11
  8. 12

    Enkosi kakhulu ngokwabelana ngale khowudi. Indisindise ixesha elininzi lophuhliso. Kwakhona, ndiyabulela kubafundi bakho ngokuchaza ukuba i-HAVING statement iyimfuneko kwi-MySQL 5.x. Uncedo kakhulu.

  9. 14
  10. 15
  11. 16

    Ndiphinde ndafumanisa ukuba i-WHERE ayindisebenzelanga. Itshintshe ibe yi-HAVING kwaye yonke into isebenza ngokugqibeleleyo. Ekuqaleni andizange ndiwafunde amagqabantshintshi kwaye ndiphinde ndibhale kwakhona ndisebenzisa indawo ekhethiweyo. Zombini ziya kusebenza kakuhle.

  12. 17
  13. 18

    Iluncedo kakhulu, enkosi kakhulu! Ndandineengxaki nge-"HAVING" entsha, kunokuba "APHO", kodwa ndakuba ndifunde amagqabantshintshi apha (emva kwesiqingatha seyure yokusila amazinyo ngokukhungatheka = P), ndayifumana isebenza kakuhle. Enkosi ^_^

  14. 19
  15. 20

    Gcina ukhumbule ukuba inkcazo ekhethiweyo enjalo iya kuba nzima kakhulu kwaye icothe. Ukuba unemibuzo emininzi, inokwenza izinto zibe phantsi ngokukhawuleza.

    Indlela engqongqo kakhulu kukusebenzisa eyokuqala (ekrwada) ekhethiweyo usebenzisa indawo e-SQUARE echazwa ngumgama obalwayo oko kukuthi “khetha * kwigama letafile apho isibanzi phakathi kwe-lat1 ne-lat2 nobude phakathi kwe-lon1 ne-lon2”. i-lat1 = i-target latitude - i-latdiff, i-lat2 = i-targetletitude + i-latdiff, efana ne-lon. latdiff ~= umgama / 111 (yeekhilomitha), okanye umgama/69 kwiimayile ukusukela kwidigri e-1 yesibanzi yi- ~ 111 km (utshintsho oluncinci ukusukela oko umhlaba unombhoxo kancinane, kodwa wanele le njongo). londiff = umgama / (abs(cos(deg2rad(latitude))*111)) — okanye 69 yeemayile (ungathatha isikwere esikhulu kancinci ukuze uphendule ngokwahluka). Emva koko thatha isiphumo saloo nto kwaye uyondle kwi-radial ekhethiweyo. Ungalibali nje ukunika ingxelo ngolungelelwaniso olungaphandle kwemida – okt uluhlu lwelongitudi eyamkelekileyo yi -180 ukuya +180 kunye noluhlu lwesibanzi esamkelekileyo ngu -90 ukuya +90 — kwimeko apho i-latdiff okanye ilondiff yakho ibaleka ngaphandle kolu luhlu. . Qaphela ukuba kwiimeko ezininzi oku akunakusebenza kuba kuchaphazela kuphela izibalo ngaphaya komgca wepacific ocean ukusuka kwipali ukuya kwipali, nangona inqumla inxalenye ye-chukotka kunye nenxalenye yeAlaska.

    Esikufezayo koku kukuncitshiswa okubonakalayo kwenani lamanqaku owenze lo ubalo. Ukuba unesigidi seengongoma zehlabathi kwisiseko sedatha esisasazwe ngokulinganayo ngokulinganayo kwaye ufuna ukukhangela ngaphakathi kwe-100 km, ngoko uphendlo lwakho lokuqala (olukhawulezayo) lolwendawo eyi-10000 sq km kwaye luza kuvelisa malunga neziphumo ezingama-20 (ngokusekwe kunikezelo olulinganayo ngaphezulu kwe indawo engaphezulu malunga ne-500M sq km), okuthetha ukuba ubaleka umgama onzima wokubala amaxesha angama-20 kulo mbuzo endaweni yesigidi samaxesha.

    • 21
      • 22

        Ingcebiso emangalisayo! Ngenene ndisebenze nomphuhlisi obhale umsebenzi otsale ingaphakathi lesikwere kwaye emva koko umsebenzi ophindaphindayo owenza 'izikwere' ukujikeleza umjikelezo ukubandakanya nokukhuphela ngaphandle amanqaku ashiyekileyo. Isiphumo yaba sisiphumo esikhawulezayo esimangalisayo - wayenokuvavanya izigidi zamanqaku kwi-microseconds.

        Indlela yam engentla ngokuqinisekileyo 'ikrwada' kodwa iyakwazi. Enkosi kwakhona!

        • 23

          UDoug,

          Kudala ndizama ukusebenzisa i-mysql kunye ne-php ukuvavanya ukuba inqaku elide lingaphakathi kwepolygon. Ngaba uyazi ukuba umhlobo wakho womphuhlisi upapashe nayiphi na imizekelo malunga nendlela yokuphumeza lo msebenzi. Okanye ngaba uyazi nayiphi na imizekelo emihle. Ndiyabulela kwangoko.

  16. 24

    Molweni nonke luvavanyo lwam lwe-SQL ingxelo:

    SELECT DISTINCT area_id, (
    (
    (
    acos( sin( ( 13.65 * pi( ) /180 ) ) * sin( (
    `lat_dec` * pi( ) /180 ) ) + cos( ( 13.65 * pi( ) /180 ) ) * cos( (
    `lat_dec` * pi( ) /180 )
    ) * cos( (
    ( 51.02 - `lon_dec` ) * pi( ) /180 )
    )
    )
    ) *180 / pi( )
    ) *60 * 1.1515 * 1.609344
    ) AS distance
    FROM `post_codes` WHERE distance <= 50

    kwaye iMysql indixelela ukuba umgama, awukho njengekholamu, ndingasebenzisa umyalelo, ndingayenza ngaphandle kwe-WHERE, kwaye iyasebenza, kodwa kungekhona nayo ...

  17. 26

    Oku kuhle, nangona kunjalo kufana nje neentaka. Kuya kuba kuhle ukuzama ukubandakanya i-API yeemephu ze-google kule ngandlela-thile (mhlawumbi ukusebenzisa iindlela njl.) Ukunika nje ingcamango usebenzisa indlela eyahlukileyo yokuthutha. Kusafuneka ndenze umsebenzi wokulinganisa owenziweyo kwi-PHP oza kukwazi ukunika isisombululo esisebenzayo kwingxaki yomthengisi ohambahambayo. Kodwa ndicinga ukuba ndingaphinda ndisebenzise enye ikhowudi yakho ukwenza njalo.

  18. 27
  19. 28

    Inqaku elilungileyo! Ndifumene amanqaku amaninzi achaza indlela yokubala umgama phakathi kwamanqaku amabini kodwa ngokwenene ndandijonge i-snippet ye-SQL.

  20. 29
  21. 30
  22. 31
  23. 32
  24. 36

    Iintsuku ezi-2 zophando ukuze ekugqibeleni ndifumane eli phepha elisombulula ingxaki yam. Kubonakala ngathi ndingakhupha iWolframAlpha yam kwaye ndiphucule kwizibalo zam. Utshintsho ukusuka PHI ukuya ku-HAVING inescript sam sisebenza ngokulandelelana. ENKOSI

  25. 37
  26. 39

    Akwaba eli ibiliphepha lokuqala endilifumene kweli. Emva kokuzama imiyalelo emininzi eyahlukileyo le yayikuphela kwayo yokusebenza ngokufanelekileyo, kunye notshintsho oluncinci olufunekayo ukulingana nedatabase yam.
    Ndiyabulela kakhulu!

  27. 40

    Akwaba eli ibiliphepha lokuqala endilifumene kweli. Emva kokuzama imiyalelo emininzi eyahlukileyo le yayikuphela kwayo yokusebenza ngokufanelekileyo, kunye notshintsho oluncinci olufunekayo ukulingana nedatabase yam.
    Ndiyabulela kakhulu!

  28. 41
  29. 42
  30. 43
  31. 45
  32. 46
  33. 47

    Ndiyazi ukuba le fomula iyasebenza, kodwa andiboni apho iradiyasi yomhlaba ithathelwa ingqalelo. Ngaba ukhona umntu onokundikhanyisela, nceda?

  34. 49
  35. 50
  36. 52
  37. 53
  38. 55
  39. 56
  40. 58

    enkosi ngokuthumela eli nqaku liluncedo,  
    kodwa ngesizathu esithile ndingathanda ukubuza
    ungawufumana njani umgama phakathi kweekhonkco ngaphakathi kwe-mysql db kunye neekhonkco ezifakwe kwiphp ngumsebenzisi?
    ukuchaza ngokucacileyo ngakumbi:
    1.umsebenzisi kufuneka afake i- [id] ukukhetha idata ekhankanyiweyo kwi-db kunye neekhowudi zabasebenzisi
    2.ifayile yephp ifumana idatha ekujoliswe kuyo (iikhonkco) usebenzisa i [id] kwaye emva koko ubale umgama phakathi komsebenzisi kunye nendawo ekujoliswe kuyo.

    okanye ungafumana nje umgama ukusuka kwikhowudi engezantsi?

    $qry = “KHETHA *,(((acos(sin((“.$latitude.”*pi()/180)) * sin((`Latitude`*pi()/180))+cos((“. $isibanzi.”*pi()/180)) * cos((`I-Latitude`*pi()/180)) * cos(((“.$longitude.”- `Ubude`)*pi()/180) )))*180/pi())*60*1.1515*1.609344) njengomgama UKUSUKA `MyTable` APHO umgama >= “.$distance.” >>>>ndingakwazi “ukukhupha” umgama ukusuka apha?
    Enkosi kwakhona,
    UTimmy S

  41. 60

    ok, yonke into endiyizamile ayisebenzi. Ndiyathetha, into endinayo iyasebenza, kodwa imigama ikude lee.

    Ngaba kukho umntu onokubona ukuba yintoni engalunganga ngale khowudi?

    ukuba(isset($_POST['submitted'])){ $z = $_POST['zipcode']; $r = $_POST['irediyo']; phinda “Iziphumo ze “.$z; $sql = mysql_query(“KHETHA DIISTINCT m.zipcode, m.MktName,m.LocAddSt,m.LocAddCity,m.LocAddState,m.x1,m.y1,m.verified,z1.lat,z2.lon,z1. isixeko,z1.state UKUSUKA mrk m, zip z1, zip z2 APHO m.zipcode = z1.zipcode KUNYE z2.zipcode = $z KUNYE (3963 * acos( truncate( sin( z2.lat / 57.2958 ) * isono( m. y1 / 57.2958 ) + cos( z2.lat / 57.2958 ) * cos( m.y1 / 57.2958 ) * cos( m.x1 / 57.2958 – z2.lon / 57.2958 ) , 8 ) ) <= $r ") okanye fa (mysql_error()); ngelixa($umqolo = mysql_fetch_array($sql)) {$store1 = $umqolo['MktName']."”; $store = $umqolo['LocAddSt'].””; $store .= $umqolo['LocAddCity'].”, “.$row['LocAddState'].” “.$umqolo['zipcode']; $ isibanzi1 = $umqolo['lat']; I-$ longitude1 = umqolo we-$['lon']; $ latitude2 = $umqolo['y1']; I-$ longitude2 = umqolo we-$['x1']; Isixeko se-$ = $ umqolo ['isixeko']; I-$ state = $umqolo['imeko']; $dis = getnew($latitude1, $longitude1, $latitude2, $longitude2, $unit = 'Mi'); // $ dis = umgama ($ lat1, $ lon1, $ lat2, $ lon2); $ verified = $ umqolo ['verified']; ukuba($verified =='1'){ echo “”; echo “”.$store.””; echo $dis. "i(ii)mayile kude"; i-echo ""; } enye {echo “”.$store.””; echo $dis. "i(ii)mayile kude"; i-echo ""; }}}

    imisebenzi yam.php ikhowudi yam
    umsebenzi getnew($latitude1, $longitude1, $longitude2, $longitude2, $unit = 'Mi') {$theta = $longitude1 – $longitude2; Umgama we-$= (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)) ); Umgama we-$ = acos (i-$ distance); Umgama we-$ = rad2deg (i-$ distance); Umgama we-$ = $ umgama * 60 * 1.1515; tshintsha (iyunithi ye-$) { case 'Mi': ikhefu; ityala 'Km' : $ umgama = $ umgama * 1.609344; } ukubuya (round($distance,2)); }

    ndiyakubulela kwangaphambili

  42. 61
  43. 62

    Molo Douglas, inqaku elihle. Ndifumene ingcaciso yakho yeengqikelelo zejografi kunye nekhowudi enomdla kakhulu. Ekuphela kwengcebiso yam iya kuba yindawo kwaye ujonge ikhowudi yokubonisa (njengeStackoverflow, umzekelo). Ndiyaqonda ukuba ufuna ukonga indawo, kodwa ikhowudi yokushiywa kwesithuba / ukufakwa ngaphakathi kuya kwenza kube lula kum, njengomdwebi wenkqubo, ukufunda nokucalula. Phofu, yinto encinci leyo. Qhubeka nomsebenzi omkhulu.

  44. 64
  45. 65
  46. 66
  47. 67
  48. 68
  49. 69
  50. 70

    ibonakala ikhawuleza (mysql 5.9) ukusebenzisa kabini ifomula ekukhetheni nalapho:
    $formula = “(((acos(sin(“.$latitude.”*pi()/180)) * sin((`Latitude`*pi()/180))+cos((“.$latitude. ”*pi()/180)) * cos((`Ubude`*pi()/180)) * cos(((“.$longitude.”- `Ubude`)*pi()/180)))) *180/pi())*60*1.1515*1.609344)”;
    $sql = 'KHETHA *, '.$ifomula.' njengomgama UKUSUKA kwitafile APHO '..$formula.' <= '.$umgama;

  51. 71
  52. 72

    Enkosi kakhulu ngokucheba eli nqaku.iluncedo kakhulu.
    I-PHP yaqala ukudalwa njengeqonga elilula lokubhala elibizwa ngokuba “Iphepha leKhaya loBuntu”. Kule mihla i-PHP (emfutshane ye-Hypertext Preprocessor) yenye yetekhnoloji ye-Microsoft ye-Active Server Pages (ASP).

    I-PHP lulwimi olukwicala lomncedisi oluvulelekileyo olusetyenziselwa ukwenza amaphepha ewebhu aguqukayo. Inokuthi ifakwe kwi-HTML. I-PHP idla ngokusetyenziswa ngokudityaniswa nesiseko sedata seMySQL kwiiseva zewebhu zeLinux/UNIX. Mhlawumbi lolona lwimi ludumileyo lokubhala.

  53. 73

    Ndifumene isisombululo esingentla singasebenzi kakuhle.
    Kufuneka nditshintshele ku:

    $qqq = “KHETHA *,(((acos(sin((“.$latitude.”*pi()/180)) * sin((`latt`*pi()/180))+cos((” . $ isibanzi . “*pi()/180)) * cos((`latt`*pi()/180)) * cos(((” . $longitude . “- `longt`)*pi()/180) )))*180/pi())*60*1.1515) njengomgama UKUSUKA `kubhaliso` “;

  54. 75
  55. 76

    Molo, ndicela ngokwenene uncedo lwakho kule nto.

    Ndenze isicelo sokufumana iseva yam yewebhu http://localhost:8000/users/findusers/53.47792/-2.23389/20/
    53.47792 = i-$ latitude
    -2.23389 = i-$ longitude
    kunye nama-20 = umgama endifuna ukuwuthatha

    Nangona kunjalo usebenzisa ifomula yakho, ifumana yonke imiqolo kwidb yam

    $ iziphumo = DB :: khetha( DB :: ekrwada (“KHETHA *, (((acos(isono((“.$ latitude.”*pi()/180)) * isono((lat*pi()/180 ))+cos((“.$ isibanzi.”*pi()/180)) * cos((lat*pi()/180)) * cos(((“.$longitude.”- lng)*pi( )/180))))*180/pi())*60*1.1515*1.609344) njengomgama UKUSUKA abamakishi ABANOMgama>= “.$distance ));

    [{“id”:1,”igama”:”Frankie Johnnie & Luigo Too”,”idilesi”:”939 W El Camino Real, Mountain View, CA”,”lat”:37.386337280273,”lng”:-122.08582305908, ”umgama”:16079.294719663},{“id”:2,”igama”:”Amici's East Coast Pizzeria”,”idilesi”:”790 Castro St, Mountain View, CA”,”lat”:37.387138366699,”lng”: -122.08323669434,”umgama”:16079.175940152},{“id”:3,”igama”:”Kapp’s Pizza Bar & Grill”,”idilesi”:”191 Castro St, Mountain View, CA”,”lat”:37.393886566162 ”lng”:-122.07891845703,”umgama”:16078.381373826},{“id”:4,”igama”:”Round Table Pizza: Mountain View”,”idilesi”:”570 N Shoreline Blvd, Mountain View, CA”, ”lat”:37.402652740479,”lng”:-122.07935333252,”umgama”:16077.420540582},{“id”:5,”igama”:”Tony & Alba's Pizza & Pasta”,619idilesi,Mountain”:”37.394012451172 Jonga, CA”,”lat”:122.09552764893,”lng”:-16078.563225154,”umgama”:6},{“id”:4546,”igama”:“IPizza eBolwe Ngokhuni yeOregano”37.401725769043”: El Camino Real, Los Altos, CA”, lat”:122.11464691162,”lng”:-16077.937560795,”umgama”:7},{“ id":24,"igama":"Iibha kunye neegrill","idilesi":"53.485118865967 Whiteley Street, Manchester","lat":2.1828699111938,"lng":-8038.7620112314,"umgama":XNUMX}]

    Ndifuna ukubuyisela imiqolo nje ngeemayile ezingama-20 kodwa izisa yonke imiqolo. Ndicela ndenza wrongo

  56. 77

    Ndikhangela umbuzo ofanayo kodwa ndinyuke kancinci – ngokufutshane oku kukwenza amaqela zonke izilungelelanisi ngaphakathi kweemayile ezi-2 zolungelelwaniso ngalunye kwaye ke ubale ukuba zingaphi ulungelelwaniso kwiqela ngalinye kwaye kuphume iqela elinye elinezona zilungelelanisi zininzi – nokuba uneqela elingaphezulu kwesinye phakathi kwamaqela anelona nani lininzi labalungelelanisi - khupha nje iqela elingenamkhethe kumaqela anenani elikhulu elifanayo -

Ingaba ucinga ntoni?

Le sayithi isebenzisa i-Akismet ukunciphisa ugaxekile. Funda indlela idatha yakho yokubhaliweyo isetyenziswe ngayo.