Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-11-2009
Member
 
Join Date: Nov 2008
Posts: 25
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
Reply With Quote
  #2  
Old 16-11-2009
Member
 
Join Date: Feb 2009
Posts: 96
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.
Reply With Quote
  #3  
Old 16-11-2009
Member
 
Join Date: Nov 2008
Posts: 25
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 ;
thank you
Reply With Quote
  #4  
Old 17-11-2009
Member
 
Join Date: Feb 2009
Posts: 96
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem with my java method"
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


All times are GMT +5.5. The time now is 07:29 AM.