Package org.insa.graphs.gui.drawing
Class MercatorProjection
- java.lang.Object
-
- org.insa.graphs.gui.drawing.MercatorProjection
-
- All Implemented Interfaces:
Projection
public class MercatorProjection extends java.lang.Object implements Projection
-
-
Field Summary
Fields Modifier and Type Field Description private double
height
private static double
IMAGE_HEIGHT
private static double
IMAGE_WIDTH
static double
MAX_LATITUDE
private static double
MAX_LATITUDE_PROJ
private float
maxLatitude
private double
maxLatitudeProj
private float
maxLongitude
static double
MIN_LATITUDE
private static double
MIN_LATITUDE_PROJ
private float
minLatitude
private double
minLatitudeProj
private float
minLongitude
private double
width
-
Constructor Summary
Constructors Constructor Description MercatorProjection(GraphStatistics.BoundingBox boundingBox, int maxSize)
Create a new MercatorProjection corresponding to the given BoundingBox and maxSize.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.awt.Dimension
computeImageSize(int maxSize)
Compute the dimension required for drawing a projection of the given box on an image, ensuring that none of the side of image is greater than maxSize.double
getImageHeight()
double
getImageWidth()
int
latitudeToPixelY(float latitude)
Project the given latitude on the image.int
longitudeToPixelX(float longitude)
Project the given longitude on the image.float
pixelXToLongitude(double px)
Retrieve the longitude associated to the given projected point.float
pixelYToLatitude(double py)
Retrieve the latitude associated to the given projected point.private static double
projectY(double latitude)
Compute the projection (without scaling) of the given latitude.
-
-
-
Field Detail
-
MAX_LATITUDE
public static final double MAX_LATITUDE
- See Also:
- Constant Field Values
-
MIN_LATITUDE
public static final double MIN_LATITUDE
- See Also:
- Constant Field Values
-
IMAGE_WIDTH
private static final double IMAGE_WIDTH
- See Also:
- Constant Field Values
-
IMAGE_HEIGHT
private static final double IMAGE_HEIGHT
- See Also:
- Constant Field Values
-
MAX_LATITUDE_PROJ
private static final double MAX_LATITUDE_PROJ
-
MIN_LATITUDE_PROJ
private static final double MIN_LATITUDE_PROJ
-
minLatitude
private final float minLatitude
-
minLongitude
private final float minLongitude
-
maxLatitude
private final float maxLatitude
-
maxLongitude
private final float maxLongitude
-
minLatitudeProj
private final double minLatitudeProj
-
maxLatitudeProj
private final double maxLatitudeProj
-
width
private final double width
-
height
private final double height
-
-
Constructor Detail
-
MercatorProjection
public MercatorProjection(GraphStatistics.BoundingBox boundingBox, int maxSize)
Create a new MercatorProjection corresponding to the given BoundingBox and maxSize.- Parameters:
boundingBox
- Box for this projection.maxSize
- Maximum size of any side (width / height) of the image to which this projection should draw.
-
-
Method Detail
-
projectY
private static double projectY(double latitude)
Compute the projection (without scaling) of the given latitude.- Parameters:
latitude
- Latitude to project.- Returns:
- Projection of the given latitude (without scaling).
-
computeImageSize
protected java.awt.Dimension computeImageSize(int maxSize)
Compute the dimension required for drawing a projection of the given box on an image, ensuring that none of the side of image is greater than maxSize.- Parameters:
maxSize
- Maximum side of any side of the image.- Returns:
- Dimension corresponding to the preferred size for the image.
-
getImageWidth
public double getImageWidth()
- Specified by:
getImageWidth
in interfaceProjection
- Returns:
- Image width for this projection to work properly.
-
getImageHeight
public double getImageHeight()
- Specified by:
getImageHeight
in interfaceProjection
- Returns:
- Image weight for this projection to work properly.
-
latitudeToPixelY
public int latitudeToPixelY(float latitude)
Description copied from interface:Projection
Project the given latitude on the image.- Specified by:
latitudeToPixelY
in interfaceProjection
- Parameters:
latitude
- Latitude to project.- Returns:
- Projected position of the latitude on the image.
-
longitudeToPixelX
public int longitudeToPixelX(float longitude)
Description copied from interface:Projection
Project the given longitude on the image.- Specified by:
longitudeToPixelX
in interfaceProjection
- Parameters:
longitude
- Longitude to project.- Returns:
- Projected position of the longitude on the image.
-
pixelYToLatitude
public float pixelYToLatitude(double py)
Description copied from interface:Projection
Retrieve the latitude associated to the given projected point.- Specified by:
pixelYToLatitude
in interfaceProjection
- Parameters:
py
- Projected y-position for which latitude should be retrieved.- Returns:
- The original latitude of the point.
-
pixelXToLongitude
public float pixelXToLongitude(double px)
Description copied from interface:Projection
Retrieve the longitude associated to the given projected point.- Specified by:
pixelXToLongitude
in interfaceProjection
- Parameters:
px
- Projected x-position for which longitude should be retrieved.- Returns:
- The original longitude of the point.
-
-