Beispiel #1
0
        public virtual double Evaluate(INetworkLocation networkLocation)
        {
            if ((Parent != null) && (IsTimeDependent))
            {
                //can't just convert to filters and handle by function since interpolation logic
                //is defined at networkcoverage level
                //return Parent.Evaluate<double>(GetFiltersInParent(Filters));
                if (Filters.Count != 1 || !(Filters[0] is VariableValueFilter <DateTime>))
                {
                    throw new ArgumentException(
                              "Please specify time filter to retrieve value from time related network coverage");
                }
                var currentTime = ((VariableValueFilter <DateTime>)Filters[0]).Values[0];

                return(((INetworkCoverage)Parent).Evaluate(currentTime, networkLocation));
            }
            //we might have a local filter
            if (IsTimeDependent && Filters.Count == 1 && Filters[0] is VariableValueFilter <DateTime> )
            {
                var time = ((VariableValueFilter <DateTime>)Filters[0]).Values[0];
                return(Evaluate(time, networkLocation));
            }
            if ((IsTimeDependent))
            {
                throw new ArgumentException(
                          "Please specify time filter to retrieve value from time related network coverage");
            }


            return(GetInterpolatedValue(new VariableValueFilter <INetworkLocation>(Locations, networkLocation)));
        }
        /// <summary>
        /// Updates the segments for all branches with branchlocation following this scheme:
        ///                b1
        /// n1---------------------------------n2
        ///
        /// A----------C---------B----------D--    - network locations
        ///                                        - segments
        /// </summary>
        /// <param name="coverage"></param>
        /// <param name="fullyCover"></param>
        /// when set to true the segment of the branch
        private static void UpdateSegmentsSegmentBetweenLocations(INetworkCoverage coverage, bool fullyCover)
        {
            coverage.Segments.Values.Clear();
            //var coverageLocations = coverage.Locations.Values.OrderBy(l => l.Offset).OrderBy(l => l.Branch);
            //sorting is done in coverage locations..don't need to do it here. This supports for reversed segments.
            var coverageLocations = coverage.Locations.Values;

            IBranch                  branch          = null;
            INetworkLocation         previous        = null;
            IList <INetworkLocation> branchLocations = new List <INetworkLocation>();

            foreach (var location in coverageLocations)
            {
                if ((null != previous) && (previous.Branch != location.Branch))
                {
                    IEnumerable <INetworkSegment> segments = UpdateSegmentsBranchSegmentBetweenLocations(fullyCover, branch, branchLocations);
                    foreach (var segment in segments)
                    {
                        coverage.Segments.Values.Add(segment);
                    }
                    branchLocations.Clear();
                }
                branchLocations.Add(location);
                branch   = location.Branch;
                previous = location;
            }
            if (branchLocations.Count > 0)
            {
                IEnumerable <INetworkSegment> segments = UpdateSegmentsBranchSegmentBetweenLocations(fullyCover, branch, branchLocations);
                foreach (var segment in segments)
                {
                    coverage.Segments.Values.Add(segment);
                }
            }
        }
Beispiel #3
0
        private static bool IsWithinSegment(INetworkSegment segment, INetworkLocation location)
        {
            if (segment.Branch != location.Branch)
            {
                return(false);
            }

            var begin = segment.Chainage;
            var end   = segment.EndChainage;

            if (!segment.DirectionIsPositive)
            {
                begin = segment.EndChainage;
                end   = segment.Chainage;
            }

            //add some rounding margin
            begin += 0.000001;
            end   -= 0.000001;

            if (begin < location.Chainage && location.Chainage < end)
            {
                return(true);
            }

            return(false);
        }
        public void NextValueOnSameBranch()
        {
            var network = new Network();

            var node1 = new Node("node1");
            var node2 = new Node("node2");

            network.Nodes.Add(node1);
            network.Nodes.Add(node2);

            var branch1 = new Branch("branch1", node1, node2, 100.0);

            network.Branches.Add(branch1);

            // create network coverate
            var networkCoverage = new NetworkCoverage {
                Network = network
            };

            NetworkLocationNextValueGenerator networkLocationNextValueGenerator = new NetworkLocationNextValueGenerator(networkCoverage);

            INetworkLocation location = networkLocationNextValueGenerator.GetNextValue();

            Assert.AreEqual(new NetworkLocation(branch1, 0), location);
            networkCoverage.Locations.Values.Add(location);

            Assert.AreEqual(new NetworkLocation(branch1, 1), networkLocationNextValueGenerator.GetNextValue());
        }
