* @param wmtSource
* @return
*/
public NASATile getTileFromCoordinate(double lat, double lon,
WMTZoomLevel zoomLevel, WMTSource wmtSource) {
NASASource nasaSource = (NASASource) wmtSource;
// normalize latitude and longitude
lat = WMTTileFactory.normalizeDegreeValue(lat, 90);
lon = WMTTileFactory.normalizeDegreeValue(lon, 180);
lat = WMTTileFactory.moveInRange(lat,
nasaSource.getBounds().getMinY(), nasaSource.getBounds().getMaxY());
lon = WMTTileFactory.moveInRange(lon,
nasaSource.getBounds().getMinX(), nasaSource.getBounds().getMaxX());
NASAZoomLevel nasaZoomLevel = (NASAZoomLevel) zoomLevel;
int row = (int) Math.abs((lat - nasaSource.getBounds().getMaxY()) / nasaZoomLevel.getHeightInWorldUnits());
int col = (int) Math.abs((lon - nasaSource.getBounds().getMinX()) / nasaZoomLevel.getWidthInWorldUnits());
WMTPlugin.debug("[NASATile.getTileFromCoordinate] " + zoomLevel.getZoomLevel() + //$NON-NLS-1$
"/" + col + "/" + row + " lon: " + lon + " lat: " + lat, Trace.NASA); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
return new NASATile(col, row, nasaZoomLevel, (NASASource) wmtSource);