org.kaboum.util
Class KaboumPrecisionModel

java.lang.Object
  extended by org.kaboum.util.KaboumPrecisionModel

public class KaboumPrecisionModel
extends java.lang.Object

This class manage the map units and the precision Model Some parts of this code are rewritten from JTS PrecisionModel class (cf. http://www.vividsolutions.com)

Author:
Jérôme Gasperi aka jrom

Field Summary
 int DPI
          Dots per inch = 72
 double magicalNumber
          This is used to computed scale
static int MS_ARE
           
static int MS_DD
           
static int MS_HECTARE
           
static int MS_KILOMETERS
           
static int MS_METERS
          Constants definition
static int MS_SQUARE_METERS
          Surface definition
 double scale
          Precision scale
 java.lang.String sUnit
           
 java.lang.String xStrUnit
          Used to create the formated text output
 java.lang.String yStrUnit
           
 
Constructor Summary
KaboumPrecisionModel()
          Constructor
KaboumPrecisionModel(int unitType, float precision)
          Constructor
KaboumPrecisionModel(int unitType, float precision, int surfaceType, float surfacePrecision)
          Constructor
 
Method Summary
 java.lang.String getArea(double area)
          Return a string representation of an area expressed in internals coordinates
 double getDistance(KaboumCoordinate coordA, KaboumCoordinate coordB)
          Return the distance between two point in meters.
 double getMagicalNumber()
          Get the magicalNumber
 java.lang.String getNumberFormated(double number)
          Return a formated output from an input number
 java.lang.String getPerimeter(double perimeter)
          Return a string representation of a perimeter expressed in internals coordinates
static double makePrecise(double val)
          Return an integered value of val
static int sToSurface(java.lang.String str)
          Convert an input string to the corresponding int value
static int sToUnit(java.lang.String str)
          Convert an input string to the corresponding int value
 KaboumCoordinate toExternal(double xInternal, double yInternal)
          Sets external to the external representation of internal
 KaboumCoordinate toExternal(KaboumCoordinate internal)
          Sets external to the external representation of internal
 KaboumCoordinate toInternal(double xExternal, double yExternal)
          Sets internal to the precise representation of external
 KaboumCoordinate toInternal(KaboumCoordinate external)
          Sets internal to the precise representation of external
 java.lang.String writeMapCoords(KaboumCoordinate internal)
          Return the formated output of the pointer in map coordinate assuming the current unit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MS_METERS

public static final int MS_METERS
Constants definition

See Also:
Constant Field Values

MS_KILOMETERS

public static final int MS_KILOMETERS
See Also:
Constant Field Values

MS_DD

public static final int MS_DD
See Also:
Constant Field Values

MS_SQUARE_METERS

public static final int MS_SQUARE_METERS
Surface definition

See Also:
Constant Field Values

MS_ARE

public static final int MS_ARE
See Also:
Constant Field Values

MS_HECTARE

public static final int MS_HECTARE
See Also:
Constant Field Values

scale

public double scale
Precision scale


DPI

public final int DPI
Dots per inch = 72

See Also:
Constant Field Values

magicalNumber

public double magicalNumber
This is used to computed scale


xStrUnit

public java.lang.String xStrUnit
Used to create the formated text output


yStrUnit

public java.lang.String yStrUnit

sUnit

public java.lang.String sUnit
Constructor Detail

KaboumPrecisionModel

public KaboumPrecisionModel()
Constructor


KaboumPrecisionModel

public KaboumPrecisionModel(int unitType,
                            float precision)
Constructor


KaboumPrecisionModel

public KaboumPrecisionModel(int unitType,
                            float precision,
                            int surfaceType,
                            float surfacePrecision)
Constructor

Method Detail

writeMapCoords

public java.lang.String writeMapCoords(KaboumCoordinate internal)
Return the formated output of the pointer in map coordinate assuming the current unit.

Parameters:
external - Coordinate (in internal representation)

makePrecise

public static double makePrecise(double val)
Return an integered value of val


toInternal

public KaboumCoordinate toInternal(double xExternal,
                                   double yExternal)
Sets internal to the precise representation of external

Parameters:
x - External representation of x coordinate
y - External representation of x coordinate

toExternal

public KaboumCoordinate toExternal(double xInternal,
                                   double yInternal)
Sets external to the external representation of internal

Parameters:
x - Internal representation of x coordinate
y - Internal representation of x coordinate

toInternal

public KaboumCoordinate toInternal(KaboumCoordinate external)
Sets internal to the precise representation of external

Parameters:
external - the original coordinate

toExternal

public KaboumCoordinate toExternal(KaboumCoordinate internal)
Sets external to the external representation of internal

Parameters:
internal - the original coordinate

sToUnit

public static int sToUnit(java.lang.String str)
Convert an input string to the corresponding int value


sToSurface

public static int sToSurface(java.lang.String str)
Convert an input string to the corresponding int value


getDistance

public double getDistance(KaboumCoordinate coordA,
                          KaboumCoordinate coordB)
Return the distance between two point in meters. The calculation for points in geographical coordinates only works for close points since it assume the mean latitude between these two points as the disance reference.

Parameters:
coordA - Coordinate A (internal representation)
coordB - Coordinate B (internal representation)

getMagicalNumber

public double getMagicalNumber()
Get the magicalNumber


getNumberFormated

public java.lang.String getNumberFormated(double number)
Return a formated output from an input number


getArea

public java.lang.String getArea(double area)
Return a string representation of an area expressed in internals coordinates


getPerimeter

public java.lang.String getPerimeter(double perimeter)
Return a string representation of a perimeter expressed in internals coordinates



Copyright © 2005 Kaboum team. All Rights Reserved.