How to create geometric networks within a geodatabase

简介: public void CreateGeometricNetwork(IWorkspace workspace, IFeatureDatasetName featureDatasetName) { // Create a network loader.
public void CreateGeometricNetwork(IWorkspace workspace, IFeatureDatasetName
    featureDatasetName)
{
    // Create a network loader.
    INetworkLoader2 networkLoader2 = new NetworkLoaderClass();

    // Set the network name.
    networkLoader2.NetworkName = "Water_Net";

    // Set the network type.
    networkLoader2.NetworkType = esriNetworkType.esriNTUtilityNetwork;

    // Set the containing feature dataset.
    networkLoader2.FeatureDatasetName = (IDatasetName)featureDatasetName;

    // Add the two classes to the network.
    if (networkLoader2.CanUseFeatureClass("Distribmains") ==
        esriNetworkLoaderFeatureClassCheck.esriNLFCCValid)
    {
        networkLoader2.AddFeatureClass("Distribmains",
            esriFeatureType.esriFTComplexEdge, null, false);
    }

    if (networkLoader2.CanUseFeatureClass("Tanks") ==
        esriNetworkLoaderFeatureClassCheck.esriNLFCCValid)
    {
        networkLoader2.AddFeatureClass("Tanks", esriFeatureType.esriFTSimpleJunction,
            null, false);
    }

    // Set the enabled field for the distribmains class.
    INetworkLoaderProps networkLoaderProps = (INetworkLoaderProps)networkLoader2;
    String defaultEnabledFieldName = networkLoaderProps.DefaultEnabledField;
    esriNetworkLoaderFieldCheck enabledFieldCheck =
        networkLoader2.CheckEnabledDisabledField("Tanks", defaultEnabledFieldName);
    switch (enabledFieldCheck)
    {
        case esriNetworkLoaderFieldCheck.esriNLFCValid:
        case esriNetworkLoaderFieldCheck.esriNLFCNotFound:
            networkLoader2.PutEnabledDisabledFieldName("Tanks",
                defaultEnabledFieldName);
            break;
        default:
            Console.WriteLine(
                "The field {0} could not be used as an enabled/disabled field.",
                defaultEnabledFieldName);
            break;
    }

    networkLoader2.PreserveEnabledValues = true;

    // Set the ancillary role field for the tanks class.
    String defaultAncillaryRoleFieldName =
        networkLoaderProps.DefaultAncillaryRoleField;
    esriNetworkLoaderFieldCheck ancillaryRoleFieldCheck =
        networkLoader2.CheckAncillaryRoleField("Tanks",
        defaultAncillaryRoleFieldName);
    switch (ancillaryRoleFieldCheck)
    {
        case esriNetworkLoaderFieldCheck.esriNLFCValid:
        case esriNetworkLoaderFieldCheck.esriNLFCNotFound:
            networkLoader2.PutAncillaryRole("Tanks",
                esriNetworkClassAncillaryRole.esriNCARSourceSink,
                defaultAncillaryRoleFieldName);
            break;
        default:
            Console.WriteLine(
                "The field {0} could not be used as an ancillary role field.",
                defaultAncillaryRoleFieldName);
            break;
    }

    // If the geodatabase is an SDE GDB, set the configuration keyword.
    if (workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
    {
        networkLoader2.ConfigurationKeyword = "Network_Defaults";
    }

    // Set the snap tolerance for the network.
    networkLoader2.SnapTolerance = networkLoader2.MinSnapTolerance;

    // Add a weight with a double type to the network.
    networkLoader2.AddWeight("MainWeight", esriWeightType.esriWTDouble, 0);

    // For weights of type esriWTBitGate, the BitGateSize parameter should be set:
    networkLoader2.AddWeight("WTBitGateEx", esriWeightType.esriWTBitGate, 5);

    // Associate the MainWeight weight with the DIAMETER field of Distribmains.
    networkLoader2.AddWeightAssociation("MainWeight", "Distribmains", "DIAMETER");

    // Load the network.
    networkLoader2.LoadNetwork();

    // Get the name of the network's error table.
    String errorTableName = networkLoader2.ErrorTableName;

    // Display the number of invalid features in the Distribmains class.
    int numInvalidFeatures = networkLoader2.get_NumInvalidFeatures("Distribmains");
    Console.WriteLine("Distribmains contains {0} invalid features.",
        numInvalidFeatures);

    // Display the number of invalid features in the network.
    int totalNumInvalidFeatures = networkLoader2.TotalNumInvalidFeatures;
    Console.WriteLine("The network contains {0} invalid features.",
        totalNumInvalidFeatures);
}

相关文章
|
2月前
|
算法 BI 计算机视觉
[Initial Image Segmentation Generator]论文实现:Efficient Graph-Based Image Segmentation
[Initial Image Segmentation Generator]论文实现:Efficient Graph-Based Image Segmentation
35 1
|
11月前
|
机器学习/深度学习 人工智能 自然语言处理
OneIE:A Joint Neural Model for Information Extraction with Global Features论文解读
大多数现有的用于信息抽取(IE)的联合神经网络模型使用局部任务特定的分类器来预测单个实例(例如,触发词,关系)的标签,而不管它们之间的交互。
128 0
|
11月前
|
存储 自然语言处理 测试技术
LASS: Joint Language Semantic and Structure Embedding for Knowledge Graph Completion 论文解读
补全知识三元组的任务具有广泛的下游应用。结构信息和语义信息在知识图补全中都起着重要作用。与以往依赖知识图谱的结构或语义的方法不同
93 0
|
11月前
|
人工智能 自然语言处理 算法
UIE: Unified Structure Generation for Universal Information Extraction 论文解读
信息提取受到其不同目标、异构结构和特定需求模式的影响。本文提出了一个统一的文本到结构生成框架,即UIE,该框架可以对不同的IE任务进行统一建模,自适应生成目标结构
364 0
|
11月前
|
机器学习/深度学习 自然语言处理 算法
TPLinker: Single-stage Joint Extraction of Entities and Relations Through Token Pair Linking 论文解读
近年来,从非结构化文本中提取实体和关系引起了越来越多的关注,但由于识别共享实体的重叠关系存在内在困难,因此仍然具有挑战性。先前的研究表明,联合学习可以显著提高性能。然而,它们通常涉及连续的相互关联的步骤,并存在暴露偏差的问题。
141 0
|
11月前
|
机器学习/深度学习 自然语言处理 算法
Joint Information Extraction with Cross-Task and Cross-Instance High-Order Modeling 论文解读
先前的信息抽取(IE)工作通常独立地预测不同的任务和实例(例如,事件触发词、实体、角色、关系),而忽略了它们的相互作用,导致模型效率低下。
69 0
|
11月前
|
自然语言处理 算法 知识图谱
DEGREE: A Data-Efficient Generation-Based Event Extraction Model论文解读
事件抽取需要专家进行高质量的人工标注,这通常很昂贵。因此,学习一个仅用少数标记示例就能训练的数据高效事件抽取模型已成为一个至关重要的挑战。
89 0
|
机器学习/深度学习 存储 传感器
Automated defect inspection system for metal surfaces based on deep learning and data augmentation
简述:卷积变分自动编码器(CVAE)生成特定的图像,再使用基于深度CNN的缺陷分类算法进行分类。在生成足够的数据来训练基于深度学习的分类模型之后,使用生成的数据来训练分类模型。
116 0
|
机器学习/深度学习 传感器 编解码
Remote Sensing Images Semantic Segmentation with General Remote Sensing Vision Model via a Self-Supe
Remote Sensing Images Semantic Segmentation with General Remote Sensing Vision Model via a Self-Supe
80 0
Remote Sensing Images Semantic Segmentation with General Remote Sensing Vision Model via a Self-Supe
《Investigation of Transformer based Spelling Correction Model for CTC-based End-to-End Mandarin Speech Recognition》电子版地址
Investigation of Transformer based Spelling Correction Model for CTC-based End-to-End Mandarin Speech Recognition
83 0
《Investigation of Transformer based Spelling Correction Model for CTC-based End-to-End Mandarin Speech Recognition》电子版地址