com.bbn.openmap.proj
Class LineCoordinateGenerator

java.lang.Object
  extended by com.bbn.openmap.proj.LineCoordinateGenerator

public class LineCoordinateGenerator
extends java.lang.Object

Generator class that connects simple coordinates with complex lines (great circle or rhumb). If you provide decimal degrees, the answer will be in decimal degrees. If coords are provided in radians, the answer will be in radians.

 Usage:
 
 double[] coords = new double[] { 30.0, -125.0, 30.0, -90.0, 15.0, -90.0, 15, -125.0, 30.0, -125.0 };
 double[] complexCoords = LineCoordinateGenerator.fromDegrees(coords).withSegmentsPerDegrees(10).greatCircleLineDoubles();
 
 

Author:
dietrick

Field Summary
static double DEFAULT_SEGS_PER_DEG
           
 
Method Summary
static LineCoordinateGenerator fromDegrees(double[] degrees)
          Create LCG with decimal degree coordinates.
static LineCoordinateGenerator fromRadians(double[] radians)
          Create LCG with radian coordinates.
 double[] greatCircleLineDoubles()
          Return the source coordinates connected by great circle lines
 java.awt.Shape greatCircleLineShape()
          Create a java.awt.Shape object of coordinates connected by great circle lines.
 double[] rhumbLineDoubles()
          Return the source coordinates connected by rhumb lines
 java.awt.Shape rhumbLineShape()
          Create a java.awt.Shape object of coordinates connected by rhumb lines.
 java.awt.Shape straightLineShape()
          Creates a Shape object from provided coordinates.
static java.util.List<double[]> toDoubles(java.awt.Shape s)
          Convert a Shape object into a List of double[].
 LineCoordinateGenerator withSegmentsPerDegrees(double spd)
          Set how complex the line is by setting how many segments per degree are used to approximate the curve.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SEGS_PER_DEG

public static final double DEFAULT_SEGS_PER_DEG
See Also:
Constant Field Values
Method Detail

fromRadians

public static LineCoordinateGenerator fromRadians(double[] radians)
Create LCG with radian coordinates.

Parameters:
radians - array of coordinates in radians, in lat, lon, lat, lon order.
Returns:
LCG

fromDegrees

public static LineCoordinateGenerator fromDegrees(double[] degrees)
Create LCG with decimal degree coordinates.

Parameters:
degrees - array of coordinates in degrees, in lat, lon, lat, lon order.
Returns:
LCG

withSegmentsPerDegrees

public LineCoordinateGenerator withSegmentsPerDegrees(double spd)
Set how complex the line is by setting how many segments per degree are used to approximate the curve.

Parameters:
spd - the default is 10 segments per degree
Returns:
this

greatCircleLineDoubles

public double[] greatCircleLineDoubles()
Return the source coordinates connected by great circle lines

Returns:
double[] in lat, lon, lat, lon order.

greatCircleLineShape

public java.awt.Shape greatCircleLineShape()
Create a java.awt.Shape object of coordinates connected by great circle lines.

Returns:
java.awt.Shape

rhumbLineDoubles

public double[] rhumbLineDoubles()
Return the source coordinates connected by rhumb lines

Returns:
double[] in lat, lon, lat, lon order.

rhumbLineShape

public java.awt.Shape rhumbLineShape()
Create a java.awt.Shape object of coordinates connected by rhumb lines.

Returns:
java.awt.Shape

straightLineShape

public java.awt.Shape straightLineShape()
Creates a Shape object from provided coordinates.

Returns:
java.awt.Shape

toDoubles

public static java.util.List<double[]> toDoubles(java.awt.Shape s)
Convert a Shape object into a List of double[]. Separate double[] are created in case there's a moveTo in the order of coordinates in Shape.

Parameters:
s - java.awt.Shape
Returns:
a List of double[]


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details