Exemplo n.º 1
0
        private void loadMapButton_eventClick(UIComponent component, UIMouseEventParameter eventParam)
        {
            var path = pathTextBox.text.Trim();

            if (!File.Exists(path))
            {
                path += ".osm";
                if (!File.Exists(path))
                {
                    errorLabel.text = "Cannot find osm file: " + path;
                    return;
                }
            }
            try
            {
                var osm = new OSMInterface(pathTextBox.text.Trim(), double.Parse(scaleTextBox.text.Trim()), double.Parse(tolerance.text.Trim()), double.Parse(curveTolerance.text.Trim()), double.Parse(tiles.text.Trim()));
                currentIndex    = 0;
                roadMaker       = new RoadMaker2(osm);
                errorLabel.text = "File Loaded.";
                okButton.Enable();
                loadMapButton.Disable();
                loadAPIButton.Disable();
            }
            catch (Exception ex)
            {
                errorLabel.text = ex.ToString();
                Debug.Log(ex.ToString());
            }
        }
        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();
            }
        }
Exemplo n.º 3
0
        // Called when Load OSM file button is clicked
        //  -   Disables loadMapButton and LoadAPIButton so they do not work anymore!!!!
        private void loadOsmFromFileButton_eventClick(UIComponent component, UIMouseEventParameter eventParam)
        {
            var ob = GetBounds(); // in Load Osm from File


            var path = pathTextBox.text.Trim();

            if (!File.Exists(path))
            {
                path += ".osm";
                if (!File.Exists(path))
                {
                    //errorLabel.text = "Cannot find osm file: " + path;
                    return;
                }
            }
            try
            {
                var osm = new OSMInterface(ob, pathTextBox.text.Trim(), double.Parse(scaleTextBox.text.Trim()),
                                           double.Parse(tolerance.text.Trim()), double.Parse(curveTolerance.text.Trim()),
                                           double.Parse(tiles.text.Trim()));
                currentIndex = 0;
                roadMaker    = new RoadMaker2(osm);
                //errorLabel.text = "File Loaded.";
                makeRoadsButton.Enable();
                //loadOsmFromFile.Disable();
                //loadAPIButton.Disable();
            }
            catch (Exception ex)
            {
                SetErrorText(ex.ToString());
            }
        }
Exemplo n.º 4
0
        private void okButton_eventClick(UIComponent component, UIMouseEventParameter eventParam)
        {
            var scale = double.Parse(scaleTextBox.text.Trim());
            var tt    = double.Parse(tiles.text.Trim());
            var osm   = new OSMInterface(ob, nodesXml, waysXml, scale, double.Parse(tolerance.text.Trim()), double.Parse(curveTolerance.text.Trim()), tt);

            currentIndex = 0;
            roadMaker    = new RoadMaker2(osm);
            loadMapButton.Disable();
            loadAPIButton.Disable();

            if (roadMaker != null)
            {
                createRoads = !createRoads;
            }
        }
Exemplo n.º 5
0
        private void loadAPIButton_eventClick(UIComponent component, UIMouseEventParameter eventParam)
        {
            try
            {
                var scale = double.Parse(scaleTextBox.text.Trim());
                var tt    = double.Parse(tiles.text.Trim());

                var ob = GetBounds(scale, tt);

                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 loadMapButton_eventClick(UIComponent component, UIMouseEventParameter eventParam)
 {
     var path = pathTextBox.text.Trim();
     if (!File.Exists(path))
     {
         path += ".osm";
         if (!File.Exists(path))
         {
             errorLabel.text = "Cannot find osm file: " + path;
             return;
         }
     }
     try
     {
         var osm = new OSMInterface(pathTextBox.text.Trim(), double.Parse(scaleTextBox.text.Trim()), double.Parse(tolerance.text.Trim()), double.Parse(curveTolerance.text.Trim()), double.Parse(tiles.text.Trim()));
         currentIndex = 0;
         roadMaker = new RoadMaker2(osm);
         errorLabel.text = "File Loaded.";
         okButton.Enable();
         loadMapButton.Disable();
         loadAPIButton.Disable();
     }
     catch (Exception ex)
     {
         errorLabel.text = ex.ToString();
     }
 }
        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();
            }
        }
Exemplo n.º 8
0
        private void LoadMapButton_eventClick(UIComponent component, UIMouseEventParameter eventParam)
        {
            var path = pathInput.text.Trim();

            if (!File.Exists(path))
            {
                if (!File.Exists(path))
                {
                    errorLabel.text      = "Cannot find osm file: " + path;
                    errorLabel.textColor = COLOR_ERROR;
                    return;
                }
            }
            try
            {
                errorLabel.text      = "Loading OSM file ...";
                errorLabel.textColor = COLOR_TEXT;

                this.osm             = new OSMInterface(pathInput.text.Trim(), double.Parse(toleranceInput.text.Trim()), double.Parse(curveToleranceInput.text.Trim()), double.Parse(tilesInput.text.Trim()), double.Parse(scaleInput.text.Trim()));
                currentIndex         = 0;
                currentRoadTypeIndex = 0;

                int totalCount = 0;
                foreach (var rt in osm.ways)
                {
                    totalCount += rt.Value.Count;
                }
                errorLabel.text      = "OSM file loaded: " + totalCount + " roads (" + osm.ways.Count.ToString() + " types) found.";
                errorLabel.textColor = COLOR_SUCCESS;
                makeErrorLabel.text  = "";
                roadMaker            = new RoadMaker2(this.osm);

                int y = roadCheckBoxStartY;
                int x = 15;

                if (roadMaker != null && roadMaker.netInfos != null)
                {
                    int rtIndex = 0;
                    foreach (var osmrt in osm.roadTypeCount)
                    {
                        int c = 0;
                        if (roadMaker.osm.ways.ContainsKey(osmrt.Key))
                        {
                            foreach (var n in osm.ways[osmrt.Key])
                            {
                                c += n.nodes.Count();
                            }
                        }
                        osm.roadTypeCount[osmrt.Key] = c;
                        if (c > 0)
                        {
                            UILabel chk;
                            UILabel lbl;
                            if (!roadCheckbox.ContainsKey(osmrt.Key))
                            {
                                chk = AddUIComponent <UILabel>();
                                roadCheckbox.Add(osmrt.Key, chk);
                                lbl = AddUIComponent <UILabel>();
                                roadCheckboxLabel.Add(osmrt.Key, lbl);
                            }
                            else
                            {
                                chk = roadCheckbox[osmrt.Key];
                                lbl = roadCheckboxLabel[osmrt.Key];
                            }
                            chk.textScale = .8f;

                            SetCheckBox(chk, false, lbl, x, y);
                            x += 16;

                            SetLabel(lbl, osmrt.Key.ToString() + "(" + c + " nodes)", x, y);
                            lbl.textScale = .7f;

                            rtIndex++;
                            if (rtIndex % 2 == 0)
                            {
                                x  = 15;
                                y += 14;
                            }
                            else
                            {
                                x = 15 + 250 * (rtIndex % 2);
                            }
                        }
                    }
                    x  = 270;
                    y += 5;

                    SetLabel(totalRoadLabel, "", x, y);
                    totalRoadLabel.textScale = .7f;
                }

                disableOSMImportFields();
                updateLimits();
            }
            catch (Exception ex)
            {
                errorLabel.text      = ex.ToString();
                errorLabel.textColor = COLOR_ERROR;
            }
        }