0

Please check the code which i tried to write with the help of the link suggested by people below. Please tell whether i have implemented the logic correctly or not. I have pasted the data in excel sheet to see its plot on http://www.copypastemap.com/map.php `

import java.io.File;
import java.io.IOException;

import jxl.Workbook;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

public class FindingLatLongAlongACircle {
static double latitude= 35.306614; 
static double longitude= -80.7444093;
//static double circumofEarth= 40075000;
static double R=20;


public static void main(String[] args) throws IOException {
    File f= new File("C:\\Users\\Manu Chaudhary\\Desktop\\LatongAroundaPoint.xls");
    WritableWorkbook myexcel= Workbook.createWorkbook(f);
    WritableSheet mysheet= myexcel.createSheet("mysheet",0);

    int YAxis1=0;
    int YAxis2=0;
               //  Added now
    jxl.write.Label k1;
    jxl.write.Label k2;

     double angle=0;
     double angleRadian=0; 
    // double changeInLat;
     //double changeInLong;
     double dx;
     double dy;
     double final_latitude=0;
     double final_longitude=0;

     double delta_longitude;
     double delta_latitude;

        while(angle<360){
            angle=angle+15;
            angleRadian= Math.toRadians(angle);
            dx= R* Math.sin(angleRadian);
            dy= R* Math.cos(angleRadian);
            //changeInLat= (distance* Math.cos(angleRadian))/(circumofEarth* Math.cos(lat1));
            //changeInLong= (distance*Math.sin(angleRadian))/circumofEarth;

            //newLatitude= lat1+changeInLat;
            //newLongitude=long1+ changeInLong;
            delta_longitude= dx/(111320* Math.cos(latitude));
            delta_latitude= dy/110540;
            final_latitude= latitude+ delta_latitude;

            final_longitude=longitude+ delta_longitude;
            YAxis1++;
            YAxis2++;

            k1= new jxl.write.Label(0,YAxis1,Double.toString(final_latitude));
            k2= new jxl.write.Label(1,YAxis2,Double.toString(final_longitude));

                try {
                    mysheet.addCell(k1);
                } catch (RowsExceededException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (WriteException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                try {
                    mysheet.addCell(k2);
                } catch (RowsExceededException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (WriteException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }   

            System.out.println("The value of latitude at "+ angle + " angle is"+ final_latitude);
            System.out.println("The value of longitude at "+ angle + " angle is"+ final_longitude);


        }
        myexcel.write();

        try {
            myexcel.close();
                } catch (WriteException e) {

                e.printStackTrace();
            System.out.println("Finish");  
                }

        }


}

`Suppose i know the latitude and longitude of a point. Can i calculate the latitude and longitude all around the point(approx. 16 points) if i know the distance of separation? I searched the stackoverflow and found two useful links.

For making the question clear please see the Latitudes and longitudes required. Please help me with a code in python.

Manu
  • 177
  • 9
  • 1
    What are your ideas as to the formulas? Show us the code you have so far. The point of this site is not to have someone solve a general problem like this for you. Rather, you should give what you're doing a try so that you can show us some attempt you've made and have a more specific question. – CryptoFool Mar 23 '19 at 04:54
  • What are your ideas as to the formulas? Show us the code you have so far. The point of this site is not to have someone solve a general problem like this for you. Rather, you should give what you're doing a try so that you can show us some attempt you've made and have a more specific question. – CryptoFool Mar 23 '19 at 04:54
  • Please give me some link to understand the mathematical formula. – Manu Mar 23 '19 at 05:00
  • Huh? This isn't a site for free research. If someone happens to know it off hand, I guess it's ok to hope for that, but I think you should go do your own research. This Exchange is about programming, and computer stuff, not about geospatial relationships. For help on this forum, you should come with your domain knowledge in hand. – CryptoFool Mar 23 '19 at 06:17
  • Hey Steve, be a bit polite in your comments. This is just a programming problem. I have pasted a solution. Hopefully it is correct. – Manu Mar 23 '19 at 16:00
  • It wasn't a programming problem as you first stated it. A programming problem takes a well understood task, and only involves converting that task to automation. If you can't solve the problem on paper, it isn't yet a programming problem...it's still a domain problem. – CryptoFool Mar 23 '19 at 18:57

1 Answers1

0

This is just basic trig:

θ = angle of elevation in a triangle formed by connecting an outer dot to the center dot, then extending a 90º line horizontally from the center dot until an altitude can connect the two priorly drawn lines

ec = earth's circumference

distance•cos(θ)/(ec•cos(latitude)) = Δlong

distance•sin(θ)/ec = Δlat

Please attempt some code, this site isn't to have people do your homework.

Alec
  • 8,529
  • 8
  • 37
  • 63
  • I am not able to understand what exactly θ is? Please also tell how can i find the Cos of a Latitude? – Manu Mar 23 '19 at 05:21
  • I think you'd have better luck with this question on [Mathematics](https://math.stackexchange.com/). Once you get your formulas straight, write some code, and then come back here if you need help with your code. – CryptoFool Mar 23 '19 at 06:21
  • I have updated the question by writing the code using your formula. Please edit it. There is some error in the implementation i feel. – Manu Mar 23 '19 at 07:46
  • Why did you implement java code on a post tagged `python`? – Alec Mar 23 '19 at 07:48
  • Python is very new to me. If the logic implementation is correct, i will convert the code to python. – Manu Mar 23 '19 at 07:49
  • The first link you provided explains the logical implementation very clearly – Alec Mar 23 '19 at 07:52
  • Please give me a formula for this if possible. – Manu Mar 23 '19 at 08:03
  • Thanks Alec, your words were harsh, but the suggestion you gave worked for me. I am pasting a Java code for it. But the formula you suggested is missing something. – Manu Mar 23 '19 at 15:41
  • I didn't mean to be disrespectful. I may well have made a mistake in the formula, but the logic is correct. Good Luck! – Alec Mar 23 '19 at 15:42