Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.dinopolis.gpstool.projection
Class FlatProjection  view FlatProjection download FlatProjection.java

java.lang.Object
  extended byOrthographic
      extended byorg.dinopolis.gpstool.projection.FlatProjection

public class FlatProjection
extends Orthographic

Implements the Flat projection for use of mapblast and expedia maps. The algorithms are mostly copied from Fritz Ganter's gpsdrive application. (http://gpsdrive.kraftvoll.at). As this class extends an openmap base projection, the usage might not be clear. The main methods are forward and inverse.

The forward method forwards latitude/longitude to screen coordinates, the inverse method the other way round. Usage:

java.awt.Point forward(float latitude, float longitude)
java.awt.Point forward(float latitude, float longitude, java.awt.point reuse)
java.awt.Point forward(com.bbn.openmap.LatLonPoint point)
java.awt.Point forward(com.bbn.openmap.LatLonPoint point, java.awt.Point reuse)
com.bbn.openmap.LatLonPoint inverse(int x, int y)
com.bbn.openmap.LatLonPoint inverse(int x, int y, com.bbn.openmap.LatLonPoint reuse)
com.bbn.openmap.LatLonPoint inverse(java.awt.Point screen_point, com.bbn.openmap.LatLonPoint reuse)

Version:
$Revision: 1.4 $

Field Summary
(package private)  LatLonPoint center_
           
static double DIFF_LATITUDE_FACT
           
static double EARTH_FLATTENING
           
(package private) static double[] earth_radius
           
static java.lang.String FlatProjectionName
          The name.
static int FlatProjectionType
          The type of projection.
(package private)  int height_
           
static double PIXELFACT
          scale / PIXELFACT gives meters per pixel (for mapblast)
d_screen [pixel] = d_map [m] * r_map [dpi] * (1/0.0254) in/m
d_map = d_real / scale
PIXELFACT = 72 dpi * 1/0.0254 in/m = 2834.65 pixel/m,
static double RADIUS_EQUATOR
           
static double RADIUS_POLAR
           
(package private)  float scale_
           
(package private)  int width_
           
 
Constructor Summary
FlatProjection(LatLonPoint center, float scale, int width, int height)
          Construct a LLXY projection.
FlatProjection(LatLonPoint center, float scale, int width, int height, int type)
           
 
Method Summary
protected  java.awt.Point _forward(float lat, float lon, java.awt.Point p, AzimuthVar az_var)
          Forward projects lat,lon into XY space and returns a Point.
static double calcEarthRadius(double latitude)
          Calculate the earth radius for the given latitude.
protected  void computeParameters()
          Called when some fundamental parameters change.
 void drawBackground(java.awt.Graphics g)
          Draw the background for the projection.
static java.awt.geom.Point2D forward(float reference_latitude, float reference_longitude, float latitude, float longitude)
          This method calculates the horizontal and vertical distance of two locations given in latitude and longitude.
static java.awt.geom.Point2D forward(float reference_latitude, float reference_longitude, float latitude, float longitude, float scale)
          This method calculates the horizontal and vertical distance of two locations given in latitude and longitude.
 java.lang.String getName()
          Get the name string of the projection.
static LatLonPoint inverse(double reference_latitude, double reference_longitude, double delta_x, double delta_y)
          This method calculates the longitude and latitude of a point that is located a given amount of meters in horizontal and vertical away.
static LatLonPoint inverse(double reference_latitude, double reference_longitude, double delta_x, double delta_y, double scale)
          This method calculates the longitude and latitude of a point that is located at a given numer of pixels in horizontal and vertical away.
 LatLonPoint inverse(int x, int y, LatLonPoint llp)
          Inverse project x,y coordinates into a LatLonPoint.
 LatLonPoint inverse(java.awt.Point pt, LatLonPoint llp)
          Inverse project a Point.
 boolean isPlotable(float lat, float lon)
          Checks if a LatLonPoint is plot-able.
static void main(java.lang.String[] args)
           
static double normalize_latitude_degree(double lat)
          Sets radian latitude to something sane.
 float normalize_latitude(float lat)
          Sets radian latitude to something sane.
 java.lang.String toString()
          Return stringified description of this projection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FlatProjectionName

public static final transient java.lang.String FlatProjectionName
The name.

See Also:
Constant Field Values

FlatProjectionType

