|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Problem with my java method hello, I have a problem in my method I know how to continue to find the shortest distance and then extract cinques the nearest distance method must return cinques longitudes and latitudes with their cities to see my method that I have not yet Finally some things can give gaps public static String getMagasinProche(double lat,double lon){ double latitude; double longitude; String v; String chaine=""; double madistance; ArrayList distances=new ArrayList(); if(Magasins.c==null) etablirConnexion(); try{ Statement s=c.createStatement(); java.sql.ResultSet curseur=s.executeQuery("select latitude,longitude,nomville from liste_magasins"); ResultSetMetaData rsmd=curseur.getMetaData(); int nCol=rsmd.getColumnCount(); while(curseur.next()){ latitude=curseur.getDouble("latitude"); longitude=curseur.getDouble("longitude"); v=curseur.getString("nomville"); double latr=Math.toRadians(lat); double lonr=Math.toRadians(lon); double latituder=Math.toRadians(latitude); double longituder=Math.toRadians(longitude); double substrire=longituder-lonr; madistance=6378*Math.acos(Math.cos(latr)*Math.cos(latituder)*Math.cos(substrire)+Math.sin(latr)*Math .sin(latituder)); distances.add(madistance); Object obj=Collections.min(distances); }}catch(Exception e){System.out.println("erreur selection"+e); }return ; thank u |
#2
| |||
| |||
re: Problem with my java method what you typed is hard to understand-- even your question is hard to understand--- put code tags on your code to make it easier to read and tell us exactly what part of the program isn't working. I am a bit confused as to your question. |
#3
| |||
| |||
Re: Problem with my java method Thank you i have a probleme how return five latitude and logitude near of my latitude and logitude passed on my methode Code: public static String getMagasinProche(double lat,double lon){ double latitude; double longitude; String v; String chaine=""; double madistance; ArrayList distances=new ArrayList(); if(Magasins.c==null) etablirConnexion(); try{ Statement s=c.createStatement(); java.sql.ResultSet curseur=s.executeQuery("select latitude,longitude,nomville from liste_magasins"); ResultSetMetaData rsmd=curseur.getMetaData(); int nCol=rsmd.getColumnCount(); while(curseur.next()){ latitude=curseur.getDouble("latitude"); longitude=curseur.getDouble("longitude"); v=curseur.getString("nomville"); double latr=Math.toRadians(lat); double lonr=Math.toRadians(lon); double latituder=Math.toRadians(latitude); double longituder=Math.toRadians(longitude); double substrire=longituder-lonr; madistance=6378*Math.acos(Math.cos(latr)*Math.cos( latituder)*Math.cos(substrire)+Math.sin(latr)*Math .sin(latituder)); distances.add(madistance); Object obj=Collections.min(distances); }}catch(Exception e){System.out.println("erreur selection"+e); }return ; |
#4
| |||
| |||
Re: Problem with my java method why did you put public static string this line public static String getMagasinProche(double lat,double lon){ the static is stating that it will be a definite double double and once you go static it will not replace itself try public String getMagasinProche or public void String getMagasinProche |
![]() |
|
Tags: java |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Method execution problem in java | Elizabeth Allen | Software Development | 5 | 12-03-2010 12:51 PM |
Problem in using random method in java | Gunner 1 | Software Development | 5 | 13-02-2010 02:22 AM |
Clone method in Java | Joyjeet | Software Development | 5 | 16-01-2010 01:12 AM |
What is method overriding and method overloading in java | beelow | Software Development | 3 | 17-11-2009 08:20 AM |
Java: How can I call one method in another method? | biohazard 76 | Software Development | 3 | 16-07-2009 07:12 PM |