longitudeToTileX method

  1. @override
int longitudeToTileX(
  1. double longitude
)
override

@param scaleFactor the scale factor for which the size of the world map should be returned. @return the horizontal and vertical size of the map in pixel at the given scale. @throws IllegalArgumentException if the given scale factor is < 1 Converts a longitude coordinate (in degrees) to the tile X number at a certain zoom level.

@param longitude the longitude coordinate that should be converted. @param zoomLevel the zoom level at which the coordinate should be converted. @return the tile X number of the longitude value.

Implementation

// double _mapSizeWithScaleFactor(double scaleFactor) {
//   assert(scaleFactor >= 1);
//   return (tileSize.toDouble() * (pow(2, Projection.scaleFactorToZoomLevel(scaleFactor))));
// }

/// Converts a longitude coordinate (in degrees) to the tile X number at a certain zoom level.
///
/// @param longitude the longitude coordinate that should be converted.
/// @param zoomLevel the zoom level at which the coordinate should be converted.
/// @return the tile X number of the longitude value.
@override
int longitudeToTileX(double longitude) {
  if (longitude == 180) {
    return (_scalefactor.scalefactor - 1).floor();
  }
  int result = ((longitude + 180) / 360 * _scalefactor.scalefactor).floor();
  return result;
}