PixelProjection class

Pixel-based projection extending Mercator projection with screen coordinate support.

This class extends MercatorProjection to provide conversions between geographic coordinates and pixel coordinates on screen. It handles:

  • Geographic coordinates ↔ pixel coordinates
  • Pixel coordinates ↔ tile coordinates
  • Relative positioning within tiles
  • Distance and scale calculations

Key features:

  • Configurable tile size for different display densities
  • Cached calculations for performance
  • Relative coordinate calculations for tile rendering
  • Meter-per-pixel calculations for scale awareness
Inheritance

Constructors

PixelProjection(int zoomlevel)

Properties

hashCode int
The hash code for this object.
no setterinherited
mapsize int
the size of the whole map in mappixel. At scalefactor 1 (or zoomLevel 0) the _mapSize is equal to the tileSize.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scalefactor → Scalefactor
no setterinherited
tileSize double
The size of a tile in pixels. Each tile has the same width and height. This value is typically 256 or 512 pixels depending on display density.
final

Methods

boundaryAbsolute(Tile tile) MapRectangle
boundingBoxOfTile(Tile tile) BoundingBox
Calculates the geographic bounding box for a single tile.
inherited
boundingBoxOfTileNumbers(int top, int left, int bottom, int right) BoundingBox
inherited
boundingBoxOfTiles(Tile upperLeft, Tile lowerRight) BoundingBox
inherited
boundingBoxToRectangle(BoundingBox boundingBox) MapRectangle
getCenter(Tile tile) Mappoint
Returns the center point of the given tile in absolute pixel coordinates
getLeftUpper(Tile tile) Mappoint
Returns the top-left point of this tile in absolute pixel coordinates.
latitudeDiffPerPixel(double latitude, double pixelDiff) double
latitudeToPixelY(double latitude) double
Converts a latitude coordinate to the corresponding pixel Y coordinate.
latitudeToTileY(double latitude) int
Converts a latitude coordinate to the corresponding tile Y number.
inherited
latLonToPixel(ILatLong latLong) Mappoint
Calculates the absolute pixel position for a map size and tile size
longitudeToPixelX(double longitude) double
Converts a longitude coordinate (in degrees) to a pixel X coordinate at a certain zoom level.
longitudeToTileX(double longitude) int
@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 to the corresponding tile X number.
inherited
meterPerPixel(ILatLong latLong) double
returns the meters per pixel at the current zoomlevel. Returns 0 at +/-90°
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pixelRelativeToLeftUpper(ILatLong latLong, Mappoint leftUpper) MappointRelative
Calculates the absolute pixel position for a tile and tile size relative to origin
pixelRelativeToTile(ILatLong latLong, Tile tile) MappointRelative
Calculates the absolute pixel position for a tile and tile size relative to origin
pixelToLatLong(double pixelX, double pixelY) ILatLong
pixelXToLongitude(double pixelX) double
Converts a pixel X coordinate at a certain map size to a longitude coordinate.
pixelXToTileX(double pixelX) int
Converts a pixel X coordinate to the corresponding tile X number.
pixelYToLatitude(double pixelY) double
Converts a pixel Y coordinate to the corresponding latitude coordinate.
pixelYToTileY(double pixelY) int
Converts a pixel Y coordinate to the corresponding tile Y number.
tileXToLongitude(int tileX) double
Converts a tile X coordinate to the corresponding longitude (western edge).
inherited
tileYToLatitude(int tileY) double
Converts a tile Y coordinate to the corresponding latitude (northern edge).
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

calculateFittingZoomlevel(BoundingBox boundary, MapSize size) int
Find the maximum zoomLevel where the boundary fits in given the current screensize. This is an expensive operations since we probe each zoomLevel until we find the correct one. Use it sparingly.