public static nodeType getNodeType(Node node)
        {
            if (node.tags == null)
                return nodeType.None;

            for(int i = 0 ; i < node.tags.Count ; i++)
            {
                if (node.tags[i].k == "natural" && node.tags[i].v == "tree")
                    return nodeType.Tree;
                if (node.tags[i].k == "amenity")
                {
                    if(node.tags[i].v == "drinking_water")
                        return nodeType.DrinkingFountain;
                    if(node.tags[i].v == "post_box")
                        return nodeType.PostBox;
                    if(node.tags[i].v == "telephone")
                        return nodeType.PhoneBox;
                }
                if(node.tags[i].k == "highway")
                {
                    if (node.tags[i].v == "traffic_signals")
                        return nodeType.TrafficSign;
                    if (node.tags[i].v == "street_lamp")
                        return nodeType.StreetLamp;
                }

            }

            return nodeType.None;
        }
 public Node(Node nd)
 {
     this.type = nd.type;
     this.id = nd.id;
     this.lat = nd.lat;
     this.lon = nd.lon;
     this.height = nd.height;
     this.meterPosition = nd.meterPosition;
     this.tags = new List<Tag>(nd.tags);
 }
        private static Object3D drawDrinkingFountain(Node nd)
        {
            Object3D obj = new Object3D();
            obj.id = nd.id;
            obj.name = "Drinking Fountain";
            obj.type = ObjectType.Default;
            obj.resourcePath = "Prefabs/Environment/Prefabs/Fountain2";
            obj.object3D = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent<Object3dMouseHandler>();
            obj.object3D.transform.position = nd.meterPosition;
            obj.object3D.tag = "3DObject";
            obj.object3D.name = "Drinking Fountain";

            return obj;
        }
 private bool isTrafficLight(Node nd)
 {
     return (nd.type == ItemEnumerator.nodeType.TrafficSign);
 }
        private static Object3D drawPhoneBox(Node nd)
        {
            Object3D obj = new Object3D();
            obj.id = nd.id;
            obj.name = "Phone Box";
            obj.type = ObjectType.Default;
            obj.resourcePath = "Prefabs/CityRelated/Prefabs/PhoneBoxPrefab";
            obj.object3D = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent<Object3dMouseHandler>();
            obj.object3D.transform.position = nd.meterPosition;
            obj.object3D.tag = "3DObject";
            obj.object3D.name = "Phone Box";

            return obj;
        }
        private static Object3D drawTree(Node nd)
        {
            Object3D obj = new Object3D();
            obj.id = nd.id;
            obj.name = "Broad Leaf Tree";
            obj.type = ObjectType.Tree;
            obj.resourcePath = "Prefabs/Environment/Prefabs/BroadLeafDesktop";
            obj.object3D = (GameObject)MonoBehaviour.Instantiate(Resources.Load(obj.resourcePath));
            obj.object3D.AddComponent<Object3dMouseHandler>();
            obj.object3D.transform.position = nd.meterPosition;
            obj.object3D.tag = "3DObject";
            obj.object3D.name = "Broad Leaf Tree";

            return obj;
        }
        private Node readNode(XmlNode node)
        {
            Node nd = new Node();

               foreach(XmlAttribute attr in node.Attributes)
               {
               if (attr.Name == "id")
               nd.id = attr.Value;
               else if (attr.Name == "lat")
               nd.lat = float.Parse(attr.Value);
               else if (attr.Name == "lon")
               nd.lon = float.Parse(attr.Value);
               }

               if(node.HasChildNodes)
               {
               nd.tags = new List<Tag>();
               foreach(XmlNode child in node.ChildNodes)
               {
               if (child.Name == "tag")
                   nd.tags.Add(readTag(child));
               }
               }

               nd.type = ItemEnumerator.getNodeType(nd);

               return nd;
        }
        private Vector3[] getFacadeVertices(Node node1, Node node2)
        {
            Vector3[] vertices = {
                                     node1.meterPosition,
                                     node2.meterPosition,
                                     new Vector3(node2.meterPosition.x,equalizedBuildingHeight,node2.meterPosition.z),
                                     new Vector3(node1.meterPosition.x,equalizedBuildingHeight,node1.meterPosition.z)
                                 };

            return vertices;
        }
        private void createFacade(int facadeID, Node node1, Node node2,GameObject building)
        {
            GameObject facade = new GameObject("facade" +facadeID, typeof(MeshRenderer), typeof(MeshFilter), typeof(MeshCollider));
            facade.tag = "Building";
            facade.transform.parent = building.transform;
            facade.AddComponent<BuildingMouseHandler>();

            Vector3[] vertices = {
                                     node1.meterPosition,
                                     node2.meterPosition,
                                     new Vector3(node2.meterPosition.x,equalizedBuildingHeight,node2.meterPosition.z),
                                     new Vector3(node1.meterPosition.x,equalizedBuildingHeight,node1.meterPosition.z)
                                 };

            int[] triangles;

            if (!isClockwise)
                triangles = new int[] {1,2,3,3,0,1};
            else
                triangles = new int[] {0,3,2,2,1,0};

            //Texture Size Horizontal
            float aa;
            //Texture Size Vertical
            float bb;

            bb = equalizedBuildingHeight - buildingHeight; // Min Height

            try
            {
               aa = (vertices[1] - vertices[0]).magnitude / defaultTextureWidth;
            }
            catch (Exception)
            {
                aa = 1.0f;
            }

            Vector2[] UVcoords = new Vector2[4];
            if (isClockwise)
            {
                UVcoords[0] = new Vector2(0, (vertices[0].y - bb) / buildingHeight);
                UVcoords[1] = new Vector2(aa, (vertices[1].y - bb) / buildingHeight);
                UVcoords[2] = new Vector2(aa, 1);
                UVcoords[3] = new Vector2(0, 1);
            }
            else
            {
                UVcoords[0] = new Vector2(aa, (vertices[0].y - bb) / buildingHeight);
                UVcoords[1] = new Vector2(0, (vertices[1].y - bb) / buildingHeight);
                UVcoords[2] = new Vector2(0, 1);
                UVcoords[3] = new Vector2(aa, 1);
            }

            Geometry geo = new Geometry();
            Vector3 facadeNormal;
            if (isClockwise)
                facadeNormal = -1 * geo.findNormal(vertices[0], vertices[1], vertices[2]);
            else
                facadeNormal = geo.findNormal(vertices[0], vertices[1], vertices[2]);

            Vector3[] normals = {
                                    facadeNormal,
                                    facadeNormal,
                                    facadeNormal,
                                    facadeNormal
                                };

            Mesh mesh = new Mesh();
            mesh.vertices = vertices;
            mesh.uv = UVcoords;
            mesh.triangles = triangles;
            mesh.normals = normals;

            MeshFilter meshFilter = facade.GetComponent<MeshFilter>();
            meshFilter.mesh = mesh;

            MeshRenderer meshRenderer = facade.GetComponent<MeshRenderer>();
            int skinIndex = facadeSkins.FindIndex(o=>o.facadeID == facadeID);
            if (skinIndex == -1)
                meshRenderer.material = defaultMaterial;
            else
                meshRenderer.material = InGameTextureHandler.createMaterial(facadeSkins[skinIndex]);

            MeshCollider meshCollider = facade.GetComponent<MeshCollider>();
            meshCollider.sharedMesh = mesh;

            facades.Add(facade);
        }