Results 1 to 4 of 4

Thread: Problem with my java method

  1. #1
    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

  2. #2
    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.

  3. #3
    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

  4. #4
    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

Similar Threads

  1. Method execution problem in java
    By Elizabeth Allen in forum Software Development
    Replies: 5
    Last Post: 12-03-2010, 12:51 PM
  2. Problem in using random method in java
    By Gunner 1 in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 02:22 AM
  3. Clone method in Java
    By Joyjeet in forum Software Development
    Replies: 5
    Last Post: 16-01-2010, 01:12 AM
  4. What is method overriding and method overloading in java
    By beelow in forum Software Development
    Replies: 3
    Last Post: 17-11-2009, 08:20 AM
  5. Java: How can I call one method in another method?
    By biohazard 76 in forum Software Development
    Replies: 3
    Last Post: 16-07-2009, 07:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,559,323.82075 seconds with 16 queries