Beispiel #5
0
        private void drawTempLine(INetworkRoute route)
        {
            // 画出停靠点到映射点的虚线
            int segmentCount                   = route.SegmentCount;
            INetworkRouteSegment segment       = null;
            INetworkLocation     startLocation = null;
            INetworkLocation     endLocation   = null;
            IPoint       pointOnNetwork        = null;
            ICurveSymbol tmpLineSym            = new CurveSymbol();

            tmpLineSym.Color = System.Drawing.Color.Yellow;
            tmpLineSym.Width = -2;
            for (int i = 0; i < segmentCount; i++)
            {
                segment        = route.GetSegment(i);
                startLocation  = segment.StartLocation;
                pointOnNetwork = startLocation.NetworkPosition;
                fdepoint       = startLocation.Position;
                IPolyline tmpLine = geoFac.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                tmpLine.AppendPoint(fdepoint);
                tmpLine.AppendPoint(pointOnNetwork);
                tmpRenderLineArray.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(tmpLine, tmpLineSym, rootId));
                if (i == segmentCount - 1)
                {
                    endLocation    = segment.EndLocation;
                    pointOnNetwork = endLocation.NetworkPosition;
                    fdepoint       = endLocation.Position;
                    tmpLine        = geoFac.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
                    tmpLine.AppendPoint(fdepoint);
                    tmpLine.AppendPoint(pointOnNetwork);
                    tmpRenderLineArray.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(tmpLine, tmpLineSym, rootId));
                }
            }
        }
Beispiel #6
0
        public virtual void ToggleFixedPoint(INetworkLocation networkLocation)
        {
            var current = Evaluate(networkLocation);

            //new value is invert of current
            var newValue = current == 0?1:0;
            
            SetValues(new[] { newValue}, new VariableValueFilter<INetworkLocation>(Locations, networkLocation));
        }
Beispiel #7
0
        public virtual void ToggleFixedPoint(INetworkLocation networkLocation)
        {
            var current = Evaluate(networkLocation);

            //new value is invert of current
            var newValue = current == 0?1:0;

            SetValues(new[] { newValue }, new VariableValueFilter <INetworkLocation>(Locations, networkLocation));
        }
Beispiel #8
0
 public virtual double Evaluate(DateTime dateTime, INetworkLocation networkLocation)
 {
     if (!IsTimeDependent)
     {
         throw new ArgumentException(
                   "Please do not specify time filter to retrieve value from time related network coverage");
     }
     return(GetInterpolatedValue(new VariableValueFilter <DateTime>(Time, dateTime),
                                 new VariableValueFilter <INetworkLocation>(Locations, networkLocation)));
 }
Beispiel #9
0
        public override IFunction GetTimeSeries(ICoordinate coordinate)
        {
            //convert coordinate to networkLocation
            INetworkLocation nearestLocation = GetNearestNetworkLocation(coordinate);

            if (nearestLocation == null)
            {
                return(null);
            }

            return(GetTimeSeries(nearestLocation));
        }
