Esempio n. 1
0
        private void CreateTurnFeature_NO(TurnFeatureClassWrapper turnFCW, OSMTurnInfo osmTurn)
        {
            IFeature turn = turnFCW.TurnFeatureClass.CreateFeature();

            IPoint    ptVia    = osmTurn.ViaFeature.Shape as IPoint;
            IPolyline lineFrom = osmTurn.FromFeature.Shape as IPolyline;
            IPolyline lineTo   = osmTurn.ToFeature.Shape as IPolyline;

            // Create Turn Shape
            bool   edge1End, edge2End;
            double posFrom, posTo;
            IPoint ptStart = GetTurnEndpoint(lineFrom, ptVia, out edge1End, out posFrom);
            IPoint ptEnd   = GetTurnEndpoint(lineTo, ptVia, out edge2End, out posTo);

            turn.Shape = CreateTurnGeometry(ptStart, ptVia, ptEnd, lineFrom.SpatialReference);

            // Attributes (Edge1)
            turn.set_Value(turnFCW.idxEdge1End, (edge1End) ? "Y" : "N");
            turn.set_Value(turnFCW.idxEdge1FCID, osmTurn.FromFeature.Class.ObjectClassID);
            turn.set_Value(turnFCW.idxEdge1FID, osmTurn.FromFeature.OID);
            turn.set_Value(turnFCW.idxEdge1Pos, posFrom);

            // Attributes (Edge2)
            turn.set_Value(turnFCW.idxEdge2FCID, osmTurn.ToFeature.Class.ObjectClassID);
            turn.set_Value(turnFCW.idxEdge2FID, osmTurn.ToFeature.OID);
            turn.set_Value(turnFCW.idxEdge2Pos, posTo);

            // Restriction Type
            turn.set_Value(turnFCW.idxRestrict, osmTurn.TurnType);

            turn.Store();
        }
        private void PopulateTurnsFromRelations()
        {
            IFeatureWorkspace fws = (IFeatureWorkspace)_osmDataset.Workspace;

            TurnFeatureClassWrapper fcTurn = new TurnFeatureClassWrapper();
            fcTurn.OpenTurnFeatureClass(fws, _turnClassName);

            // Add NDS Turn features to the turn feature class
            foreach (OSMTurnInfo osmTurn in EnumerateOsmTurnRestrictions(fws))
            {
                TaskManager.CheckCancel();

                if (osmTurn.TurnType.StartsWith("NO", StringComparison.CurrentCultureIgnoreCase))
                    CreateTurnFeature_NO(fcTurn, osmTurn);
                else if (osmTurn.TurnType.StartsWith("ONLY", StringComparison.CurrentCultureIgnoreCase))
                    CreateTurnFeature_ONLY(fcTurn, osmTurn);
            }
        }
Esempio n. 3
0
        private void CreateTurnFeature_ONLY(TurnFeatureClassWrapper turnFCW, OSMTurnInfo osmTurn)
        {
            IPoint    ptVia    = osmTurn.ViaFeature.Shape as IPoint;
            IPolyline lineFrom = osmTurn.FromFeature.Shape as IPolyline;

            bool   edge1End, edge2End;
            double posFrom, posTo;
            IPoint ptStart = GetTurnEndpoint(lineFrom, ptVia, out edge1End, out posFrom);

            foreach (INetworkEdge edge in EnumerateAdjacentTurnEdges(osmTurn, edge1End))
            {
                IFeature turn = turnFCW.TurnFeatureClass.CreateFeature();

                INetworkSource srcTo     = _networkDataset.get_SourceByID(edge.SourceID);
                IFeatureClass  fcTo      = ((IFeatureClassContainer)_networkDataset).get_ClassByName(srcTo.Name);
                IFeature       featureTo = fcTo.GetFeature(edge.OID);
                IPolyline      lineTo    = featureTo.Shape as IPolyline;

                // Create Turn Shape
                IPoint ptEnd = GetTurnEndpoint(lineTo, ptVia, out edge2End, out posTo);
                turn.Shape = CreateTurnGeometry(ptStart, ptVia, ptEnd, lineFrom.SpatialReference);

                // Attributes (Edge1)
                turn.set_Value(turnFCW.idxEdge1End, (edge1End) ? "Y" : "N");
                turn.set_Value(turnFCW.idxEdge1FCID, osmTurn.FromFeature.Class.ObjectClassID);
                turn.set_Value(turnFCW.idxEdge1FID, osmTurn.FromFeature.OID);
                turn.set_Value(turnFCW.idxEdge1Pos, posFrom);

                // Attributes (Edge2)
                turn.set_Value(turnFCW.idxEdge2FCID, featureTo.Class.ObjectClassID);
                turn.set_Value(turnFCW.idxEdge2FID, featureTo.OID);
                turn.set_Value(turnFCW.idxEdge2Pos, posTo);

                // Restriction Type
                turn.set_Value(turnFCW.idxRestrict, "NO");

                turn.Store();
            }
        }