public static final transient int FlatProjectionType
The type of projection.

See Also:
Constant Field Values

center_

LatLonPoint center_

scale_

float scale_

width_

int width_

height_

int height_

earth_radius

static double[] earth_radius

PIXELFACT

public static final double PIXELFACT
scale / PIXELFACT gives meters per pixel (for mapblast)
d_screen [pixel] = d_map [m] * r_map [dpi] * (1/0.0254) in/m
d_map = d_real / scale
PIXELFACT = 72 dpi * 1/0.0254 in/m = 2834.65 pixel/m,

See Also:
Constant Field Values

RADIUS_EQUATOR

public static final double RADIUS_EQUATOR
See Also:
Constant Field Values

RADIUS_POLAR

public static final double RADIUS_POLAR
See Also:
Constant Field Values

EARTH_FLATTENING

public static final double EARTH_FLATTENING
See Also:
Constant Field Values

DIFF_LATITUDE_FACT

public static final double DIFF_LATITUDE_FACT
See Also:
Constant Field Values
Constructor Detail

FlatProjection

public FlatProjection(LatLonPoint center,
                      float scale,
                      int width,
                      int height)
Construct a LLXY projection.


FlatProjection

public FlatProjection(LatLonPoint center,
                      float scale,
                      int width,
                      int height,
                      int type)
Method Detail

toString

public java.lang.String toString()
Return stringified description of this projection.


computeParameters

protected void computeParameters()
Called when some fundamental parameters change. Each projection will decide how to respond to this change. For instance, they may need to recalculate "constant" paramters used in the forward() and inverse() calls.


normalize_latitude

public float normalize_latitude(float lat)
Sets radian latitude to something sane.


normalize_latitude_degree

public static double normalize_latitude_degree(double lat)
Sets radian latitude to something sane.


isPlotable

public boolean isPlotable(float lat,
                          float lon)
Checks if a LatLonPoint is plot-able. A point is always plot-able in the LLXY projection.


_forward

protected java.awt.Point _forward(float lat,
                                  float lon,
                                  java.awt.Point p,
                                  AzimuthVar az_var)
Forward projects lat,lon into XY space and returns a Point.


inverse

public LatLonPoint inverse(java.awt.Point pt,
                           LatLonPoint llp)
Inverse project a Point.


inverse

public LatLonPoint inverse(int x,
                           int y,
                           LatLonPoint llp)
Inverse project x,y coordinates into a LatLonPoint.


getName

public java.lang.String getName()
Get the name string of the projection.


forward

public static java.awt.geom.Point2D forward(float reference_latitude,
                                            float reference_longitude,
                                            float latitude,
                                            float longitude,
                                            float scale)
This method calculates the horizontal and vertical distance of two locations given in latitude and longitude. The result is in pixels on the screen. The closer the two locations are, the more accurate is the result! A kind of flat projection is used. The algorithm is taken from gpsdrive of Fritz Ganter (http://gpsdrive.kraftvoll.at)


forward

public static java.awt.geom.Point2D forward(float reference_latitude,
                                            float reference_longitude,
                                            float latitude,
                                            float longitude)
This method calculates the horizontal and vertical distance of two locations given in latitude and longitude. The closer the two locations are, the more accurate is the result! A kind of flat projection is used. The algorithm is taken from gpsdrive of Fritz Ganter (http://gpsdrive.kraftvoll.at)


inverse

public static LatLonPoint inverse(double reference_latitude,
                                  double reference_longitude,
                                  double delta_x,
                                  double delta_y)
This method calculates the longitude and latitude of a point that is located a given amount of meters in horizontal and vertical away. The algorithm is taken from gpsdrive of Fritz Ganter (http://gpsdrive.kraftvoll.at)


inverse

public static LatLonPoint inverse(double reference_latitude,
                                  double reference_longitude,
                                  double delta_x,
                                  double delta_y,
                                  double scale)
This method calculates the longitude and latitude of a point that is located at a given numer of pixels in horizontal and vertical away. The algorithm is taken from gpsdrive of Fritz Ganter (http://gpsdrive.kraftvoll.at)


drawBackground

public void drawBackground(java.awt.Graphics g)
Draw the background for the projection.


calcEarthRadius

public static double calcEarthRadius(double latitude)
Calculate the earth radius for the given latitude.


main

public static void main(java.lang.String[] args)