Beispiel #10
0
        public void CreateSegmentsMultipleCrossSectionsAndFixedPoint()
        {
            IHydroNetwork network = CreateSegmentTestNetwork();
            var           branch1 = network.Channels.First();

            var discretization = new Discretization()
            {
                Network = network,
                SegmentGenerationMethod = SegmentGenerationMethod.SegmentBetweenLocations
            };

            HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage
                                                      branch1,        // branch
                                                      5.0,            // minimumDistance
                                                      false,          // gridAtStructure
                                                      0.5,            // structureDistance
                                                      false,          // gridAtCrossSection
                                                      true,           // gridAtFixedLength
                                                      2);             // fixedLength
            Assert.AreEqual(51, discretization.Locations.Values.Count);


            INetworkLocation networkLocation = discretization.Locations.Values.Where(nl => nl.Offset == 8).First();

            //DiscretizationHelper.SetUserDefinedGridPoint(networkLocation, true);
            discretization.ToggleFixedPoint(networkLocation);
            networkLocation = discretization.Locations.Values.Where(nl => nl.Offset == 32).First();
            discretization.ToggleFixedPoint(networkLocation);

            AddTestCrossSectionAt(network, branch1, 10.0);
            AddTestCrossSectionAt(network, branch1, 20.0);
            AddTestCrossSectionAt(network, branch1, 30.0);

            HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage
                                                      branch1,        // branch
                                                      5.0,            // minimumDistance
                                                      false,          // gridAtStructure
                                                      0.5,            // structureDistance
                                                      true,           // gridAtCrossSection
                                                      false,          // gridAtFixedLength
                                                      -1);            // fixedLength
            // expect gridpoints at:
            // begin and end 0 and 100
            // fixed locations 8 and 32.
            // 20 for the cross section, 10 and 30 should not be generated due to existing
            // fixed points and minimium distance 0f 5.
            Assert.AreEqual(5, discretization.Locations.Values.Count);
            Assert.AreEqual(0.0, discretization.Locations.Values[0].Offset, 1.0e-6);
            Assert.AreEqual(8.0, discretization.Locations.Values[1].Offset, 1.0e-6);
            Assert.AreEqual(20.0, discretization.Locations.Values[2].Offset, 1.0e-6);
            Assert.AreEqual(32.0, discretization.Locations.Values[3].Offset, 1.0e-6);
            Assert.AreEqual(100.0, discretization.Locations.Values[4].Offset, 1.0e-6);
        }
Beispiel #11
0
        public void CreateSegmentsFixedLocations()
        {
            IHydroNetwork network        = CreateSegmentTestNetwork();
            var           branch1        = network.Channels.First();
            var           discretization = new Discretization()
            {
                Network = network,
                SegmentGenerationMethod = SegmentGenerationMethod.SegmentBetweenLocations
            };

            HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage
                                                      branch1,        // branch
                                                      0.5,            // minimumDistance
                                                      false,          // gridAtStructure
                                                      0.5,            // structureDistance
                                                      false,          // gridAtCrossSection
                                                      true,           // gridAtFixedLength
                                                      10);            // fixedLength
            Assert.AreEqual(11, discretization.Locations.Values.Count);
            Assert.AreEqual(0.0, discretization.Locations.Values[0].Offset, 1.0e-6);
            Assert.AreEqual(50.0, discretization.Locations.Values[5].Offset, 1.0e-6);
            Assert.AreEqual(100.0, discretization.Locations.Values[10].Offset, 1.0e-6);

            INetworkLocation networkLocation = discretization.Locations.Values[7];

            Assert.AreEqual(70.0, networkLocation.Offset, 1.0e-6);
            discretization.ToggleFixedPoint(networkLocation);
            //DiscretizationHelper.SetUserDefinedGridPoint(networkLocation, true);

            HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage
                                                      branch1,        // branch
                                                      0.5,            // minimumDistance
                                                      false,          // gridAtStructure
                                                      0.5,            // structureDistance
                                                      false,          // gridAtCrossSection
                                                      true,           // gridAtFixedLength
                                                      40);            // fixedLength
            // expect values at
            // - 0 and 100 start and end
            // - 70 for fixed location
            // - none between 70 and 100
            // - (0 - 70) > 40, divide in equal parts -> 35
            Assert.AreEqual(4, discretization.Locations.Values.Count);
            Assert.AreEqual(0.0, discretization.Locations.Values[0].Offset, 1.0e-6);
            Assert.AreEqual(35.0, discretization.Locations.Values[1].Offset, 1.0e-6);
            Assert.AreEqual(70.0, discretization.Locations.Values[2].Offset, 1.0e-6);
            Assert.AreEqual(100.0, discretization.Locations.Values[3].Offset, 1.0e-6);
        }
        // TODO: make it work for T, make interpolators injectable
        //public override T GetInterpolatedValue<T>(params IVariableFilter[] filters)


        public virtual IFunction GetTimeSeries(INetworkLocation networkLocation)
        {
            IFunction filteredFunction = Filter(
                new VariableValueFilter <INetworkLocation>(Locations, networkLocation),
                new VariableReduceFilter(Locations));

            filteredFunction.Name = Name + " at " + networkLocation;
            //create an offline timeseris...
            var timeSeries = new TimeSeries();

            timeSeries.Components.Add(new Variable <double>());
            var times  = (IEnumerable <DateTime>)filteredFunction.Arguments[0].Values;
            var values = filteredFunction.Components[0].Values;

            timeSeries.SetValues(values, new VariableValueFilter <DateTime>(timeSeries.Time, times));
            return(timeSeries);
        }
