예제 #1
0
 public new void Create(CarriageWay carriageWay, RoadCentreLine centreLine)
 {
     if (centreLine.Road.LeftPavementActive)
     {
         base.Create(carriageWay, centreLine);
     }
 }
예제 #2
0
    public Street(Intersection from, Intersection to, OSMWay way, OSMData osm, Polyline pathway)
    {
        this.from = from;
        this.to   = to;
        this.way  = way;
        //this.osm = osm;

        //Creation of the pathway is handled outside (by bridge)
        this.pathway = pathway;
        centerLine   = new Polyline(pathway.Vertices);


        //Needs centerLine, therefore after that
        from.AddStreet(this);
        to.AddStreet(this);

        /*Default is oneway=no, except for highway=motorway which implies oneway=yes. junction=roundabout also implies oneway=yes. highway=motorway_link has been a discussion a few times before, and it's best to add the oneway=* tag on those all the time, one way or not. --Eimai 12:59, 8 January 2009 (UTC)
         * Should this be indicated in the page? --Seav 10:49, 14 January 2009 (UTC)
         * Other implicit oneway=yes cases are: highway=motorway_link, highway=trunk_link and highway=primary_link. --Beldin 21:55, 22 April 2009 (UTC)*/

        if (way.Tags.ContainsKey("oneway"))
        {
            if (way.Tags["oneway"] == "yes" || way.Tags["oneway"] == "1" || way.Tags["oneway"] == "true")
            {
                isOneWay = true;
            }
        }
        if (way.Tags.ContainsKey("highway"))
        {
            if (way.Tags["highway"] == "motorway")
            {
                isOneWay = true;
            }
        }
        if (way.Tags.ContainsKey("junction"))
        {
            if (way.Tags["junction"] == "roundabout")
            {
                isOneWay = true;
            }
        }

        if (isOneWay)
        {
            carriageways[0] = new CarriageWay(way);
        }
        else
        {
            carriageways[0] = new CarriageWay(way);
            carriageways[1] = new CarriageWay(way);
        }
    }
예제 #3
0
    public Street(Intersection from, Intersection to, OSMWay way, OSMData osm)
    {
        this.from = from;
        this.to   = to;
        this.way  = way;
        //this.osm = osm;

        OSMNode node;

        pathway = new Polyline();

        foreach (long nodeId in way.GetWayNodesFromTo(from, to))
        {
            if (osm.nodes.TryGetValue(nodeId, out node))
            {
                pathway.Add(new Vertex(node + Vector3.up * 0.1f));
            }
        }

        centerLine = new Polyline(pathway.Vertices);


        //Needs centerLine, therefore after that
        from.AddStreet(this);
        to.AddStreet(this);

        /*Default is oneway=no, except for highway=motorway which implies oneway=yes. junction=roundabout also implies oneway=yes. highway=motorway_link has been a discussion a few times before, and it's best to add the oneway=* tag on those all the time, one way or not. --Eimai 12:59, 8 January 2009 (UTC)
         * Should this be indicated in the page? --Seav 10:49, 14 January 2009 (UTC)
         * Other implicit oneway=yes cases are: highway=motorway_link, highway=trunk_link and highway=primary_link. --Beldin 21:55, 22 April 2009 (UTC)*/


        if (way.Tags.ContainsKey("oneway"))
        {
            if (way.Tags["oneway"] == "yes" || way.Tags["oneway"] == "1" || way.Tags["oneway"] == "true")
            {
                isOneWay = true;
            }
        }
        if (way.Tags.ContainsKey("highway"))
        {
            if (way.Tags["highway"] == "motorway")
            {
                isOneWay = true;
            }
        }
        if (way.Tags.ContainsKey("junction"))
        {
            if (way.Tags["junction"] == "roundabout")
            {
                isOneWay = true;
            }
        }

        if (isOneWay)
        {
            carriageways[0] = new CarriageWay(way);
        }
        else
        {
            carriageways[0] = new CarriageWay(way);
            carriageways[1] = new CarriageWay(way);
        }
    }
