/// <summary> Get a tile cover for the specified bounds and zoom. </summary> /// <param name="bounds"> Geographic bounding box.</param> /// <param name="zoom"> Zoom level. </param> /// <returns> The tile cover set. </returns> public static HashSet <CanonicalTileId> Get(GeoCoordinateBounds bounds, int zoom) { var tiles = new HashSet <CanonicalTileId>(); if (bounds.IsEmpty() || bounds.South > Constants.LatitudeMax || bounds.North < -Constants.LatitudeMax) { return(tiles); } var hull = GeoCoordinateBounds.FromCoordinates( new GeoCoordinate(Math.Max(bounds.South, -Constants.LatitudeMax), bounds.West), new GeoCoordinate(Math.Min(bounds.North, Constants.LatitudeMax), bounds.East)); var sw = CoordinateToTileId(hull.SouthWest, zoom); var ne = CoordinateToTileId(hull.NorthEast, zoom); // Scanlines. for (var x = sw.X; x <= ne.X; ++x) { for (var y = ne.Y; y <= sw.Y; ++y) { tiles.Add(new UnwrappedTileId(zoom, x, y).Canonical); } } return(tiles); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.Space(); string _notes = "The purpose of this example is to demonstrate a slippy map built with the sdk \n" + " using satellite imagery draped over geometry generated from terrain data.\n" + "At runtime an area that corresponds the specified lat/lon Northeast and Southwest coordinates\n" + "and zoom level will be created. \n" + "The area displayed will be determined by the zoom and bounding box.\n" + " mouse click and drag to pan the map in play mode.\n"; EditorGUILayout.HelpBox(_notes, MessageType.Info); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Southwest coordinate"); south.doubleValue = EditorGUILayout.DelayedDoubleField(south.doubleValue); west.doubleValue = EditorGUILayout.DelayedDoubleField(west.doubleValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Northeast coordinate"); north.doubleValue = EditorGUILayout.DelayedDoubleField(north.doubleValue); east.doubleValue = EditorGUILayout.DelayedDoubleField(east.doubleValue); EditorGUILayout.EndHorizontal(); var bounds = new GeoCoordinateBounds( new GeoCoordinate(south.doubleValue, west.doubleValue), new GeoCoordinate(north.doubleValue, east.doubleValue)); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Center coordinate"); EditorGUILayout.LabelField(bounds.Center.ToString()); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.IntSlider(zoom, 0, 20, new GUIContent("Zoom")); var tileCount = TileCover.Get(bounds, zoom.intValue).Count; EditorGUILayout.Space(); EditorGUILayout.LabelField("Tile count", tileCount.ToString()); if (tileCount > Map <RasterTile> .TileMax) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Too many tiles!", MessageType.Error); } EditorGUILayout.Space(); edge.floatValue = EditorGUILayout.FloatField("Tile edge", edge.floatValue); serializedObject.ApplyModifiedProperties(); DrawDefaultInspector(); }
/// <summary> /// Creates a bound from two arbitrary points. Contrary to the constructor, /// this method always creates a non-empty box. /// </summary> /// <param name="a"> The first point. </param> /// <param name="b"> The second point. </param> /// <returns> The convex hull. </returns> public static GeoCoordinateBounds FromCoordinates(GeoCoordinate a, GeoCoordinate b) { var bounds = new GeoCoordinateBounds(a, a); bounds.Extend(b); return(bounds); }
void FetchWorldData(GeoCoordinate coordinates) { _tileScale = _tileWidthInVoxels / MapboxConvenience.GetTileScaleInMeters((float)coordinates.Latitude, _zoom); var bounds = new GeoCoordinateBounds(); bounds.Center = coordinates; _raster.SetGeoCoordinateBoundsZoom(bounds, _zoom); _elevation.SetGeoCoordinateBoundsZoom(bounds, _zoom); }
/// <summary> /// Initializes a new instance of the <see cref="T:Mapbox.Map.Map`1"/> class. /// </summary> /// <param name="fs"> The data source abstraction. </param> public Map(IFileSource fs) { this.fs = fs; this.latLngBounds = new GeoCoordinateBounds(); this.zoom = 0; }
/// <summary> /// Sets the coordinates bounds and zoom at once. More efficient than /// doing it in two steps because it only causes one map update. /// </summary> /// <param name="bounds"> Coordinates bounds. </param> /// <param name="zoom"> Zoom level. </param> public void SetGeoCoordinateBoundsZoom(GeoCoordinateBounds bounds, int zoom) { this.latLngBounds = bounds; this.zoom = zoom; this.Update(); }
/// <summary> Extend the bounding box to contain the bounding box. </summary> /// <param name="bounds"> A bounding box. </param> public void Extend(GeoCoordinateBounds bounds) { this.Extend(bounds.SouthWest); this.Extend(bounds.NorthEast); }