Beispiel #13
0
 public int CompareTo(INetworkLocation other)
 {
     if (other.Branch != Branch)
     {
         return Branch.CompareTo(other.Branch);
     }
     if (Chainage > other.Chainage)
     {
         return 1;
     }
     if (Math.Abs(Chainage - other.Chainage) < Epsilon)
     {
         //don't take NAME into account, as happens in BranchFeature
         return 0;
     }
     return -1;
 }
Beispiel #14
0
 public int CompareTo(INetworkLocation other)
 {
     if (other.Branch != Branch)
     {
         return(Branch.CompareTo(other.Branch));
     }
     if (Chainage > other.Chainage)
     {
         return(1);
     }
     if (Math.Abs(Chainage - other.Chainage) < Epsilon)
     {
         //don't take NAME into account, as happens in BranchFeature
         return(0);
     }
     return(-1);
 }
Beispiel #15
0
        private INetworkLocation GetNearestNetworkLocation(ICoordinate coordinate)
        {
            //TODO: speed up. this sucks when we have 100000 locations (write performance test!).
            //TODO add a maximal distance otherwise return null
            double           minDistance = double.MaxValue;
            INetworkLocation minLocation = null;

            foreach (INetworkLocation location in Locations.Values)
            {
                double distance = coordinate.Distance(location.Geometry.Coordinate);
                if (distance < minDistance)
                {
                    minDistance = distance;
                    minLocation = location;
                }
            }
            return(minLocation);
        }
Beispiel #16
0
        /// <summary>
        /// returns the segment where networkLocation is located.
        /// networkLocation does not have to be a networkLocation in route.Locations.
        /// </summary>
        /// <param name="route"></param>
        /// <param name="networkLocation"></param>
        /// <returns></returns>
        public static INetworkSegment GetSegmentForNetworkLocation(Route route, INetworkLocation networkLocation)
        {
            var segments = route.Segments.Values.ToArray();

            foreach (var segment in segments)
            {
                if (segment.Branch != networkLocation.Branch)
                {
                    continue;
                }
                if ((networkLocation.Chainage > segment.Chainage) && (networkLocation.Chainage < segment.EndChainage))
                {
                    return(segment);
                }
                // segment can be reversed in coverage
                if ((networkLocation.Chainage < segment.Chainage) && (networkLocation.Chainage > segment.EndChainage))
                {
                    return(segment);
                }
            }
            return(null);
        }
Beispiel #17
0
        private void LocationsPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (Network == null)
            {
                return;
            }

            if (sender is INetworkLocation && e.PropertyName == "Geometry")
            {
                segmentsInitialized = false;

                if (Locations.IsAutoSorted)
                {
                    INetworkLocation networkLocation = (INetworkLocation)sender;

                    // if the geometry of a network location is changed (in the map) update sort of location arguments.
                    // Function does not support sorting by argument.
                    // For value based or immutable argument types this is not an issue.
                    // notes: checking for index change of networkLocation in Locations does not work
                    // MultiDimensionalArrayHelper.GetInsertionIndex is unreliable since Locations.Values are not sorted
                    var locationValues =
                        GetValues(new VariableValueFilter <INetworkLocation>(Locations, new[] { networkLocation }));
                    object[] values = new object[locationValues.Count];
                    for (int i = 0; i < locationValues.Count; i++)
                    {
                        values[i] = locationValues[i];
                    }
                    IsSorting = true;
                    RemoveValues(new VariableValueFilter <INetworkLocation>(Locations, new[] { networkLocation }));
                    SetValues(values, new VariableValueFilter <INetworkLocation>(Locations, new[] { networkLocation }));
                    IsSorting = false;
                }
            }

            updateLocationsDictionary = true;
        }
