Unit OSM.SlippyMapUtils
Description
OSM map types & functions. Ref.: https://en.wikipedia.org/wiki/Tiled_web_map
based on unit by Simon Kroik, 06.2018, kroiksm@gmx.de which is based on unit openmap.pas https://github.com/norayr/meridian23/blob/master/openmap/openmap.pas New BSD License
(c) Fr0sT-Brutal https://github.com/Fr0sT-Brutal/Delphi_OSMMap
Overview
Classes, Interfaces, Objects and Records
Name | Description |
---|---|
Record TTile |
Properties of a map tile |
Record TGeoPoint |
Point on a map defined by longitude and latitude. |
Record TGeoRect |
Region on a map defined by two pairs of longitude and latitude. |
Functions and Procedures
function RectFromPoints(const TopLeft, BottomRight: TPoint): TRect; inline; |
function TileCount(Zoom: TMapZoomLevel): Cardinal; inline; |
function TileValid(const Tile: TTile): Boolean; inline; |
function TileToStr(const Tile: TTile): string; |
function TilesEqual(const Tile1, Tile2: TTile): Boolean; inline; |
function ToTileWidthLesser(Width: Cardinal): Cardinal; inline; |
function ToTileHeightLesser(Height: Cardinal): Cardinal; inline; |
function ToTileWidthGreater(Width: Cardinal): Cardinal; inline; |
function ToTileHeightGreater(Height: Cardinal): Cardinal; inline; |
function ToTileBoundary(const Rect: TRect): TRect; |
function MapWidth(Zoom: TMapZoomLevel): Cardinal; inline; |
function MapHeight(Zoom: TMapZoomLevel): Cardinal; inline; |
function InMap(Zoom: TMapZoomLevel; const Pt: TPoint): Boolean; overload; inline; |
function InMap(Zoom: TMapZoomLevel; const Rc: TRect): Boolean; overload; inline; |
function EnsureInMap(Zoom: TMapZoomLevel; const Pt: TPoint): TPoint; overload; inline; |
function EnsureInMap(Zoom: TMapZoomLevel; const Rc: TRect): TRect; overload; inline; |
function LongitudeToMapCoord(Zoom: TMapZoomLevel; Longitude: Double): Cardinal; |
function LatitudeToMapCoord(Zoom: TMapZoomLevel; Latitude: Double): Cardinal; |
function MapCoordToLongitude(Zoom: TMapZoomLevel; X: Cardinal): Double; |
function MapCoordToLatitude(Zoom: TMapZoomLevel; Y: Cardinal): Double; |
function MapToGeoCoords(Zoom: TMapZoomLevel; const MapPt: TPoint): TGeoPoint; overload; inline; |
function MapToGeoCoords(Zoom: TMapZoomLevel; const MapRect: TRect): TGeoRect; overload; inline; |
function GeoCoordsToMap(Zoom: TMapZoomLevel; const GeoCoords: TGeoPoint): TPoint; overload; inline; |
function GeoCoordsToMap(Zoom: TMapZoomLevel; const GeoRect: TGeoRect): TRect; overload; inline; |
function CalcLinDistanceInMeter(const Coord1, Coord2: TGeoPoint): Double; |
procedure GetScaleBarParams(Zoom: TMapZoomLevel; out ScalebarWidthInPixel, ScalebarWidthInMeter: Cardinal; out Text: string); |
Types
TMapZoomLevel = 0..20; |
PTile = ˆTTile; |
Constants
TILE_IMAGE_WIDTH = 256; |
TILE_IMAGE_HEIGHT = 256; |
TileMetersPerPixelOnEquator: array [TMapZoomLevel] of Double =
(
156412,
78206,
39103,
19551,
9776,
4888,
2444,
1222,
610.984,
305.492,
152.746,
76.373,
38.187,
19.093,
9.547,
4.773,
2.387,
1.193,
0.596,
0.298,
0.149
); |
MaxLong = 180.0; |
MinLong = -MaxLong; |
MaxLat = 85.0511; |
MinLat = -MaxLat; |
Description
Functions and Procedures
function RectFromPoints(const TopLeft, BottomRight: TPoint): TRect; inline; |
Construct |
function TileCount(Zoom: TMapZoomLevel): Cardinal; inline; |
Returns count of tiles on |
function TileValid(const Tile: TTile): Boolean; inline; |
Checks |
function TileToStr(const Tile: TTile): string; |
Returns standartized string representation of |
function TilesEqual(const Tile1, Tile2: TTile): Boolean; inline; |
Compares tiles |
function ToTileWidthLesser(Width: Cardinal): Cardinal; inline; |
Floor horizontal map coord to tile size |
function ToTileHeightLesser(Height: Cardinal): Cardinal; inline; |
Floor vertical map coord to tile size |
function ToTileWidthGreater(Width: Cardinal): Cardinal; inline; |
Ceil horizontal map coord to tile size |
function ToTileHeightGreater(Height: Cardinal): Cardinal; inline; |
Ceil vertical map coord to tile size |
function ToTileBoundary(const Rect: TRect): TRect; |
Align absolute map rect to tile boundaries |
function MapWidth(Zoom: TMapZoomLevel): Cardinal; inline; |
Returns width of map at zoom level |
function MapHeight(Zoom: TMapZoomLevel): Cardinal; inline; |
Returns height of map at zoom level |
function InMap(Zoom: TMapZoomLevel; const Pt: TPoint): Boolean; overload; inline; |
Checks if point |
function InMap(Zoom: TMapZoomLevel; const Rc: TRect): Boolean; overload; inline; |
Checks if rect |
function EnsureInMap(Zoom: TMapZoomLevel; const Pt: TPoint): TPoint; overload; inline; |
Ensures point ReturnsPoint that is inside a map |
function EnsureInMap(Zoom: TMapZoomLevel; const Rc: TRect): TRect; overload; inline; |
Ensures rect ReturnsRect that is inside a map |
function LongitudeToMapCoord(Zoom: TMapZoomLevel; Longitude: Double): Cardinal; |
Converts geo coord in degrees to map coord in pixels |
function LatitudeToMapCoord(Zoom: TMapZoomLevel; Latitude: Double): Cardinal; |
Converts geo coord in degrees to map coord in pixels |
function MapCoordToLongitude(Zoom: TMapZoomLevel; X: Cardinal): Double; |
Converts map coord in pixels to geo coord in degrees |
function MapCoordToLatitude(Zoom: TMapZoomLevel; Y: Cardinal): Double; |
Converts map coord in pixels to geo coord in degrees |
function MapToGeoCoords(Zoom: TMapZoomLevel; const MapPt: TPoint): TGeoPoint; overload; inline; |
Converts map point in pixels to geo point in degrees |
function MapToGeoCoords(Zoom: TMapZoomLevel; const MapRect: TRect): TGeoRect; overload; inline; |
Converts map rect in pixels to geo rect in degrees |
function GeoCoordsToMap(Zoom: TMapZoomLevel; const GeoCoords: TGeoPoint): TPoint; overload; inline; |
Converts geo point in degrees to map point in pixels |
function GeoCoordsToMap(Zoom: TMapZoomLevel; const GeoRect: TGeoRect): TRect; overload; inline; |
Converts geo rect in degrees to map rect in pixels |
function CalcLinDistanceInMeter(const Coord1, Coord2: TGeoPoint): Double; |
Calculates distance between two geo points in meters |
procedure GetScaleBarParams(Zoom: TMapZoomLevel; out ScalebarWidthInPixel, ScalebarWidthInMeter: Cardinal; out Text: string); |
Calculates parameters of map scalebar according to zoom level |
Types
TMapZoomLevel = 0..20; |
Map zoom. 20 = Maximum zoom among all tile providers |
PTile = ˆTTile; |
This item has no description. |
Constants
TILE_IMAGE_WIDTH = 256; |
Width of map tile in pixels |
TILE_IMAGE_HEIGHT = 256; |
Height of map tile in pixels |
TileMetersPerPixelOnEquator: array [TMapZoomLevel] of Double =
(
156412,
78206,
39103,
19551,
9776,
4888,
2444,
1222,
610.984,
305.492,
152.746,
76.373,
38.187,
19.093,
9.547,
4.773,
2.387,
1.193,
0.596,
0.298,
0.149
); |
See https://wiki.openstreetmap.org/wiki/Zoom_levels Level Degree Area m / pixel ~Scale # Tiles 0 360 whole world 156,412 1:500 million 1 1 180 78,206 1:250 million 4 2 90 39,103 1:150 million 16 3 45 19,551 1:70 million 64 4 22.5 9,776 1:35 million 256 5 11.25 4,888 1:15 million 1,024 6 5.625 2,444 1:10 million 4,096 7 2.813 1,222 1:4 million 16,384 8 1.406 610.984 1:2 million 65,536 9 0.703 wide area 305.492 1:1 million 262,144 10 0.352 152.746 1:500,000 1,048,576 11 0.176 area 76.373 1:250,000 4,194,304 12 0.088 38.187 1:150,000 16,777,216 13 0.044 village/town 19.093 1:70,000 67,108,864 14 0.022 9.547 1:35,000 268,435,456 15 0.011 4.773 1:15,000 1,073,741,824 16 0.005 small road 2.387 1:8,000 4,294,967,296 17 0.003 1.193 1:4,000 17,179,869,184 18 0.001 0.596 1:2,000 68,719,476,736 19 0.0005 0.298 1:1,000 274,877,906,944 20 0.00025 mid-sized bldng 0.149 1:5,00 1,099,511,627,776 |
MaxLong = 180.0; |
Maximal possible longitude (inclusive) |
MinLong = -MaxLong; |
Minimal possible longitude (inclusive) |
MaxLat = 85.0511; |
Maximal possible latitude for used Web Mercator projection (inclusive) |
MinLat = -MaxLat; |
Minimal possible latitude for used Web Mercator projection (inclusive) |
Author
Generated by PasDoc 0.16.0.