public async void OnTapAndHold(LatLonAlt latLonAlt) { if (ReferenceEquals(MapSession.Current, null) || string.IsNullOrEmpty(MapSession.Current.DeveloperKey)) { Debug.LogError( "Provide a Bing Maps key to use the map services. " + "This key can be set on a MapSession component."); return; } var finderResult = await MapLocationFinder.FindLocationsAt(latLonAlt.LatLon); string formattedAddressString = null; if (finderResult.Locations.Count > 0) { formattedAddressString = finderResult.Locations[0].Address.FormattedAddress; } if (_mapPinPrefab != null) { // Create a new MapPin instance at the specified location. var newMapPin = Instantiate(_mapPinPrefab); newMapPin.Location = latLonAlt.LatLon; var textMesh = newMapPin.GetComponentInChildren <TextMeshPro>(); textMesh.text = formattedAddressString ?? "No address found."; _mapPinLayer.MapPins.Add(newMapPin); } }
public VisualPushpin(int width, int height, string value, LatLonAlt position, object tag, string id) { style = PushpinInfo.Default; double num = 0; try { num = Double.Parse(value); style.Label = num.ToString("0.##"); } catch { style.Label = value; } style.HitDetect = HitDetectMode.None; style.ImageWidth = width; style.ImageHeight = height; style.BackColor = Color.FromArgb(0, Color.Blue); pushpin = new PushpinGeometry( Guid.NewGuid().ToString(), id, position, style); }
private void ActivateFlight() { airport = a_airportClass.getAirport("JFK"); a_flightlist = a_baseClass.getInformationForFlightVisualization("JFK", 3); texture = Texture.FromResource(typeof(BunnyActor).Assembly, "ActorDataSource.bunny.png"); a_dataSourcePlugin = new ActorDataSourcePlugIn(globleHost); b_builder = new BunnyBuilder(globleHost, texture, a_dataSourcePlugin.BindingsSource); LatLonAlt position = LatLonAlt.CreateUsingDegrees(airport.Latitude, airport.Longitude, 0); b_actors = b_builder.CreateBunnyActors(a_flightlist.Count, position); int index = 0; foreach (BunnyActor bactor in b_actors) { bactor.setDestination = LatLonAlt.CreateUsingDegrees( ((double)(a_flightlist[index].Destination.Latitude)), ((double)(a_flightlist[index].Destination.Longitude)), a_flightlist[index].Destination.Altitude); bactor.Flight = a_flightlist[index].Identity; index++; globleHost.Actors.Add(bactor); } //globleHost.Actors.Add(b_actors.GetEnumerator().Current); }
//Debug public void getMouseCoordinate() { var ray = camera.ScreenPointToRay(Input.mousePosition); if (Input.GetMouseButtonDown(0)) { temps = Time.time; click = true; longClickDone = false; } if (Input.GetMouseButtonUp(0)) { click = false; if ((Time.time - temps) < 0.2) { if (renderer.Raycast(ray, out MapRendererRaycastHit hitInfo)) { var hitpoint = hitInfo.Point; Debug.Log(renderer.TransformWorldPointToLatLon(hitpoint)); LatLonAlt latLonAlt = new LatLonAlt(renderer.TransformWorldPointToLatLon(hitpoint).LatitudeInDegrees, renderer.TransformWorldPointToLatLon(hitpoint).LongitudeInDegrees, 0); GenerateLatLonObject(latLonAlt); } } } }
public override void MoveCamera(Microsoft.MapPoint.Rendering3D.Scene.SceneState sceneState) { LatLonAlt lla = new LatLonAlt(fLat, fLon, fAlt); lla.Altitude += (lla.Altitude - lla.AltitudeAboveSeaLevel); this.Camera.Viewpoint.Position.Location = lla; this.Camera.Viewpoint.LocalOrientation.RollPitchYaw = new Microsoft.MapPoint.Geometry.VectorMath.RollPitchYaw(-fBank, -fPitch, Microsoft.MapPoint.Constants.TwoPI - fHeading); }
public override void Update(Microsoft.MapPoint.Rendering3D.Scene.SceneState sceneState) { if (needUpdate && newSegment != null) { CameraData data; if (sceneState.TryGetData <CameraData>(out data)) { double altitude = data.MetersAboveGround / 100.0; List <Vertex.PositionColored> vertices = new List <Vertex.PositionColored>(); LatLonAlt position = LatLonAlt.CreateUsingDegrees(newSegment.StartPoint.Y, newSegment.StartPoint.X, altitude); Vector3F vec = new Vector3F(position.GetVector()); vertices.Add(new Vertex.PositionColored(vec, lineColor.ToArgb())); foreach (System.Windows.Point point in newSegment.OtherPoints) { position = LatLonAlt.CreateUsingDegrees(point.Y, point.X, altitude); vec = new Vector3F(position.GetVector()); vertices.Add(new Vertex.PositionColored(vec, lineColor.ToArgb())); } mesh = new MeshGraphicsObject <Vertex.PositionColored, ushort>( GraphicsBufferUsage.Static, GraphicsBufferUsage.Static, vertices.Count, vertices.Count, true); Material material = new Material { AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White }; int id = mesh.Materials.Add(material); mesh.Vertices.AddData(vertices.ToArray()); List <ushort> indexData = new List <ushort>(); for (int i = 0; i < newSegment.OtherPoints.Count + 1; i++) { indexData.Add((ushort)i); } mesh.Indices.AddData(indexData.ToArray(), PrimitiveType.LineStrip, id); mesh.RenderState.Lighting.Enabled = false; mesh.RenderState.Cull.Enabled = false; oldSegment = newSegment; needUpdate = false; host.NeedUpdate(); } } base.Update(sceneState); }
public void addPin(LatLonAlt coord) { if (tmpPin == null) { tmpPin = new Pin(map.transform, pinPrefab, icons[1], -1, coord.LatLon, 0, null, 1); mapMenu[0].GetComponent <MapMenu>().active = true; map.GetComponent <MapRenderer>().Center = coord.LatLon; Handheld.Vibrate(); } }
public void LocationChanged(double groundElevation, double objectElevation) { LatLonAlt newLLA = Position; newLLA.Altitude += groundElevation; Vector = newLLA.GetVector(); LatLonAlt lla = new LatLonAlt(Vector); Valid = true; }
private List <Vertex.PositionColored> BuildVertices(PointSet pointSet, double altitude) { List <Vertex.PositionColored> vertices = new List <Vertex.PositionColored>(); double minT = 0, maxT = 0, k; if (!Double.IsNaN(pointSet.MaxValue)) { minT = pointSet.MinValue; maxT = pointSet.MaxValue; k = 1.0 / (maxT - minT); } else { k = Double.NaN; } for (int j = 0; j < pointSet.Data.Count; j++) { float x = (float)pointSet.Data[j].Longitude; float y = (float)pointSet.Data[j].Latitude; LatLonAlt position = LatLonAlt.CreateUsingDegrees(y + step, x + step, altitude); Vector3F vec = new Vector3F(position.GetVector()); double hue; Color color = Color.Red; System.Windows.Media.Color tempColor; if (!Double.IsNaN(k)) { hue = 270 * ((maxT - (double)pointSet.Data[j].Value) * k); tempColor = new HsbColor(hue, 1, 1, 0.8).ToArgb(); color = Color.FromArgb(tempColor.A, tempColor.R, tempColor.G, tempColor.B); } vertices.Add(new Vertex.PositionColored(vec, color.ToArgb())); position = LatLonAlt.CreateUsingDegrees(y - step, x - step, altitude); vec = new Vector3F(position.GetVector()); vertices.Add(new Vertex.PositionColored(vec, color.ToArgb())); position = LatLonAlt.CreateUsingDegrees(y + step, x - step, altitude); vec = new Vector3F(position.GetVector()); vertices.Add(new Vertex.PositionColored(vec, color.ToArgb())); position = LatLonAlt.CreateUsingDegrees(y - step, x + step, altitude); vec = new Vector3F(position.GetVector()); vertices.Add(new Vertex.PositionColored(vec, color.ToArgb())); } return(vertices); }
private bool CheckEnvirons(LatLonAlt point1, LatLonAlt point2, double eps) { if (Math.Sqrt( Math.Pow(Math.Abs(point1.LongitudeDegrees - point2.LongitudeDegrees), 2) + Math.Pow(Math.Abs(point1.LatitudeDegrees - point2.LatitudeDegrees), 2)) < eps) { return(true); } else { return(false); } }
private void GenerateLatLonObject(LatLonAlt data) { var mapPin = Instantiate(_mapPinPrefab); mapPin.Location = data.LatLon; _mapPinLayer.MapPins.Add(mapPin); POICoordinatesObject poiCoordinatesObject = new POICoordinatesObject(data.LatitudeInDegrees, data.LongitudeInDegrees, 0); poiCoordinatesObject.setMapPin(mapPin); poiCoordinatesObject.setName(data.LatLon.LatitudeInDegrees.ToString() + " " + data.LongitudeInDegrees); var EventArgs = new POIEventArgs(poiCoordinatesObject); OnPOI(this, EventArgs); }
public bool CheckIntersection(LatLonAlt location) { if (layers.Count == 0) { return(false); } if (layers[layers.Count - 1] == null) { return(false); } WarpedDataSource2D <double> dataSource = null;//layers[layers.Count - 1].dataSource; if (dataSource == null) { return(false); } double isolineLayer; bool foundVal = Search(dataSource, new Point(location.LongitudeDegrees, location.LatitudeDegrees), out isolineLayer); if (foundVal) { host.Geometry.RemoveGeometry("RunningLine", "rl"); IsolineCollection collection = isolineBuilder.Build(isolineLayer); LevelLine segment = collection.Lines[0]; //runningIsoline.LineColor = palette.GetColor(segment.Value01); //runningIsoline.Segment = segment; //List<Coordinate2D> points = new List<Coordinate2D>(); //points.Add(new Coordinate2D(segment.StartPoint.X, segment.StartPoint.Y)); //foreach (Point point in segment.OtherPoints) //{ // points.Add(new Coordinate2D(point.X, point.Y)); //} //PolyInfo style = PolyInfo.DefaultPolyline; //style.LineColor = palette.GetColor(segment.Value01); //style.LineWidth = 5; //runningLine = new PolylineGeometry("RunningLine", "rl", new Polyline2(Wgs84CoordinateReferenceSystem.Instance, // Coordinate2DCollection.CreateUnsafe(points.ToArray())), style); } return(foundVal); }
// Use this for initialization void Start() { SystemId = (byte)MAV_MODE.MAV_MODE_MANUAL_ARMED; ComponentId = (byte)MAV_COMPONENT.MAV_COMP_ID_AUTOPILOT1; Application.runInBackground = true; mlpn = new Msg_local_position_ned(); mgpi = new Msg_global_position_int(); Mheratbeat = new Msg_heartbeat(); Msts = new Msg_sys_status(); Matt = new Msg_attitude(); Mdatastream = new Msg_request_data_stream(); Mgpsr = new Msg_gps_raw_int(); Mattq = new Msg_attitude_quaternion(); Mvhud = new Msg_vfr_hud(); MattTar = new Msg_attitude_target(); MHome = new Msg_home_position(); setMHome = new Msg_set_home_position(); setMode = new Msg_set_mode(); EstimatorStatus = new Msg_estimator_status(); Mvirbration = new Msg_vibration(); ExtendState = new Msg_extended_sys_state(); latlonalt = new LatLonAlt(); Malt = new Msg_altitude(); positionL = new Msg_position_target_local_ned(); setPositionL = new Msg_set_position_target_local_ned(); setPositionG = new Msg_set_position_target_global_int(); PositionG = new Msg_position_target_global_int(); MhiIMU = new Msg_highres_imu(); BatteryStatus = new Msg_battery_status(); player = GameObject.FindGameObjectWithTag("Player"); DM = player.GetComponent <DroneMove> (); InitSocket(); setHomePosition(); setPositionTargetLocal(); setPositionTargetGlobal(); }
public void changeDisplayMode_Click() { modeChange = !modeChange; if (modeChange) { //DeactivateFlight(); //ActivateFlight(); int index = 0; LatLonAlt position = LatLonAlt.CreateUsingDegrees(airport.Latitude, airport.Longitude, 0); foreach (BunnyActor b in b_actors) { b.changeMode = !b.changeMode; b.isStaticState = !b.isStaticState; b.setLocation = position; //bactor.isStaticState = false; b.setDestination = LatLonAlt.CreateUsingDegrees( ((double)(a_flightlist[index].Destination.Latitude)), ((double)(a_flightlist[index].Destination.Longitude)), a_flightlist[index].Destination.Altitude); b.Flight = a_flightlist[index].Identity; index++; } } else { foreach (BunnyActor b in b_actors) { InFlightAircraftStruct f = a_baseClass.getFlightStatus(b.Flight); LatLonAlt loc = LatLonAlt.CreateUsingDegrees(f.latitude, f.longitude, 0); b.setLocation = loc; } foreach (BunnyActor b in b_actors) { b.changeMode = !b.changeMode; } } }
// public async void OnTapAndHold(LatLonAlt latLonAlt) public void OnTapAndHold(LatLonAlt latLonAlt) { if (ReferenceEquals(MapSession.Current, null) || string.IsNullOrEmpty(MapSession.Current.DeveloperKey)) { Debug.LogError( "Provide a Bing Maps key to use the map services. " + "This key can be set on a MapSession component."); return; } // var finderResult = await MapLocationFinder.FindLocationsAt(latLonAlt.LatLon); /* * string formattedAddressString = null; * if (finderResult.Locations.Count > 0) * { * formattedAddressString = finderResult.Locations[0].Address.FormattedAddress; * } */ if (_mapPinPrefab != null) { // Create a new MapPin instance at the specified location. var newMapPin = Instantiate(_mapPinPrefab); newMapPin.Location = latLonAlt.LatLon; latitude = latLonAlt.LatitudeInDegrees; longitude = latLonAlt.LongitudeInDegrees; latLonText = GameObject.Find("LatitudeLongitudeText").GetComponent <TextMeshProUGUI>(); latLonText.text = "Latitude: " + latitude.ToString() + " Longitude: " + longitude.ToString(); Debug.Log("What is the latitude?" + latLonAlt.LatitudeInDegrees); Debug.Log("What is the longitude?" + latLonAlt.LongitudeInDegrees); // var textMesh = newMapPin.GetComponentInChildren<TextMeshPro>(); // textMesh.text = formattedAddressString ?? "No address found."; _mapPinLayer.MapPins.Clear(); _mapPinLayer.MapPins.Add(newMapPin); } }
private void AddDataSource(IDataSource2D <double> field, Guid guid) { List <PolylineGeometry> geometry = new List <PolylineGeometry>(); List <VisualPushpin> labels = new List <VisualPushpin>(); isolineBuilder.DataSource = field; IsolineCollection collection = isolineBuilder.Build(); annotater.WayBeforeText = 20.0; foreach (LevelLine segment in collection.Lines) { List <Coordinate2D> points = new List <Coordinate2D>(); points.Add(new Coordinate2D(segment.StartPoint.X, segment.StartPoint.Y)); foreach (Point point in segment.OtherPoints) { points.Add(new Coordinate2D(point.X, point.Y)); } PolyInfo style = PolyInfo.DefaultPolyline; Color color = palette.GetColor(segment.Value01); style.LineColor = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B); geometry.Add(new PolylineGeometry(guid.ToString(), Guid.NewGuid().ToString(), new Polyline2(Wgs84CoordinateReferenceSystem.Instance, Coordinate2DCollection.CreateUnsafe(points.ToArray())), style)); } foreach (IsolineTextLabel label in annotater.Annotate(collection, new Rect())) { labels.Add(new VisualPushpin(30, 30, label.Text, LatLonAlt.CreateUsingDegrees(label.Position.Y, label.Position.X, 0), this, Guid.NewGuid().ToString())); } layers.Add(new IsolinesLayer() { Geometry = geometry, IsVisible = true, Guid = guid, Labels = labels }); AddLayerToHost(layers[layers.Count - 1]); }
public bool CheckIntersection(Microsoft.MapPoint.Rendering3D.LatLonAlt location) { bool hasIntersections = false; foreach (VisualPushpin pin in intersectedValues) { host.Geometry.RemoveGeometry(pin.Pushpin.LayerId, pin.Pushpin.Id); } intersectedValues.Clear(); lock (trajectoriesLayers) { foreach (TrajectoriesLayer trajectoriesLayer in trajectoriesLayers) { if (trajectoriesLayer.IsVisible) { for (int i = 0; i < trajectoriesLayer.DataSource.PointSet.Data.Count; i++) { LatLonAlt gridPos = LatLonAlt.CreateUsingDegrees(trajectoriesLayer.DataSource.PointSet.Data[i].Latitude, trajectoriesLayer.DataSource.PointSet.Data[i].Longitude, 0); if (CheckEnvirons(gridPos, location, trajectoriesLayer.DataSource.Step)) { if (!hasIntersections) { hasIntersections = true; } intersectedValues.Add(new VisualPushpin(60, 60, trajectoriesLayer.DataSource.PointSet.Data[i].Value.ToString(), gridPos, null, Guid.NewGuid().ToString())); break; } } } } } return(hasIntersections); }
public JumpCameraController(Host host, CameraController <PredictiveCamera> nextCamera, LatLonAlt nextPosition, RollPitchYaw nextOrientation) : base() { this.host = host; this.Next = nextCamera; this.SetNext(nextPosition, nextOrientation); }
public bool CheckIntersection(LatLonAlt location) { bool hasIntersections = false; foreach (VisualPushpin pin in intersectedValues) { host.Geometry.RemoveGeometry(pin.Pushpin.LayerId, pin.Pushpin.Id); } intersectedValues.Clear(); lock (probesLayers) { foreach (ProbesLayer probesLayer in probesLayers) { if (probesLayer.IsVisible) { if (probesLayer.DataSource.Field is IDataSource2D <double> ) { //for warped grids IDataSource2D <double> field = probesLayer.DataSource.Field as IDataSource2D <double>; System.Windows.Point[,] grid = field.Grid; Coordinate2D minCoordinate = new Coordinate2D(grid[0, 0].X, grid[0, 0].Y); Coordinate2D maxCoordinate = new Coordinate2D(grid[field.Width - 1, field.Height - 1].X, grid[field.Width - 1, field.Height - 1].Y); bool intersectionFound = false; for (int j = 0; j < field.Height; j++) { for (int i = 0; i < field.Width; i++) { if (grid[i, j].X < minCoordinate.X) { minCoordinate.X = grid[i, j].X; } if (grid[i, j].X > maxCoordinate.X) { maxCoordinate.X = grid[i, j].X; } if (grid[i, j].Y < minCoordinate.Y) { minCoordinate.Y = grid[i, j].Y; } if (grid[i, j].Y > maxCoordinate.Y) { maxCoordinate.Y = grid[i, j].Y; } } } if (location.LatitudeDegrees > minCoordinate.Y && location.LongitudeDegrees > minCoordinate.X && location.LongitudeDegrees < maxCoordinate.X && location.LatitudeDegrees < maxCoordinate.Y) { for (int i = 0; i < field.Width; i++) { for (int j = 0; j < field.Height; j++) { LatLonAlt gridPos = LatLonAlt.CreateUsingDegrees(field.Grid[i, j].Y, field.Grid[i, j].X, 0); if (CheckEnvirons(gridPos, location, probesLayer.DataSource.Step)) { if (!hasIntersections) { hasIntersections = true; } intersectedValues.Add(new VisualPushpin(60, 60, field.Data[i, j].ToString(), gridPos, null, Guid.NewGuid().ToString())); intersectionFound = true; break; } } if (intersectionFound) { break; } } } } else if (probesLayer.DataSource.Field is PointSet) { PointSet pointSet = probesLayer.DataSource.Field as PointSet; if (probesLayer.IsVisible) { for (int i = 0; i < pointSet.Data.Count; i++) { LatLonAlt gridPos = LatLonAlt.CreateUsingDegrees(pointSet.Data[i].Latitude, pointSet.Data[i].Longitude, 0); if (CheckEnvirons(gridPos, location, probesLayer.DataSource.Step)) { if (!hasIntersections) { hasIntersections = true; } intersectedValues.Add(new VisualPushpin(60, 60, pointSet.Data[i].Value.ToString(), gridPos, null, Guid.NewGuid().ToString())); break; } } } } } } } return(hasIntersections); }
/// <summary> /// Transforms an XYZ point in world space to a LatLonAlt. /// </summary> public static Vector3 TransformLatLonAltToWorld(this MapRenderer mapRenderer, LatLonAlt location) { // Can compute XZ coords in local space from the Mercator position and map center. var mercatorPosition = location.LatLon.ToMercatorPosition(); var mercatorPositionRelativeToCenter = mercatorPosition - mapRenderer.Center.ToMercatorPosition(); var equatorialCircumferenceInLocalSpace = Math.Pow(2, mapRenderer.ZoomLevel - 1); var localSpaceXZ = equatorialCircumferenceInLocalSpace * mercatorPositionRelativeToCenter; // Altitude to local y value. var offsetMapAltitudeInMeters = location.AltitudeInMeters - mapRenderer.ElevationBaseline; var mercatorScale = 1.0 / Math.Cos(location.LatLon.LatitudeInRadians); var altitudeInLocalSpace = offsetMapAltitudeInMeters * mercatorScale * (equatorialCircumferenceInLocalSpace / EquatorialCircumferenceInWgs84Meters); var localPoint = new Vector3( (float)localSpaceXZ.X, (float)(altitudeInLocalSpace + mapRenderer.LocalMapHeight), (float)localSpaceXZ.Y); return(mapRenderer.transform.TransformPoint(localPoint)); }
/// <summary> /// Reset camera position /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MenuButton_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e) { this.viewBase.Host.Navigation.FlyTo(LatLonAlt.CreateUsingDegrees(0, 0, 20000000), -90.0, 0.0); }
/// <summary> /// Transforms a <see cref="LatLonAlt"/> to an XYZ point in local space. /// </summary> public static Vector3 TransformLatLonAltToLocalPoint(this MapRenderer mapRenderer, LatLonAlt location) { // Can compute XZ coords in local space from the Mercator coordinate of thie location and the map center. var mercatorCoordinate = location.LatLon.ToMercatorCoordinate(); return(mapRenderer.TransformMercatorWithAltitudeToLocalPoint(mercatorCoordinate, location.AltitudeInMeters)); }
internal VELatLong(LatLonAlt lla) : this(lla.Latitude, lla.Longitude, lla.Latitude, VEAltMode.FromGround) { }
public static double GreatCircleDistance(VELatLong a, VELatLong b) { return(LatLonAlt.GreatCircleDistance(a.ToLatLonAlt(), b.ToLatLonAlt())); }
private bool CheckEnvirons(LatLonAlt point1, LatLonAlt point2, double eps) { if (Math.Sqrt( Math.Pow(Math.Abs(point1.LongitudeDegrees - point2.LongitudeDegrees), 2) + Math.Pow(Math.Abs(point1.LatitudeDegrees - point2.LatitudeDegrees), 2)) < eps) return true; else return false; }
public bool CheckIntersection(LatLonAlt location) { bool hasIntersections = false; foreach (VisualPushpin pin in intersectedValues) { host.Geometry.RemoveGeometry(pin.Pushpin.LayerId, pin.Pushpin.Id); } intersectedValues.Clear(); lock (probesLayers) { foreach (ProbesLayer probesLayer in probesLayers) { if (probesLayer.IsVisible) { if (probesLayer.DataSource.Field is IDataSource2D<double>) { //for warped grids IDataSource2D<double> field = probesLayer.DataSource.Field as IDataSource2D<double>; System.Windows.Point[,] grid = field.Grid; Coordinate2D minCoordinate = new Coordinate2D(grid[0, 0].X, grid[0, 0].Y); Coordinate2D maxCoordinate = new Coordinate2D(grid[field.Width - 1, field.Height - 1].X, grid[field.Width - 1, field.Height - 1].Y); bool intersectionFound = false; for (int j = 0; j < field.Height; j++) { for (int i = 0; i < field.Width; i++) { if (grid[i, j].X < minCoordinate.X) minCoordinate.X = grid[i, j].X; if (grid[i, j].X > maxCoordinate.X) maxCoordinate.X = grid[i, j].X; if (grid[i, j].Y < minCoordinate.Y) minCoordinate.Y = grid[i, j].Y; if (grid[i, j].Y > maxCoordinate.Y) maxCoordinate.Y = grid[i, j].Y; } } if (location.LatitudeDegrees > minCoordinate.Y && location.LongitudeDegrees > minCoordinate.X && location.LongitudeDegrees < maxCoordinate.X && location.LatitudeDegrees < maxCoordinate.Y) { for (int i = 0; i < field.Width; i++) { for (int j = 0; j < field.Height; j++) { LatLonAlt gridPos = LatLonAlt.CreateUsingDegrees(field.Grid[i, j].Y, field.Grid[i, j].X, 0); if (CheckEnvirons(gridPos, location, probesLayer.DataSource.Step)) { if (!hasIntersections) hasIntersections = true; intersectedValues.Add(new VisualPushpin(60, 60, field.Data[i, j].ToString(), gridPos, null, Guid.NewGuid().ToString())); intersectionFound = true; break; } } if (intersectionFound) break; } } } else if (probesLayer.DataSource.Field is PointSet) { PointSet pointSet = probesLayer.DataSource.Field as PointSet; if (probesLayer.IsVisible) { for (int i = 0; i < pointSet.Data.Count; i++) { LatLonAlt gridPos = LatLonAlt.CreateUsingDegrees(pointSet.Data[i].Latitude, pointSet.Data[i].Longitude, 0); if (CheckEnvirons(gridPos, location, probesLayer.DataSource.Step)) { if (!hasIntersections) hasIntersections = true; intersectedValues.Add(new VisualPushpin(60, 60, pointSet.Data[i].Value.ToString(), gridPos, null, Guid.NewGuid().ToString())); break; } } } } } } } return hasIntersections; }
/// <summary> /// Activates this plug-in. This should be written such that it can be called multiple times /// along with Deactivate. /// </summary> /// <param name="activationObject">Passed by the activator, in this case script.</param> public override void Activate(object activationObject) { base.Activate(activationObject); Host.BindingsManager.RegisterAction(this.BindingsSource, "GeometryMouse", MouseMove); Host.BindingsManager.AddActiveBindingSet(this.BindingsSource, "Geometry"); dataSources = new ObservableCollection <VisualizationDataSource>(); pluginVisualizationProviders = new List <IVisualizationProvider>(); //ColorMap providers Guid colorMapGuid = Guid.NewGuid(); pluginVisualizationProviders.Add(new ColorMapActor(startAltitude, this.BindingsSource, this.dataSources, Host) { IsDynamicProvider = true, ProviderGuid = colorMapGuid }); pluginVisualizationProviders.Add(new StaticColorMaps(this.dataSources, this.Host) { IsDynamicProvider = false, ProviderGuid = colorMapGuid }); //Probes providers Guid probesGuid = Guid.NewGuid(); pluginVisualizationProviders.Add(new ProbesActor(this.Host, startAltitude, this.BindingsSource, this.dataSources) { IsDynamicProvider = true, ProviderGuid = probesGuid }); pluginVisualizationProviders.Add(new StaticProbes(this.dataSources, this.Host) { IsDynamicProvider = false, ProviderGuid = probesGuid }); //Isolines providers Guid isolinesGuid = Guid.NewGuid(); pluginVisualizationProviders.Add(new StaticIsolines(this.dataSources, this.Host) { IsDynamicProvider = false, ProviderGuid = isolinesGuid }); //Trajectories providers Guid trajectoriesGuid = Guid.NewGuid(); pluginVisualizationProviders.Add(new StaticTrajectories(this.dataSources, this.Host) { IsDynamicProvider = false, ProviderGuid = trajectoriesGuid }); foreach (IVisualizationProvider item in pluginVisualizationProviders) { if (item is Actor) { Host.Actors.Add(item as Actor); } } Arbiter.Activate(dispatcherQueue, Arbiter.Interleave( new TeardownReceiverGroup(), new ExclusiveReceiverGroup( Arbiter.Receive <EmptyValue>(true, mousePort, delegate(EmptyValue val) { if (Host.Navigation.PointerPosition != null) { LatLonAlt location = Host.Navigation.PointerPosition.Location; foreach (IVisualizationProvider visualizationProvider in pluginVisualizationProviders) { if (visualizationProvider is IMouseCheck) { IMouseCheck provider = visualizationProvider as IMouseCheck; if (provider.CheckIntersection(location)) { provider.ShowIntersectedValues(); } } } } })), new ConcurrentReceiverGroup() )); }
/// <summary> /// Transforms a <see cref="LatLonAlt"/> to an XYZ point in world space. /// </summary> public static Vector3 TransformLatLonAltToWorldPoint(this MapRenderer mapRenderer, LatLonAlt location) { var pointInLocalSpace = mapRenderer.TransformLatLonAltToLocalPoint(location); return(mapRenderer.transform.TransformPoint(pointInLocalSpace)); }
private void AddDataSource(IDataSource2D <double> field, Guid guid) { double minT, maxT; //if (colorMapControl.PaletteType == PaletteType.FromMaxMin) //{ // minT = colorMapControl.MinValue; // maxT = colorMapControl.MaxValue; //} //else //{ MathHelper.GetMaxMin(field.Data, out maxT, out minT); //colorMapControl.MinValue = minT; //colorMapControl.MaxValue = maxT; //} double k = 1.0 / (maxT - minT); List <Vertex.PositionColored> vertices = new List <Vertex.PositionColored>(); double altitude = layerHelper.GetNewAltitude(); for (int i = 0; i < field.Width; i++) { for (int j = 0; j < field.Height; j++) { float x = (float)field.Grid[i, j].X; float y = (float)field.Grid[i, j].Y; LatLonAlt position = LatLonAlt.CreateUsingDegrees(y, x, altitude); Vector3F vec = new Vector3F(position.GetVector()); System.Windows.Media.Color color = palette.GetColor((field.Data[i, j] - minT) * k); vertices.Add(new Vertex.PositionColored(vec, Color.FromArgb(opacity, color.R, color.G, color.B).ToArgb())); } } MeshGraphicsObject <Vertex.PositionColored, ushort> mesh = new MeshGraphicsObject <Vertex.PositionColored, ushort>( GraphicsBufferUsage.Static, GraphicsBufferUsage.Static, vertices.Count, vertices.Count * 6, true); Material material = new Material { AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White }; int id = mesh.Materials.Add(material); mesh.Vertices.AddData(vertices.ToArray()); for (int i = 0; i < field.Width - 1; i++) { for (int j = 0; j < field.Height - 1; j++) { mesh.Indices.AddData( (ushort)(i * field.Height + j), (ushort)(i * field.Height + j + 1), (ushort)((i + 1) * field.Height + j), PrimitiveType.TriangleList, id); mesh.Indices.AddData( (ushort)(i * field.Height + j + 1), (ushort)((i + 1) * field.Height + j + 1), (ushort)((i + 1) * field.Height + j), PrimitiveType.TriangleList, id); } } mesh.RenderState.Lighting.Enabled = false; mesh.RenderState.Alpha.Enabled = true; mesh.RenderState.Alpha.AlphaTestEnable = true; mesh.RenderState.Alpha.SourceBlend = Blend.BothInvSourceAlpha; mesh.RenderState.Alpha.DestinationBlend = Blend.BothInvSourceAlpha; mesh.RenderState.Cull.Enabled = false; meshLayers.Add(new MeshLayer { LayerAltitude = altitude, Mesh = mesh, Guid = guid, IsVisible = true, ScalarField = field }); }
public Point?LatLongToScreenPosition(LatLonAlt ll) { return(VectorToScreenPosition(ll.GetVector())); }
public void SetNext(LatLonAlt nextPosition, RollPitchYaw nextOrientation) { this.position = nextPosition; this.orientation = nextOrientation; }
private void AddDataSource(IDataSource2D <double> field, Guid guid) { // Get data and min/max. double[,] data = field.Data; double minT, maxT; MathHelper.GetMaxMin(data, out maxT, out minT); double k = 1.0 / (maxT - minT); double altitude = layerAltitude; //TODO: Perform right calculation depending on grid step = 0.3; List <Vertex.PositionColored> vertices = new List <Vertex.PositionColored>(); for (int i = 0; i < field.Width; i++) { for (int j = 0; j < field.Height; j++) { float x = (float)field.Grid[i, j].X; float y = (float)field.Grid[i, j].Y; LatLonAlt position = LatLonAlt.CreateUsingDegrees(y + step, x + step, altitude); Vector3F vec = new Vector3F(position.GetVector()); vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb())); position = LatLonAlt.CreateUsingDegrees(y - step, x - step, altitude); vec = new Vector3F(position.GetVector()); vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb())); position = LatLonAlt.CreateUsingDegrees(y + step, x - step, altitude); vec = new Vector3F(position.GetVector()); vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb())); position = LatLonAlt.CreateUsingDegrees(y - step, x + step, altitude); vec = new Vector3F(position.GetVector()); vertices.Add(new Vertex.PositionColored(vec, Color.Red.ToArgb())); } } MeshGraphicsObject <Vertex.PositionColored, ushort> mesh = new MeshGraphicsObject <Vertex.PositionColored, ushort>( GraphicsBufferUsage.Static, GraphicsBufferUsage.Static, vertices.Count, vertices.Count, true); Material material = new Material { AmbientColor = Color.White, DiffuseColor = Color.White, SpecularColor = Color.White }; int id = mesh.Materials.Add(material); mesh.Vertices.AddData(vertices.ToArray()); List <ushort> indexData = new List <ushort>(); for (int i = 0; i < field.Width; i++) { for (int j = 0; j < field.Height; j++) { indexData.Add((ushort)((i * field.Height + j) * 4)); indexData.Add((ushort)((i * field.Height + j) * 4 + 1)); indexData.Add((ushort)((i * field.Height + j) * 4 + 2)); indexData.Add((ushort)((i * field.Height + j) * 4 + 3)); } } mesh.Indices.AddData(indexData.ToArray(), PrimitiveType.LineList, id); mesh.RenderState.Lighting.Enabled = false; mesh.RenderState.Cull.Enabled = false; meshLayers.Add(new MeshLayer { LayerAltitude = altitude, Mesh = mesh, Guid = guid, IsVisible = true, ScalarField = field, Step = step }); }
public bool CheckIntersection(LatLonAlt location) { if (layers.Count == 0) return false; if (layers[layers.Count - 1] == null) return false; WarpedDataSource2D<double> dataSource = null;//layers[layers.Count - 1].dataSource; if (dataSource == null) return false; double isolineLayer; bool foundVal = Search(dataSource, new Point(location.LongitudeDegrees, location.LatitudeDegrees), out isolineLayer); if (foundVal) { host.Geometry.RemoveGeometry("RunningLine", "rl"); IsolineCollection collection = isolineBuilder.Build(isolineLayer); LevelLine segment = collection.Lines[0]; //runningIsoline.LineColor = palette.GetColor(segment.Value01); //runningIsoline.Segment = segment; //List<Coordinate2D> points = new List<Coordinate2D>(); //points.Add(new Coordinate2D(segment.StartPoint.X, segment.StartPoint.Y)); //foreach (Point point in segment.OtherPoints) //{ // points.Add(new Coordinate2D(point.X, point.Y)); //} //PolyInfo style = PolyInfo.DefaultPolyline; //style.LineColor = palette.GetColor(segment.Value01); //style.LineWidth = 5; //runningLine = new PolylineGeometry("RunningLine", "rl", new Polyline2(Wgs84CoordinateReferenceSystem.Instance, // Coordinate2DCollection.CreateUnsafe(points.ToArray())), style); } return foundVal; }