Beispiel #18
0
        public void CreateSegmentsMultipleStructuresAndFixedPoint()
        {
            IHydroNetwork network = CreateSegmentTestNetwork();
            var           branch1 = network.Channels.First();

            var discretization = new Discretization()
            {
                Network = network,
                SegmentGenerationMethod = SegmentGenerationMethod.SegmentBetweenLocations
            };

            HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage
                                                      branch1,        // branch
                                                      5.0,            // minimumDistance
                                                      false,          // gridAtStructure
                                                      0.5,            // structureDistance
                                                      false,          // gridAtCrossSection
                                                      true,           // gridAtFixedLength
                                                      2);             // fixedLength
            Assert.AreEqual(51, discretization.Locations.Values.Count);


            INetworkLocation networkLocation = discretization.Locations.Values.Where(nl => nl.Offset == 8).First();

            //DiscretizationHelper.SetUserDefinedGridPoint(networkLocation, true);
            discretization.ToggleFixedPoint(networkLocation);
            networkLocation = discretization.Locations.Values.Where(nl => nl.Offset == 32).First();
            discretization.ToggleFixedPoint(networkLocation);
            //DiscretizationHelper.SetUserDefinedGridPoint(networkLocation, true);

            AddTestStructureAt(network, branch1, 10.0);
            AddTestStructureAt(network, branch1, 20.0);
            AddTestStructureAt(network, branch1, 30.0);

            HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage
                                                      branch1,        // branch
                                                      6.0,            // minimumDistance
                                                      true,           // gridAtStructure
                                                      4.0,            // structureDistance
                                                      false,          // gridAtCrossSection
                                                      false,          // gridAtFixedLength
                                                      -1);            // fixedLength
            // expect gridpoints with no minimumDistance
            // 0  8 (6 14) (16 24) (26 34) 32 100
            // 0  6 8 14 16 24 26 32 34 100
            //        10   20   30                 // structure locations
            // 0    8   14    24    32      100    // result

            // fixed locations 8 and 32.
            // first structure (6) and 14
            // second structure 16 and 24; 16 will be merged into 14 -> 15
            // third structure 26 and (34); 26 will be merged into 24 -> 25
            // fixed points and minimium distance 0f 5.

            Assert.AreEqual(6, discretization.Locations.Values.Count);
            Assert.AreEqual(0.0, discretization.Locations.Values[0].Offset, 1.0e-6);
            Assert.AreEqual(8.0, discretization.Locations.Values[1].Offset, 1.0e-6);
            Assert.AreEqual(15.0, discretization.Locations.Values[2].Offset, 1.0e-6);
            Assert.AreEqual(25.0, discretization.Locations.Values[3].Offset, 1.0e-6);
            Assert.AreEqual(32.0, discretization.Locations.Values[4].Offset, 1.0e-6);
            Assert.AreEqual(100.0, discretization.Locations.Values[5].Offset, 1.0e-6);
        }
