Jeospace API

org.jeospace.projection
Class Equirectangular

java.lang.Object
  extended byorg.jeospace.projection.Equirectangular

public class Equirectangular
extends java.lang.Object

A simple Cylindrical Equidistant Projection of the world. This class provides utility methods for translating geographic coordinates to 2D points in the projection area and vice versa. This Equirectangular Projection differs slightly from the standard projection model in that it maps the 2D ( x, y ) points to a typical computer oriented two-dimensional projection coordinate system with the origin (0,0) at the top left corner and with ( x, y ) values increasing to the right and downward respectively.


                    prime meridian
                (0 degrees longitude)
 ( x=0, y=0 )             ^
      o-------------------|-------------------|
      |                   |                   |
      |                   |                   |
      |                   |                   |
      |                   |                   |         equator 
      |-------------------|-------------------| > (0 degrees latitude)
      |                   |                   |
      |                   |                   |
      |                   |                   |
      |                   |                   |
      |-------------------|-------------------o
                                     ( x=width, y=height )

 

Version:
$Revision: 1.1.1.1 $
Author:
Rex Melton

Constructor Summary
Equirectangular(int width, int height)
          Constructor
 
Method Summary
 int[][] createLineIndices(Ellipsoidal[] coordinate, int points_per_revolution_hint)
          Create 2D line segment points for the given set of coordinates.
 int[][] createPolyIndices(Ellipsoidal[] coordinate, boolean top)
          Create polygon indices for the given set of coordinates.
 int getHeight()
          Return the vertical (latitude) dimension of the projection.
 int getWidth()
          Return the horizontal (longitude) dimension of the projection.
 Spherical toCoordinate(int x, int y)
          Translate the argument 2D point into a 2 dimensional geographic coordinate corresponding to the point location on the projection.
 int[] toPoint(Polar p)
          Translate the coordinate to a point in the projection.
 int toPoint(Polar p, int[] val, int index)
          Translate the coordinate to a point in the projection and append it to the argument array at the specified index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Equirectangular

public Equirectangular(int width,
                       int height)
Constructor

Parameters:
width - The total span in points along the horizontal (longitude) dimension of the projection.
height - The total span in points along the vertical (latitude) dimension of the projection.
Method Detail

getWidth

public int getWidth()
Return the horizontal (longitude) dimension of the projection.

Returns:
the horizontal (longitude) dimension of the projection.

getHeight

public int getHeight()
Return the vertical (latitude) dimension of the projection.

Returns:
the vertical (latitude) dimension of the projection.

toPoint

public int[] toPoint(Polar p)
Translate the coordinate to a point in the projection.

Parameters:
p - The coordinate to translate to a point in the projection.
Returns:
The point in the projection that corresponds to the argument coordinate.

toPoint

public int toPoint(Polar p,
                   int[] val,
                   int index)
Translate the coordinate to a point in the projection and append it to the argument array at the specified index. This method is used in the generation of line sets that define paths or boundaries on the map projection.

Parameters:
p - The coordinate to translate to a point in the projection.
val - An array for appending the translated point
index - The index within the array for the first (x) coordinate to be appended.
Returns:
The index in the array following the appended 2D point.

toCoordinate

public Spherical toCoordinate(int x,
                              int y)
Translate the argument 2D point into a 2 dimensional geographic coordinate corresponding to the point location on the projection.

Parameters:
x - The x or horizontal dimension in the projection.
y - The y or vertical dimension in the projection.
Returns:
A Spherical coordinate containing the geographic latitude and longitude corresponding to the projection point. If the point is outside the bounds of the projection, null will be returned.

createLineIndices

public int[][] createLineIndices(Ellipsoidal[] coordinate,
                                 int points_per_revolution_hint)
Create 2D line segment points for the given set of coordinates. A new segment is created for each line that 'wraps' around the projection in the horizontal direction.

Parameters:
coordinate - An array of the sequence of Polar coordinates that defines the line to be drawn.
points_per_revolution_hint - A hint to the point generator describing how many coordinates will constitute a single line segment.
Returns:
an array of line segment arrays. i.e. - each contiguous line segment on the map will be returned in an int[] of ( x, y ) points each.

createPolyIndices

public int[][] createPolyIndices(Ellipsoidal[] coordinate,
                                 boolean top)
Create polygon indices for the given set of coordinates. A new segment is created for each portion of the polygon that 'wraps' around the projection in the horizontal direction.

Parameters:
coordinate - An array of the sequence of Polar coordinates that defines the line to be drawn.
top - Flag indicating which horizontal edge of the projection should be used to complete the polygon in the case that it extends over a polar region
Returns:
an array of arrays of polygon indices. i.e. - each contiguous polygon on the map will be returned in an int[] of ( x, y ) points each.

Jeospace API

Copyright © 2006 - jeospace.org