View Javadoc

1   /*
2    * @(#) LatLonToSmallMap.java Dec 6, 2004
3    * 
4    * 
5    * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
6    * Delft, the Netherlands. All rights reserved.
7    * 
8    * See for project information <a href="http://www.simulation.tudelft.nl/">
9    * www.simulation.tudelft.nl </a>.
10   * 
11   * The source code and binary code of this software is proprietary information
12   * of Delft University of Technology.
13   * 
14   */
15  package org.gscg.common.gui.images;
16  
17  import nl.tudelft.simulation.language.d3.DirectedPoint;
18  
19  /***
20   * <p>
21   * (c) copyright 2004 <a href="http://www.simulation.tudelft.nl">Delft
22   * University of Technology </a>, the Netherlands. <br>
23   * 
24   * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
25   * Delft, the Netherlands. All rights reserved.
26   * 
27   * See for project information <a href="http://www.simulation.tudelft.nl/">
28   * www.simulation.tudelft.nl </a>.
29   * 
30   * The source code and binary code of this software is proprietary information
31   * of Delft University of Technology.
32   * 
33   * @author <a
34   *         href="http://www.tbm.tudelft.nl/webstaf/stijnh/index.htm">Stijn-Pieter
35   *         van Houten </a>
36   * @version $Revision: 1.1 $ $Date: 2005/06/16 12:33:55 $
37   * @since 1.1.0 <br>
38   */
39  public final class LatLonToSmallMap
40  {
41  
42  	/***
43  	 * constructs a new LatLonToSmallMap
44  	 */
45  	protected LatLonToSmallMap()
46  	{
47  		// Utility class
48  		super();
49  	}
50  
51  	/***
52  	 * Method getSmallMapLocation returns a point reflecting the small map
53  	 * location for a player gui.
54  	 * 
55  	 * @param lat the latititude
56  	 * @param lon the longitude
57  	 * @param mapWidth the width of the map
58  	 * @param mapHeight the height of the map
59  	 * @return returns a small map location
60  	 */
61  	public static DirectedPoint getSmallMapLocation(final double lat,
62  			final double lon, final double mapWidth, final double mapHeight)
63  	{
64  		double width = 0.0;
65  		double height = 0.0;
66  		if (lon < 0)
67  		{
68  			height = ((lon + 90) / 90) * (mapHeight / 2);
69  		} else
70  		{
71  			height = ((90 - lon) / 90) * (mapHeight / 2);
72  		}
73  		if (lat < 0)
74  		{
75  			width = ((lat + 180) / 180) * (mapWidth / 2);
76  		} else
77  		{
78  			width = ((180 + lat) / 180) * (mapWidth / 2);
79  		}
80  		return new DirectedPoint(width, height, 0.0);
81  	}
82  }