Beispiel #19
0
 public int CompareTo(INetworkLocation other)
 {
     return(base.CompareTo(other));
 }
        private static DateTime CalculateDateTimeTransition(INetworkCoverage coverage, double referenceValue, INetworkLocation location, DateTime dateTimePrevious, DateTime dateTimeCurrent, InterpolationType timeInterpolation)
        {
            var dateTimeIndex = coverage.Time.Values.IndexOf(dateTimeCurrent);

            if (dateTimeIndex == 0)
            {
                return(dateTimeCurrent);
            }

            TimeSpan timeSpan;

            switch (timeInterpolation)
            {
            case InterpolationType.None:
                return(dateTimeCurrent);

            case InterpolationType.Constant:
                // Constant interpolation: value changes in the middle of 'dateTime' and 'dateTimePrevious'
                timeSpan = dateTimeCurrent - dateTimePrevious;
                return(dateTimePrevious + new TimeSpan(timeSpan.Ticks / 2));

            case InterpolationType.Linear:
                var currentValue  = (double)coverage[dateTimeCurrent, location];
                var previousValue = (double)coverage[dateTimePrevious, location];
                timeSpan = dateTimeCurrent - dateTimePrevious;

                return(dateTimePrevious + new TimeSpan(Convert.ToInt64(timeSpan.Ticks * Math.Abs(previousValue - referenceValue) / Math.Abs(currentValue - previousValue))));

            default:
                throw new NotImplementedException(String.Format("Interpolation method {0} not supported", coverage.Time.InterpolationType));
            }
        }
 private static INetworkLocation GetLocationInCoverage(INetworkCoverage coverage, INetworkLocation location)
 {
     if (CheckIfNetworksMismatch(coverage.Network, location.Network)) //defined on different network
     {
         var coordinate = location.Geometry.Coordinate;
         var loc        = coverage.GetLocationOnBranch(coordinate.X, coordinate.Y);
         return(loc);
     }
     return(location);
 }
Beispiel #22
0
 public virtual bool IsFixedPoint(INetworkLocation location)
 {
     return Evaluate(location) == 1.0;
 }
