Esempio n. 1
0
        /// <summary>Returns general network direction information from the XML</summary>
        public GeneralNetworkDirectionInfo GeneralNetworkDirections()
        {
            XElement xDirections = _xml.XPathSelectElement("//networkConfiguration/directions");

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

            GeneralNetworkDirectionInfo dirInfo = new GeneralNetworkDirectionInfo();

            dirInfo.LengthAttr = (string)xDirections.Element("length_attr");

            XElement xUnits = xDirections.Element("length_units");

            if (xUnits != null)
            {
                dirInfo.LengthUnits = (esriNetworkAttributeUnits)Enum.Parse(typeof(esriNetworkAttributeUnits), "esriNAU" + xUnits.Value);
            }

            dirInfo.RoadClassAttr = (string)xDirections.Element("road_class_attr");
            dirInfo.TimeAttr      = (string)xDirections.Element("time_attr");

            return(dirInfo);
        }
Esempio n. 2
0
        /// <summary>Creates an new (unbuilt) Network Dataset</summary>
        private void CreateBuildableNDS()
        {
            IDENetworkDataset2 deNetworkDataset = new DENetworkDatasetClass();

            deNetworkDataset.Buildable = true;

            ((IDataElement)deNetworkDataset).Name = _ndsName;

            // Copy the feature dataset's extent and spatial reference to the network dataset
            IDEGeoDataset deGeoDataset = (IDEGeoDataset)deNetworkDataset;

            deGeoDataset.Extent           = _extent;
            deGeoDataset.SpatialReference = _spatialReference;

            deNetworkDataset.ElevationModel = esriNetworkElevationModel.esriNEMNone;
            deNetworkDataset.SupportsTurns  = true;

            // General Network Directions
            GeneralNetworkDirectionInfo dirInfo = _xml.GeneralNetworkDirections();

            if (dirInfo != null)
            {
                INetworkDirections netdir = new NetworkDirectionsClass();
                netdir.LengthAttributeName      = dirInfo.LengthAttr;
                netdir.DefaultOutputLengthUnits = dirInfo.LengthUnits;
                netdir.RoadClassAttributeName   = dirInfo.RoadClassAttr;
                netdir.TimeAttributeName        = dirInfo.TimeAttr;

                deNetworkDataset.Directions = netdir;
            }

            IArray sources = new ArrayClass();

            foreach (INetworkSource ns in EnumerateNetworkSources())
            {
                sources.Add(ns);
            }

            IArray attrs = new ArrayClass();

            foreach (var na in _networkAttrs)
            {
                attrs.Add(na);
            }

            deNetworkDataset.Sources    = sources;
            deNetworkDataset.Attributes = attrs;

            // Get the feature dataset extension and create the network dataset from the data element.
            IFeatureDatasetExtension fdExtension = ((IFeatureDatasetExtensionContainer)_osmDataset).FindExtension(esriDatasetType.esriDTNetworkDataset);

            _networkDataset = (INetworkDataset)((IDatasetContainer2)fdExtension).CreateDataset((IDEDataset)deNetworkDataset);
        }