Ejemplo n.º 1
0
 public void init(USlippyTile t, UPlayer p)
 {
     tile   = t;
     player = p;
     parser = new OSMParser(tile);
     parser.Start();
 }
Ejemplo n.º 2
0
    private void Update()
    {
        /// check if the thread has finished his work
        if (parser != null)
        {
            if (parser.Update())
            {
                /// here the thread have finished
                /// lets get the data from the parser
                loadBounds();
                loadNodes();
                loadWays();

                /// set the parser to null to ignore it one time has finished
                parser     = null;
                downloaded = true;
            }
        }

        if (parser == null && nodes != null && GetComponent <UTerrain>() != null && GetComponent <UTerrain>().isFullyLoaded&& !nodesSettedInTerrain)
        {
            foreach (DictionaryEntry e in nodes)
            {
                OSMNode n = (OSMNode)e.Value;
                n.pos.y = GetComponent <Terrain>().SampleHeight(n.pos + transform.position) + GetComponent <Terrain>().GetPosition().y;
            }

            nodesSettedInTerrain = true;
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Update the GUI
    /// </summary>
    public void OnGUI()
    {
        // Initialize GUI-Utils

        if (!OpenStreetMapsWindow.initializedAttributes)
        {
            myGuiUtils = new MyGUIUtils();
            myGuiUtils.Initialize();

            //mybounds = new MapBounds(50.9517f, 6.9258f, 6.9902f, 50.9202f); // Köln Groß
            //mybounds = new MapBounds(50.23513f, 8.04716f, 8.07123f, 50.22266f); // Michelbach
            mybounds = MapBounds.Cologne;


            tileMap = new OSMTileMap();
            //tileMap.centerLatitude = mybounds.CenterLatitude;
            //tileMap.centerLongitude = mybounds.CenterLongitude;
            tileMap.centerLatitude  = 50.9390d;
            tileMap.centerLongitude = 6.9605d; //7.02744f; //6.9605d;//7.56211f;  Basti 6.93728f;

            tileMap.zoomLevel = 13;


            osmMap    = new OSMMap();
            osmParser = new OSMParser();

            moving       = new List <bool>();
            points       = new List <Vector2>();
            pointsCoords = new List <Vector2>();
            point        = new Vector2();


            zoomIn       = Resources.Load("OSMWindowIcons/zoomIn", typeof(Texture2D)) as Texture2D;
            zoomOut      = Resources.Load("OSMWindowIcons/zoomOut", typeof(Texture2D)) as Texture2D;
            titleTexture = Resources.Load("OSMWindowIcons/title", typeof(Texture2D)) as Texture2D;
            //Texture2D titleTexture = Resources.Load("title_small", typeof(Texture2D)) as Texture2D;
            pointTexture      = Resources.Load("OSMWindowIcons/marker", typeof(Texture2D)) as Texture2D;
            selectionTexture  = Resources.Load("OSMWindowIcons/selection", typeof(Texture2D)) as Texture2D;
            navigationTexture = Resources.Load("OSMWindowIcons/navigation", typeof(Texture2D)) as Texture2D;
            downloadTexture   = Resources.Load("OSMWindowIcons/download", typeof(Texture2D)) as Texture2D;


            //nodePrefab = GameObject.Find("BCNodePrefab");
            //if (nodePrefab == null)
            //{
            //    nodePrefab = new GameObject("BCNodePrefab");
            //    nodePrefab.AddComponent(typeof(Node));
            //    nodePrefab.AddComponent<BCIntersection>();
            //}

            //edgePrefab = GameObject.Find("BCEdgePrefab");
            //if (edgePrefab == null)
            //{
            //    edgePrefab = new GameObject("BCEdgePrefab");
            //    edgePrefab.AddComponent<Edge>();
            //    edgePrefab.AddComponent<MeshFilter>();
            //    edgePrefab.AddComponent<MeshRenderer>();
            //    edgePrefab.AddComponent<MeshCollider>();
            //    edgePrefab.AddComponent<BCRoad>();
            //}

            //entrancePrefab = GameObject.Find("BCEntrancePrefab");
            //if (entrancePrefab == null)
            //{
            //    entrancePrefab = new GameObject("BCEntrancePrefab");
            //    entrancePrefab.AddComponent(typeof(BCEntrance));
            //    entrancePrefab.AddComponent<MeshFilter>();
            //    entrancePrefab.AddComponent<MeshRenderer>();
            //    entrancePrefab.AddComponent<MeshCollider>();

            //}


            OpenStreetMapsWindow.initializedAttributes = true;
        }


        // Calculate Center Tile, Position and Coords
        CaculateValues();
        tileMap.DisplayTileMap();

        //osmParser = new OSMParser();
        _scrollPos = GUILayout.BeginScrollView(_scrollPos, GUILayout.ExpandWidth(true));

        GUILayout.BeginVertical("Box", GUILayout.Width(sidebarWidth), GUILayout.ExpandHeight(true));
        GUILayout.Space(100f);

        // Display Title-Texture
        //DisplayTitle();

        // Display Zoom controls and execute zoomControl-handling
        ZoomControl();

        // Scroll-Control
        ScrollControl();

        GUILayout.BeginVertical(GUILayout.Width(sidebarWidth), GUILayout.Height(300f));
        EditorGUILayout.BeginHorizontal();
        GUIContent[] toolbarOptions = new GUIContent[2];
        toolbarOptions[0] = new GUIContent(navigationTexture, "Navigation Mode");
        toolbarOptions[1] = new GUIContent(selectionTexture, "Selection Mode");
        editorMode        = GUILayout.Toolbar(editorMode, toolbarOptions, GUILayout.Width(zoomButtonWidth), GUILayout.Height(zoomButtonHeight), GUILayout.ExpandWidth(true));
        EditorGUILayout.EndHorizontal();

        HandleNavigationOrSelection();
        GUILayout.EndVertical();

        GUILayout.BeginVertical(GUILayout.Width(sidebarWidth), GUILayout.Height(80f));
        OSMServerSelection();
        GUILayout.EndVertical();
        EditorGUILayout.Separator();

        GUILayout.BeginVertical(GUILayout.Width(sidebarWidth));

        //TileManager.OriginLatitude = this.mybounds.CenterLatitude;
        //TileManager.OriginLongitude = this.mybounds.CenterLongitude;

        if (GUILayout.Button(downloadTexture, GUILayout.Width(zoomButtonWidth), GUILayout.Height(zoomButtonHeight * 2), GUILayout.ExpandWidth(true)))
        {
            //TileManager.OriginLatitude = this.mybounds.CenterLatitude;
            //TileManager.OriginLongitude = this.mybounds.CenterLongitude;

            OSMTileProviderBehaviour.mapBounds = mybounds;

            OSMTileProvider.GetOSMTileGameObjectsInBoundingBoxCutting(OSMTileProviderBehaviour.mapBounds, OSMTileProviderBehaviour.CurrentZoomLevel);

            //osmParser.BoundsList = new List<MapBounds>();
            //osmParser.BoundsList.Add(this.mybounds);

            //osmParser.StartParsingNoChunks(reloadContentOSM);

            //MapBounds.CenterOffset = GeographicCoordinates.ConvertLonLatToXY(
            //           osmParser.Map.Box.CenterLongitude,
            //           osmParser.Map.Box.CenterLatitude,
            //           GeographicCoordinates.MapCenter);

            //GameObject srtmMap = new GameObject();
            //srtmMap.name = "SRTMMap";


            //mapTile.bounds = this.mybounds;
            //mapTile.latitude = this.mybounds.South;
            //mapTile.longitude = this.mybounds.West;

            //SRTMMapTile mapTile = srtmMap.AddComponent<SRTMMapTile>();
            //mapTile.ParseToCutMap(this.mybounds);
            //mapTile.transform.position = mapTile.verticesMap[0, 0];
            //srtmMap.active = false;

            //GenerateGraph();

            //foreach (Node tmpNode in Editor.FindSceneObjectsOfType(typeof(Node)))
            //{
            //    tmpNode.FirePositionChanged(NodeEvent.Dirty, 1);
            //}

            EditorUtility.ClearProgressBar();
        }
        GUILayout.BeginHorizontal(GUILayout.Width(sidebarWidth));
        //GUILayout.Label(osmParser.FilePath, GUILayout.Width(sidebarWidth - 30f));
        if (GUILayout.Button("...", GUILayout.Width(25f)))
        {
            osmParser.FilePath = EditorUtility.OpenFilePanel("Open OSM-XML-File...", EditorApplication.applicationContentsPath, "");
            this.osmParser.StartParsingNoChunks(true);
            Debug.Log("Done");
            //if(File.Exists(@osmFilename))
            //    osmParser.FilePath = osmFilename;
        }
        GUILayout.EndHorizontal();


        GUILayout.EndVertical();

        GUILayout.EndScrollView();
        GUILayout.EndVertical();
        // TODO: Unity changed its policy on using events  check if this still works without
        //Event.current.Use();
    }