Beispiel #23
0
        private void btnFindWC_Click(object sender, EventArgs e)
        {
            clear();
            clearDeep();

            IFdeCursor cursor = null;

            try
            {
                if (closestFacilitySolver == null)
                {
                    closestFacilitySolver = network.CreateClosestFacilitySolver();
                    closestFacilitySolver.ImpedanceAttributeName = "Length";
                }
                closestFacilitySolver.LocationSearchTolerance = double.Parse(txtSearchTolerance.Text);
                closestFacilitySolver.ClearFacilityLocations();
                closestFacilitySolver.ClearEventLocations();

                // 添加WC设施点
                foreach (IFeatureClass fc in fcMap_POI.Keys)
                {
                    if (fc.Name.Contains("WC"))
                    {
                        cursor = fc.Search(null, true);
                        IRowBuffer row = null;
                        while ((row = cursor.NextRow()) != null)
                        {
                            try
                            {
                                INetworkLocation facility = new NetworkLocation();
                                int    pos   = row.FieldIndex("Geometry");
                                IPoint point = row.GetValue(pos) as IPoint;
                                facility.Position = point;
                                facility.Name     = fc.Guid.ToString() + "_" + row.GetValue(0).ToString(); //设定名字"fcGUID_oid"
                                closestFacilitySolver.AddFacilityLocation(facility);
                            }
                            catch (COMException ex)
                            {
                            }
                        }
                        break;
                    }
                }
                if (closestFacilitySolver.FacilityLocationCount == 0)
                {
                    MessageBox.Show("添加的厕所数为0,请调整LocationSearchTolerance大小");
                    return;
                }

                // 添加人所在的位置
                INetworkEventLocation location = new NetworkEventLocation();
                this.axRenderControl1.Camera.GetCamera2(out fdepoint, out ang);
                location.Position            = fdepoint;
                location.Name                = "I'mHere";
                location.TargetFacilityCount = int.Parse(txtMaxNum.Text);
                location.SetCutoff("Length", double.Parse(txtCutoff.Text));
                closestFacilitySolver.AddEventLocation(location);
                // 可视化人的位置
                IImagePointSymbol ips = new ImagePointSymbol();
                ips.ImageName = "#(i)";
                ips.Size      = 50;
                renderPoint   = this.axRenderControl1.ObjectManager.CreateRenderPoint(fdepoint, ips, rootId);

                if (closestFacilitySolver.Solve())
                {
                    int routeCount = closestFacilitySolver.RouteCount;
                    if (routeCount == 0)
                    {
                        MessageBox.Show("没有厕所在指定范围内");
                        return;
                    }
                    for (int i = 0; i < routeCount; i++)
                    {
                        INetworkRoute route = closestFacilitySolver.GetRoute(i);
                        if (route != null)
                        {
                            // 可视化线路
                            ICurveSymbol lineSym = new CurveSymbol();
                            lineSym.Color = System.Drawing.Color.Yellow;
                            lineSym.Width = -2;
                            IGeometry geo = route.GetRouteGeometry();
                            if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                            {
                                IPolyline line = geo as IPolyline;
                                renderLine = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, lineSym, rootId);
                                renderLine.MaxVisibleDistance = 10000;
                                renderLineArray.Add(renderLine);
                            }
                            else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                            {
                                IMultiPolyline line = geo as IMultiPolyline;
                                multiRenderLine = this.axRenderControl1.ObjectManager.CreateRenderMultiPolyline(line, lineSym, rootId);
                                multiRenderLine.MaxVisibleDistance = 10000;
                                multiRenderLineArray.Add(multiRenderLine);
                            }

                            drawTempLine(route);

                            // 高亮厕所
                            int segmentCount = route.SegmentCount;
                            for (int j = 0; j < segmentCount; j++)
                            {
                                INetworkLocation endLocation = route.GetSegment(j).EndLocation;
                                string[]         strs        = endLocation.Name.Split('_');
                                foreach (IFeatureClass fc in fcMap_POI.Keys)
                                {
                                    if (fc.Guid.ToString() == strs[0])
                                    {
                                        this.axRenderControl1.FeatureManager.HighlightFeature(fc, int.Parse(strs[1]), System.Drawing.Color.Yellow);
                                        break;
                                    }
                                }

                                //////////////////////测试NetworkElement相关//////////////////////////////////
                                INetworkElementCollection elementCols = route.GetSegment(j).GetNetworkElements();
                                for (int c = 0; c < elementCols.Count; c++)
                                {
                                    INetworkElement element = elementCols.Get(c);
                                    if (element.Type == gviNetworkElementType.gviEdge)
                                    {
                                        INetworkEdge edge  = element as INetworkEdge;
                                        int          subId = edge.SubID;
                                    }
                                    else
                                    {
                                        INetworkJunction       junction = element as INetworkJunction;
                                        INetworkEdgeCollection edgeCol  = junction.IncomingEdges;
                                        for (int ee = 0; ee < edgeCol.Count; ee++)
                                        {
                                            INetworkEdge edge  = edgeCol.Get(ee);
                                            int          subId = edge.SubID;
                                        }
                                    }
                                }
                                //////////////////////////////////////////////////////////////////////////
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("查找失败");
                }
            }
            catch (COMException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
            }
        }
Beispiel #24
0
 public virtual bool IsFixedPoint(INetworkLocation location)
 {
     return(Evaluate(location) == 1.0);
 }
Beispiel #25
0
        private static bool IsWithinSegment(INetworkSegment segment,INetworkLocation location)
        {
            if (segment.Branch != location.Branch)
                return false;

            var begin = segment.Chainage;
            var end = segment.EndChainage;

            if (!segment.DirectionIsPositive)
            {
                begin = segment.EndChainage;
                end = segment.Chainage;
            }

            //add some rounding margin
            begin += 0.000001;
            end -= 0.000001;

            if (begin < location.Chainage && location.Chainage < end)
                return true;

            return false;
        }
Beispiel #26
0
 /// <summary>
 /// returns the segment where networkLocation is located.
 /// networkLocation does not have to be a networkLocation in route.Locations.
 /// </summary>
 /// <param name="route"></param>
 /// <param name="networkLocation"></param>
 /// <returns></returns>
 public static INetworkSegment GetSegmentForNetworkLocation(Route route, INetworkLocation networkLocation)
 {
     var segments = route.Segments.Values.ToArray();
     foreach (var segment in segments)
     {
         if (segment.Branch != networkLocation.Branch)
         {
             continue;
         }
         if ((networkLocation.Chainage > segment.Chainage) && (networkLocation.Chainage < segment.EndChainage))
         {
             return segment;
         }
         // segment can be reversed in coverage
         if ((networkLocation.Chainage < segment.Chainage) && (networkLocation.Chainage > segment.EndChainage))
         {
             return segment;
         }
     }
     return null;
 }