예제 #4
0
    public void CreateMesh(ModularMesh mesh)
    {
        Vector3 nodePos = node;

        Vertex intersectionMid = new Vertex(nodePos);
        //Create Intersection Quads (for testing)
        Vector2 intersectionPoint;


        //"PushBack"
        if (intersectionMembers.Count >= 2)
        {
            for (int i = 0; i < intersectionMembers.Count - 1; i++)
            {
                if (Polyline.Intersection(intersectionMembers[i].LeftOutline, intersectionMembers[i + 1].RightOutline, out intersectionPoint))
                {
                    float neededFromOffset0 = 5f;
                    float neededFromOffset1 = 5f;

                    //Calculate
                    //TODO

                    intersectionMembers[i].FromOffset     = Mathf.Min(intersectionMembers[i].FromOffset, neededFromOffset0);
                    intersectionMembers[i + 1].FromOffset = Mathf.Min(intersectionMembers[i + 1].FromOffset, neededFromOffset1);
                }
            }

            if (Polyline.Intersection(intersectionMembers[intersectionMembers.Count - 1].LeftOutline, intersectionMembers[0].RightOutline, out intersectionPoint))
            {
                float neededFromOffset0 = 5f;
                float neededFromOffset1 = 5f;

                //Calculate
                //TODO

                intersectionMembers[intersectionMembers.Count - 1].FromOffset = Mathf.Min(intersectionMembers[intersectionMembers.Count - 1].FromOffset, neededFromOffset0);
                intersectionMembers[0].FromOffset = Mathf.Min(intersectionMembers[0].FromOffset, neededFromOffset1);
            }
        }

        if (Type == IntersectionType.Intersection)
        {
            for (int i = 0; i < intersectionMembers.Count - 1; i++)
            {
                CarriageWay forwardCarriageWay  = intersectionMembers[i].ForwardCarriageWay;
                CarriageWay forwardCarriageWay2 = intersectionMembers[i + 1].ForwardCarriageWay;

                if (forwardCarriageWay != null && forwardCarriageWay2 != null)
                {
                    for (int j = 0; j < Mathf.Min(forwardCarriageWay.Count, forwardCarriageWay2.Count); j++)
                    {
                        CarLane carlane1 = (CarLane)forwardCarriageWay.GetLastStreetMemberOfType(typeof(CarLane));
                        CarLane carlane2 = (CarLane)forwardCarriageWay2.GetLastStreetMemberOfType(typeof(CarLane));

                        if (carlane1 != null && carlane2 != null)
                        {
                            //Quad newQuad = new Quad(carlane1.RightOutline.First, carlane1.LeftOutline.First, carlane2.LeftOutline.First, carlane2.RightOutline.First, mesh, MaterialManager.GetMaterial("error"));
                            //Debug.Log("Creating LaneQuad");
                        }
                        else
                        {
                            //Debug.Log("Carlanes null?!");
                        }
                    }
                }
                else
                {
                    //Debug.Log("CarriageWays nul!?");
                }
            }

            //for (int i = 0; i < intersectionMembers.Count; i++)
            //{
            //    if (intersectionMembers[i].BeginningLeft && intersectionMembers[i].BeginningRight)
            //    {
            //        new Triangle(intersectionMid, intersectionMembers[i].BeginningRight, intersectionMembers[i].BeginningLeft, mesh, MaterialManager.GetMaterial("diffuseDarkGray"));
            //    }
            //}

            //Triangle tri;
            //for (int i = 0; i < intersectionMembers.Count-1; i++)
            //{
            //    tri = new Triangle(intersectionMid, intersectionMembers[i+1].BeginningLeft, intersectionMembers[i].BeginningRight);
            //    if(!tri.IsClockwise())
            //        tri.AddToMesh(mesh, MaterialManager.GetMaterial("error"));
            //}
            //tri = new Triangle(intersectionMid, intersectionMembers[0].BeginningLeft, intersectionMembers[intersectionMembers.Count - 1].BeginningRight);
            //if (!tri.IsClockwise())
            //    tri.AddToMesh(mesh, MaterialManager.GetMaterial("error"));
        }

        if (Type == IntersectionType.Connection)
        {
            new Quad(intersectionMembers[0].BeginningRight, intersectionMembers[0].BeginningLeft, intersectionMembers[1].BeginningRight, intersectionMembers[1].BeginningLeft, mesh, MaterialManager.GetMaterial("diffuseGrey"));
        }

        if (Type == IntersectionType.DeadEnd)
        {
        }
    }