private void loadAPIButton_eventClick(UIComponent component, UIMouseEventParameter eventParam) { try { decimal startLat = 0M; decimal startLon = 0M; decimal endLat = 0M; decimal endLon = 0M; var scale = double.Parse(scaleTextBox.text.Trim()); var tt = double.Parse(tiles.text.Trim()); if (!GetCoordinates(tt, scale, ref startLon, ref startLat, ref endLon, ref endLat)) { return; } var ob = new osmBounds(); ob.minlon = startLon; ob.minlat = startLat; ob.maxlon = endLon; ob.maxlat = endLat; var osm = new OSMInterface(ob, scale, double.Parse(tolerance.text.Trim()), double.Parse(curveTolerance.text.Trim()), tt); currentIndex = 0; roadMaker = new RoadMaker2(osm); errorLabel.text = "Data Loaded."; okButton.Enable(); loadMapButton.Disable(); loadAPIButton.Disable(); } catch (Exception ex) { errorLabel.text = ex.ToString(); } }
private void loadAPIButton_eventClick(UIComponent component, UIMouseEventParameter eventParam) { ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback; try { ob = GetBounds(); // In LoadAPIButton //var streetMapRequest = new OpenStreeMapFrRequest(ob); //var streetMapRequest = new OpenStreeMapApi0_6Request(ob); var streetMapRequest = new OverpassRequest(ob); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.NodeRequestUrl); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.WaysRequestUrl); var nodesWebClient = new WebClient(); nodesWebClient.DownloadDataCompleted += NodesWebClientCallback; Debug.Log("NodeRequestUrl:" + streetMapRequest.NodeRequestUrl); nodesWebClient.DownloadDataAsync(new Uri(streetMapRequest.NodeRequestUrl)); var waysWebClient = new WebClient(); Debug.Log("WaysRequestUrl:" + streetMapRequest.WaysRequestUrl); waysWebClient.DownloadDataCompleted += WaysWebClientCallback; waysWebClient.DownloadDataAsync(new Uri(streetMapRequest.WaysRequestUrl)); } catch (Exception ex) { errorLabel.text = ex.ToString(); } }
public OpenStreeMapApi0_6Request(osmBounds osmBounds) { bottom = Math.Min(osmBounds.minlat, osmBounds.maxlat); top = Math.Max(osmBounds.minlat, osmBounds.maxlat); left = Math.Min(osmBounds.minlon, osmBounds.maxlon); right = Math.Max(osmBounds.minlon, osmBounds.maxlon); }
public OverpassRequest(osmBounds osmBounds) { bottom = Math.Min(osmBounds.minlat, osmBounds.maxlat); top = Math.Max(osmBounds.minlat, osmBounds.maxlat); left = Math.Min(osmBounds.minlon, osmBounds.maxlon); right = Math.Max(osmBounds.minlon, osmBounds.maxlon); }
private void loadAPIButton_eventClick(UIComponent component, UIMouseEventParameter eventParam) { Debug.Log("loadAPIButton_eventClick"); try { Debug.Log("GetBounds()"); ob = GetBounds(); Debug.Log("new OpenStreeMapFrRequest"); var streetMapRequest = new OpenStreeMapFrRequest(ob); Debug.Log("DebugOutputPanel.AddMessage"); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.NodeRequestUrl); Debug.Log("DebugOutputPanel.AddMessage"); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.WaysRequestUrl); Debug.Log("new WebClient()"); var nodesWebClient = new WebClient(); var nodeResponseData = nodesWebClient.DownloadData(new Uri(streetMapRequest.NodeRequestUrl)); NodesWebClientCallback(nodeResponseData); var waysWebClient = new WebClient(); var waysResponseData = waysWebClient.DownloadData(new Uri(streetMapRequest.WaysRequestUrl)); WaysWebClientCallback(waysResponseData); } catch (Exception ex) { Debug.Log(ex.ToString()); errorLabel.text = ex.ToString(); } }
//public void InitBoundingBox(osmNode node) //{ // startLatLon = new Vector2(Math.Min(startLatLon.x, (float)node.lon), Math.Min(startLatLon.y, (float)node.lat)); // endLatLon = new Vector2(Math.Max(endLatLon.x, (float)node.lon), Math.Max(endLatLon.y, (float)node.lat)); //} public void InitBoundingBox(osmBounds bounds, double scale) { this.middleLatLon = new Vector2((float)(bounds.minlon + bounds.maxlon) / 2f, (float)(bounds.minlat + bounds.maxlat) / 2f); var lat = Deg2rad(this.middleLatLon.y); var radius = WGS84EarthRadius(lat); var pradius = radius * Math.Cos(lat); scaleX = scale * GameSizeGameCoordinates / Rad2deg(GameSizeMetres / pradius); scaleY = scale * GameSizeGameCoordinates / Rad2deg(GameSizeMetres / radius); }
private new OSM.osmBounds GetBounds() { decimal startLat = 0M; decimal startLon = 0M; decimal endLat = 0M; decimal endLon = 0M; if (!GetCoordinates(ref startLon, ref startLat, ref endLon, ref endLat)) { return(null); } var ob = new osmBounds(); ob.minlon = startLon; ob.minlat = startLat; ob.maxlon = endLon; ob.maxlat = endLat; return(ob); }
private void loadAPIButton_eventClick(UIComponent component, UIMouseEventParameter eventParam) { try { ob = GetBounds(); var streetMapRequest = new OpenStreeMapFrRequest(ob); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.NodeRequestUrl); DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, streetMapRequest.WaysRequestUrl); var nodesWebClient = new WebClient(); nodesWebClient.DownloadDataCompleted += NodesWebClientCallback; nodesWebClient.DownloadDataAsync(new Uri(streetMapRequest.NodeRequestUrl)); var waysWebClient = new WebClient(); waysWebClient.DownloadDataCompleted += WaysWebClientCallback; waysWebClient.DownloadDataAsync(new Uri(streetMapRequest.WaysRequestUrl)); } catch (Exception ex) { errorLabel.text = ex.ToString(); } }