Esempio n. 4
0
        private void PopulateTurnsFromRelations()
        {
            IFeatureWorkspace fws = (IFeatureWorkspace)_osmDataset.Workspace;

            TurnFeatureClassWrapper fcTurn = new TurnFeatureClassWrapper();

            fcTurn.OpenTurnFeatureClass(fws, _turnClassName);

            // Add NDS Turn features to the turn feature class
            foreach (OSMTurnInfo osmTurn in EnumerateOsmTurnRestrictions(fws))
            {
                TaskManager.CheckCancel();

                if (osmTurn.TurnType.StartsWith("NO", StringComparison.CurrentCultureIgnoreCase))
                {
                    CreateTurnFeature_NO(fcTurn, osmTurn);
                }
                else if (osmTurn.TurnType.StartsWith("ONLY", StringComparison.CurrentCultureIgnoreCase))
                {
                    CreateTurnFeature_ONLY(fcTurn, osmTurn);
                }
            }
        }
Esempio n. 5
0
        private void CreateTurnFeature_ONLY(TurnFeatureClassWrapper turnFCW, OSMTurnInfo osmTurn)
        {
            IPoint ptVia = osmTurn.ViaFeature.Shape as IPoint;
            IPolyline lineFrom = osmTurn.FromFeature.Shape as IPolyline;

            bool edge1End, edge2End;
            double posFrom, posTo;
            IPoint ptStart = GetTurnEndpoint(lineFrom, ptVia, out edge1End, out posFrom);

            foreach (INetworkEdge edge in EnumerateAdjacentTurnEdges(osmTurn, edge1End))
            {
                IFeature turn = turnFCW.TurnFeatureClass.CreateFeature();

                INetworkSource srcTo = _networkDataset.get_SourceByID(edge.SourceID);
                IFeatureClass fcTo = ((IFeatureClassContainer)_networkDataset).get_ClassByName(srcTo.Name);
                IFeature featureTo = fcTo.GetFeature(edge.OID);
                IPolyline lineTo = featureTo.Shape as IPolyline;

                // Create Turn Shape
                IPoint ptEnd = GetTurnEndpoint(lineTo, ptVia, out edge2End, out posTo);
                turn.Shape = CreateTurnGeometry(ptStart, ptVia, ptEnd, lineFrom.SpatialReference);

                // Attributes (Edge1)
                turn.set_Value(turnFCW.idxEdge1End, (edge1End) ? "Y" : "N");
                turn.set_Value(turnFCW.idxEdge1FCID, osmTurn.FromFeature.Class.ObjectClassID);
                turn.set_Value(turnFCW.idxEdge1FID, osmTurn.FromFeature.OID);
                turn.set_Value(turnFCW.idxEdge1Pos, posFrom);

                // Attributes (Edge2)
                turn.set_Value(turnFCW.idxEdge2FCID, featureTo.Class.ObjectClassID);
                turn.set_Value(turnFCW.idxEdge2FID, featureTo.OID);
                turn.set_Value(turnFCW.idxEdge2Pos, posTo);

                // Restriction Type
                turn.set_Value(turnFCW.idxRestrict, "NO");

                turn.Store();
            }
        }
Esempio n. 6
0
        private void CreateTurnFeature_NO(TurnFeatureClassWrapper turnFCW, OSMTurnInfo osmTurn)
        {
            IFeature turn = turnFCW.TurnFeatureClass.CreateFeature();

            IPoint ptVia = osmTurn.ViaFeature.Shape as IPoint;
            IPolyline lineFrom = osmTurn.FromFeature.Shape as IPolyline;
            IPolyline lineTo = osmTurn.ToFeature.Shape as IPolyline;

            // Create Turn Shape
            bool edge1End, edge2End;
            double posFrom, posTo;
            IPoint ptStart = GetTurnEndpoint(lineFrom, ptVia, out edge1End, out posFrom);
            IPoint ptEnd = GetTurnEndpoint(lineTo, ptVia, out edge2End, out posTo);
            turn.Shape = CreateTurnGeometry(ptStart, ptVia, ptEnd, lineFrom.SpatialReference);

            // Attributes (Edge1)
            turn.set_Value(turnFCW.idxEdge1End, (edge1End) ? "Y" : "N");
            turn.set_Value(turnFCW.idxEdge1FCID, osmTurn.FromFeature.Class.ObjectClassID);
            turn.set_Value(turnFCW.idxEdge1FID, osmTurn.FromFeature.OID);
            turn.set_Value(turnFCW.idxEdge1Pos, posFrom);

            // Attributes (Edge2)
            turn.set_Value(turnFCW.idxEdge2FCID, osmTurn.ToFeature.Class.ObjectClassID);
            turn.set_Value(turnFCW.idxEdge2FID, osmTurn.ToFeature.OID);
            turn.set_Value(turnFCW.idxEdge2Pos, posTo);

            // Restriction Type
            turn.set_Value(turnFCW.idxRestrict, osmTurn.TurnType);

            turn.Store();
        }