1: A Geographic Distance Calculator

Write an application to calculate a table of geographic distances. The input of your application is a file containing

the coordinates of cities in latitude / longitude pairs, where latitude and longitude are given in degrees and minutes,

as in:1

Edinburgh 55;57N 03;13W

London 51;30N 0;30W

NorthWalsham 52;50N 01;22E

Norwich 52;38N 01;18E

Notice that 1 degree = 60 minutes. The output should be a text fille containing a table of geographic distances in

kilometres:

Edinburgh 0.00 520.90 452.43 467.11

London 520.90 0.00 194.50 175.33

NorthWalsham 452.43 194.50 0.00 22.57

Norwich 467.11 175.33 22.57 0.00

The application should take the names of the input fille (giving the latitude / longitude coordinates) and the output

fille (into which the distance table is written) from the first and second command line parameter. For example, if

your project is called geodist and your input file is cities.txt, the command line

java -jar geodist.jar cities.txt distances.txt

should write the distance table into distances.txt.

The procedure for calculating distances in kilometres is: One degree of latitude corresponds to 111 kilometres. One

degree of longitude corresponds to 111 . cos('') kilometres, where '' is the latitude.2 For example, the coordinates

of Norwich in kilometres are (111 . 1:3 . cos(52:63 degrees) = 87:57 kilometres east of Greenwich''s longitude, 111 .

52:63 = 5842:28 kilometres north of the equator), those of North Walsham are (91:64, 5864:48).

The Euclidean distance between these two is

Square.route(87:57- 91:64)^2 + (5842:28- 5864:48)^2 = square.route(-4:07)^2 + (-22:2)^2 = 22:57

Your application should comprise a class that adequately represents the geographic location of a city

and provides good support for carrying out this calculation.

解决方案What have you accomplished on this problem alone? What code do you have? What ideas do you have?

I have nothing, kind of hoping some Really nice people on here could give me some ideas and help really.

I have nothing, kind of hoping some Really nice people on here could give me some ideas and help really.

Well first you need to do a design. What kind of design would you need to accomplish your task? What does the flow of information look like. At a high level what do you have to do?

- Read a file

- Tokenize and parse the input

- Do some calculations on it

- Then what?

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