forked from MapComplete/MapComplete
		
	Add possibility to load external data as mercator tiles, add bbox tile possibilities, add CRAB and GRB as datasources in the GRB theme
This commit is contained in:
		
							parent
							
								
									e777776531
								
							
						
					
					
						commit
						d5f4572e9a
					
				
					 12 changed files with 254 additions and 61 deletions
				
			
		|  | @ -1,5 +1,6 @@ | |||
| import * as turf from "@turf/turf"; | ||||
| import {TileRange, Tiles} from "../Models/TileRange"; | ||||
| import {GeoOperations} from "./GeoOperations"; | ||||
| 
 | ||||
| export class BBox { | ||||
| 
 | ||||
|  | @ -22,7 +23,7 @@ export class BBox { | |||
|             this.minLon = Math.min(this.minLon, coordinate[0]); | ||||
|             this.minLat = Math.min(this.minLat, coordinate[1]); | ||||
|         } | ||||
|          | ||||
| 
 | ||||
|         this.maxLon = Math.min(this.maxLon, 180) | ||||
|         this.maxLat = Math.min(this.maxLat, 90) | ||||
|         this.minLon = Math.max(this.minLon, -180) | ||||
|  | @ -117,12 +118,12 @@ export class BBox { | |||
|     } | ||||
| 
 | ||||
|     pad(factor: number, maxIncrease = 2): BBox { | ||||
|          | ||||
| 
 | ||||
|         const latDiff = Math.min(maxIncrease / 2, Math.abs(this.maxLat - this.minLat) * factor) | ||||
|         const lonDiff =Math.min(maxIncrease / 2, Math.abs(this.maxLon - this.minLon) * factor) | ||||
|         const lonDiff = Math.min(maxIncrease / 2, Math.abs(this.maxLon - this.minLon) * factor) | ||||
|         return new BBox([[ | ||||
|             this.minLon - lonDiff, | ||||
|             this.minLat  - latDiff | ||||
|             this.minLat - latDiff | ||||
|         ], [this.maxLon + lonDiff, | ||||
|             this.maxLat + latDiff]]) | ||||
|     } | ||||
|  | @ -161,4 +162,16 @@ export class BBox { | |||
|         const boundslr = Tiles.tile_bounds_lon_lat(lr.z, lr.x, lr.y) | ||||
|         return new BBox([].concat(boundsul, boundslr)) | ||||
|     } | ||||
| 
 | ||||
|     toMercator(): { minLat: number, maxLat: number, minLon: number, maxLon: number } { | ||||
|         const [minLon, minLat] = GeoOperations.ConvertWgs84To900913([this.minLon, this.minLat]) | ||||
|         const [maxLon, maxLat] = GeoOperations.ConvertWgs84To900913([this.maxLon, this.maxLat]) | ||||
| 
 | ||||
|         return { | ||||
|             minLon, maxLon, | ||||
|             minLat, maxLat | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue