MapViewPosition.setLeftUpper constructor

MapViewPosition.setLeftUpper(
  1. MapViewPosition old,
  2. double left,
  3. double upper,
  4. Dimension viewDimension
)

Implementation

MapViewPosition.setLeftUpper(MapViewPosition old, double left, double upper, Dimension viewDimension)
    : zoomLevel = old.zoomLevel,
      indoorLevel = old.indoorLevel,
      tileSize = old.tileSize,
      scale = old.scale,
      focalPoint = old.focalPoint,
      _mercatorProjection = old._mercatorProjection {
  //calculateBoundingBox(tileSize, viewSize);
  _leftUpper = Mappoint(min(max(left, -viewDimension.width / 2), _mercatorProjection.mapSize - viewDimension.width / 2),
      min(max(upper, -viewDimension.height / 2), _mercatorProjection.mapSize - viewDimension.height / 2));

  double rightX = _leftUpper.x + viewDimension.width;
  double bottomY = _leftUpper.y + viewDimension.height;

  boundingBox = BoundingBox(
      _mercatorProjection.pixelYToLatitude(min(bottomY, _mercatorProjection.mapSize)),
      _mercatorProjection.pixelXToLongitude(max(_leftUpper.x, 0)),
      _mercatorProjection.pixelYToLatitude(max(_leftUpper.y, 0)),
      _mercatorProjection.pixelXToLongitude(min(rightX, _mercatorProjection.mapSize)));

  _latitude = _mercatorProjection.pixelYToLatitude(_leftUpper.y + viewDimension.height / 2);

  _longitude = _mercatorProjection.pixelXToLongitude(_leftUpper.x + viewDimension.width / 2);

  MercatorProjectionImpl.checkLatitude(_latitude);

  MercatorProjectionImpl.checkLongitude(_longitude);
}