void Start() { ReduceStackTraceSpam(); StartPosition.Set(0f, 50f, 0f); switch (StartState) { case StartStateValue.AdenHD: StartPosition.Set(240.0f, 20.0f, -290.0f); StartEulerAngles.Set(0.0f, -70.0f, 0.0f); StartLOD = 4; GeographicBounds = new GeographicBounds(new GeographicCoordinates(12.75, 45.00), new GeographicCoordinates(12.85, 45.06)); break; case StartStateValue.UAVDemo: StartPosition.Set(-30.0f, 50.0f, -80.0f); StartEulerAngles.Set(20.0f, 0.0f, 0.0f); //StartLOD = 0; StartLOD = 4; GeographicBounds = new GeographicBounds(new GeographicCoordinates(39.04, -85.55), new GeographicCoordinates(39.06, -85.50)); // GS LOD = 4 (2-3) // GT LOD = 1 break; case StartStateValue.DUET: StartPosition.Set(0.0f, 40.0f, 0.0f); GeographicBounds = new GeographicBounds(new GeographicCoordinates(47.58, -122.39), new GeographicCoordinates(47.64, -122.30)); StartLOD = 2; break; } }
public void UpdateElevations(GeographicBounds bounds) { // iterate through all models in bounds and update elevation var coords = new CartesianCoordinates(); foreach (var node in DataByNode) { if (node.Key.GeographicBounds.MinimumCoordinates.Latitude > bounds.MaximumCoordinates.Latitude) { continue; } if (node.Key.GeographicBounds.MinimumCoordinates.Longitude > bounds.MaximumCoordinates.Longitude) { continue; } if (node.Key.GeographicBounds.MaximumCoordinates.Latitude < bounds.MinimumCoordinates.Latitude) { continue; } if (node.Key.GeographicBounds.MaximumCoordinates.Longitude < bounds.MinimumCoordinates.Longitude) { continue; } foreach (var go in node.Value.GameObjects) { var position = go.transform.position; coords.X = position.x; coords.Y = position.z; var location = coords.TransformedWith(Database.Projection); float elev = Database.TerrainElevationAtLocation(location); go.transform.position = new Vector3(position.x, elev, position.z); } } }
public QuadTreeNode AddChild(GeographicBounds bounds) { var node = new QuadTreeNode(this, 0, bounds); Children.Add(node); return(node); }
public List <Tile> Generate(GeographicBounds bounds, LOD lod) { var result = new List <Tile>(); int isouth = bounds.MinimumCoordinates.TileLatitude; int iwest = bounds.MinimumCoordinates.TileLongitude; int inorth = bounds.MaximumCoordinates.TileLatitude; int ieast = bounds.MaximumCoordinates.TileLongitude; int rows = lod.Rows; int cols = lod.Columns; double rowHeight = 1.0f / rows; for (int ilat = isouth; ilat <= inorth; ++ilat) { Latitude latitude = ilat; int ilon_step = latitude.TileWidth; double col_width = (double)ilon_step / cols; for (int ilon = iwest; ilon <= ieast; ilon += ilon_step) { for (uint uref = 0; uref < rows; ++uref) { double tile_south = ilat + (rowHeight * uref); if (tile_south >= bounds.MaximumCoordinates.Latitude) { continue; } double tile_north = ilat + (rowHeight * (uref + 1)); if (tile_north <= bounds.MinimumCoordinates.Latitude) { continue; } for (uint rref = 0; rref < cols; ++rref) { double tile_west = ilon + (col_width * rref); if (tile_west >= bounds.MaximumCoordinates.Longitude) { continue; } double tile_east = ilon + (col_width * (rref + 1)); if (tile_east <= bounds.MinimumCoordinates.Longitude) { continue; } var tile = new Tile() { Bounds = new GeographicBounds( new GeographicCoordinates(tile_south, tile_west), new GeographicCoordinates(tile_north, tile_east) ), LOD = lod, uref = uref, rref = rref }; result.Add(tile); } } } } return(result); }
private void HandleStateChange(object sender, EventArgs e) { string selectedCode = _currentState.SelectedItem.ToString(); StateCode code = (StateCode)Enum.Parse(typeof(StateCode), selectedCode); GeographicBounds bounds = _translator.BoundsForState(code); _latitude.Minimum = bounds.MinimumLatitude; _latitude.Maximum = bounds.MaximumLatitude; _longitude.Minimum = bounds.MinimumLongitude; _longitude.Maximum = bounds.MaximumLongitude; }
public void GetData(string url, string desiredLayer, string desiredFormat, GeographicBounds bounds, out Dictionary <BruTile.TileInfo, byte[]> tiles) { WmsCapabilities wmsCapabilities = null; ITileSource tileSource = null; tiles = null; string baseUrl = url + "?SERVICE=WMS"; string capUrl = baseUrl + "&REQUEST=GetCapabilities"; if (GetCapabilities(capUrl, out wmsCapabilities)) { var version = wmsCapabilities.Version; //string firstLayer = wmsCapabilities.Capability.Layer.ChildLayers[0].Name; var formats = wmsCapabilities.Capability.Request.GetMap.Format; if (VerboseLogging) { PrintFormats(ref formats, true); } bool found = false; foreach (string format in formats) { if (format.ToLower().EndsWith(desiredFormat)) { found = true; break; } } if (found && GetMap(baseUrl, version.VersionString, desiredLayer, bounds, desiredFormat, out tileSource)) { string levelId = "0"; // desired zoom level Extent extent = new Extent(bounds.MinimumCoordinates.Longitude, bounds.MinimumCoordinates.Latitude, bounds.MaximumCoordinates.Longitude, bounds.MaximumCoordinates.Latitude); Process(tileSource, extent, out tiles, levelId); } else { Console.WriteLine("GetMap failed."); } } else { Console.WriteLine("GetCapabilities failed."); } }
private void GeocodingTest4_Click(object sender, EventArgs e) { GeographicBounds limit = new GeographicBounds() { SouthWest = new GeographicLocation(-35.0418205762627, 16.3491015625), NorthEast = new GeographicLocation(-21.9971918060098, 33.0483203125) }; var response = _gMapsWrapper.RunGeocoder(txtGeocoding.Text, "za", limit); if (response.Status == ServiceResponseStatus.Ok) { if (response.Results.Count > 0) { var bounds = response.Results[0].Geometry.ViewPort; _gMapsWrapper.FitToBounds(bounds); } } }
private void _gMapsWrapper_CenterChanged(GeographicLocation obj) { GeographicBounds limit = new GeographicBounds() { SouthWest = new GeographicLocation(-35.0418205762627, 16.3491015625), NorthEast = new GeographicLocation(-21.9971918060098, 33.0483203125) }; if (cbLimitMap.Checked) { bool changed = false; if (obj.Latitude < limit.SouthWest.Latitude - 0.1) { changed = true; obj.Latitude = limit.SouthWest.Latitude; } else if (obj.Latitude > limit.NorthEast.Latitude + 0.1) { changed = true; obj.Latitude = limit.NorthEast.Latitude; } if (obj.Longitude < limit.SouthWest.Longitude - 0.1) { changed = true; obj.Longitude = limit.SouthWest.Longitude; } else if (obj.Longitude > limit.NorthEast.Longitude + 0.1) { changed = true; obj.Longitude = limit.NorthEast.Longitude; } if (changed) { _gMapsWrapper.Center = obj; } } lblCenter.Text = obj.ToString(); lblLastEvent.Text = "Center_Changed"; }
private bool GetMap(string url, string version, string layer, GeographicBounds bounds, string imageType, out ITileSource tileSource) { if (string.IsNullOrEmpty(imageType)) { tileSource = null; return(false); } Extent extent = new Extent(bounds.MinimumCoordinates.Longitude, bounds.MinimumCoordinates.Latitude, bounds.MaximumCoordinates.Longitude, bounds.MaximumCoordinates.Latitude); var schema = new GlobalSphericalMercator(imageType, YAxis.OSM, null, null, extent); schema.Validate(); var request = new WmscRequest(new Uri(url), schema, layers: new[] { layer }.ToList(), styles: new[] { "" }.ToList(), version: version); var provider = new HttpTileProvider(request); tileSource = new TileSource(provider, schema); return(tileSource != null); }
private void _gMapsWrapper_BoundsChanged(GeographicBounds obj) { lblLastEvent.Text = "Bounds_Changed"; }
public void AddChild(GeographicBounds bounds) => Children.Add(new QuadTreeNode(Root, Depth + 1, bounds));
public QuadTreeNode(QuadTree root, int depth, GeographicBounds bounds) { Root = root; Depth = depth; GeographicBounds = bounds; }
public void Initialize(Database database, GeographicBounds bounds) { Database = database; GeographicBounds = bounds; }
public CityDataConverter() { this.cityDataReader = (CityDataReader)FactoryDataReader.GetInstance(FactoryDataReader.AvailableDataReaderTypes.CITY); this.geoBounds = (GeographicBounds)BoundsFactory.GetInstance(BoundsFactory.AvailableBoundsTypes.GEOGRAPHIC); }
void OnFileSelect(string path) { if (path.Length == 0) { return; } this.path = path; Destroy(cdbGameObject); if (ApplicationState.GlobeViewer == null) { return; } cdbGameObject = Instantiate(cdbPrefab); cdbDatabase = cdbGameObject.GetComponent <Database>(); cdbDatabase.Initialize(path); if (!cdbDatabase.Exists) { Destroy(cdbGameObject); cdbGameObject = null; return; } cdbDatabase.name = cdbDatabase.DB.Name; directoryViewButton.GetComponentsInChildren <Text>()[0].text = cdbDatabase.name; if (ApplicationState.GeographicBounds != GeographicBounds.EmptyValue) { cdbDatabase.GeographicBounds = ApplicationState.GeographicBounds; } if (ApplicationState.StartPosition != Vector3.negativeInfinity) { UserObject.transform.position = ApplicationState.StartPosition; } if (ApplicationState.StartEulerAngles != Vector3.negativeInfinity) { UserObject.transform.eulerAngles = ApplicationState.StartEulerAngles; } if (ApplicationState.StartLOD != int.MinValue) { cdbLOD = ApplicationState.StartLOD; } var globeViewer = ApplicationState.GlobeViewer.GetComponent <Cognitics.Unity.BlueMarble.GlobeViewer>(); globeViewer.CenterAndFit( cdbDatabase.GeographicBounds.MinimumCoordinates.Latitude, cdbDatabase.GeographicBounds.MinimumCoordinates.Longitude, cdbDatabase.GeographicBounds.MaximumCoordinates.Latitude, cdbDatabase.GeographicBounds.MaximumCoordinates.Longitude, 2.0f); /* * globeViewer.FitBoundsToScreen(cdbDatabase.GeographicBounds.MinimumCoordinates.Latitude, cdbDatabase.GeographicBounds.MinimumCoordinates.Longitude, * cdbDatabase.GeographicBounds.MaximumCoordinates.Latitude, cdbDatabase.GeographicBounds.MaximumCoordinates.Longitude); */ int max_lod = 6; int dim = (int)Math.Floor(Math.Pow(2, max_lod)); var inventory = cdbDatabase.DB.Tiles.GeocellInventory(); var gsta = new Cognitics.Unity.BlueMarble.GeocellSparseTextureArray(inventory, dim); globeViewer.Model.GetComponent <MeshRenderer>().material.SetTexture("_DensityTex", gsta.MapTexture); globeViewer.Model.GetComponent <MeshRenderer>().material.SetTexture("_DensityTexArray", gsta.TextureArray); var androidColor = new Color32(255, 255, 255, 96); for (int row = 0; row < 180; ++row) { for (int col = 0; col < 360; ++col) { int gsta_index = gsta.TextureIndex(row - 90, col - 180); if (gsta_index == 0) { continue; } var bounds = new GeographicBounds(new GeographicCoordinates(row - 90, col - 180), new GeographicCoordinates(row - 90 + 1, col - 180 + 1)); var tiles = cdbDatabase.DB.Tiles.Generate(bounds, 0); var ds_inventory = cdbDatabase.DB.Tiles.DatasetInventory(tiles[0], cdbDatabase.DB.Imagery.YearlyVstiRepresentation, max_lod); var ds_pixels = new Color32[dim * dim]; for (int i = 0, c = dim * dim; i < c; ++i) { byte exp = (byte)Math.Floor(Math.Pow(2, ds_inventory[i])); byte value = (byte)(31 + exp); ds_pixels[i] = new Color32(value, value, value, 255); } gsta.SetTexturePixels(gsta_index, ds_pixels); #if UNITY_ANDROID globeViewer.GeocellTexture.Set(row - 90, col - 180, androidColor); #endif } } gsta.Apply(); //OnFileSelect2(path); }