//The SelectReduction procedure works with the input node schematic node candidate to the
        //reduction and with the input linkElements list of schematic link elements incident to
        //this schematic node.	It must return True for the output reduce boolean parameter if
        //the node is reduced, false if the node is kept.	 When the output ppLink schematic link
        //is not nothing, it determines the target node that will be used to reconnect the links
        //incidents to the reduced node.	In this sample procedure, the node candidate to the
        //reduction is analyzed. If records related to this node exist in the plants_equipments table,
        //the node is kept (output reduce parameter is False); else, it is reduced (output reduce
        //parameter is True).
        public bool SelectReduction(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode node, ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature enumLink, ref ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink link)
        {
            // if associated feature doesn't exist do nothing
            ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature schemAssociatedNode;
            schemAssociatedNode = node as ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature;
            if (schemAssociatedNode == null)
            {
                return(false);
            }

            // if dataset is not plants do nothing
            ESRI.ArcGIS.Geodatabase.IDataset schemElementClass;
            schemElementClass = (ESRI.ArcGIS.Geodatabase.IDataset)schemAssociatedNode.SchematicElementClass;
            if (schemElementClass == null)
            {
                return(false);
            }
            if (schemElementClass.Name.IndexOf("plants") < 0)
            {
                return(false);
            }

            // get workspace
            ESRI.ArcGIS.Geodatabase.IFeatureWorkspace plantsWorkspace;
            plantsWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)schemElementClass.Workspace;

            // open table plants_equipments
            ESRI.ArcGIS.Geodatabase.ITable plantsEquipment;
            plantsEquipment = plantsWorkspace.OpenTable("plants_equipments");
            if (plantsEquipment == null)
            {
                return(false);
            }


            // filter for the selected feature
            ESRI.ArcGIS.Schematic.ISchematicInMemoryFeaturePrimaryAssociation schemAssociation;
            schemAssociation = schemAssociatedNode as ESRI.ArcGIS.Schematic.ISchematicInMemoryFeaturePrimaryAssociation;
            if (schemAssociation == null)
            {
                return(false);
            }

            ESRI.ArcGIS.Geodatabase.IQueryFilter plantsFilter;
            plantsFilter             = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
            plantsFilter.WhereClause = ("PlantID = " + schemAssociation.ObjectID);

            ESRI.ArcGIS.Geodatabase.ICursor plantsCursor;
            plantsCursor = plantsEquipment.Search(plantsFilter, true);

            // if found equipment return false
            if (plantsCursor != null && plantsCursor.NextRow() != null)
            {
                return(false);
            }

            return(true); // if this far
        }
        public bool SelectReduction(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode node, ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature enumLink, ref ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink link)
        {
            // if enumLink is empty do nothing
            if (enumLink == null)
            {
                return(false);
            }
            if (enumLink.Count == 0)
            {
                return(false);
            }

            enumLink.Reset();

            ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature schemAssociatedLink;
            schemAssociatedLink = enumLink.Next();

            // for each link in enumLink
            while (schemAssociatedLink != null)
            {
                // get cables
                ESRI.ArcGIS.Geodatabase.IFeature cablesFeature;
                cablesFeature = schemAssociatedLink.SchematicElement as ESRI.ArcGIS.Geodatabase.IFeature;

                if (cablesFeature == null)
                {
                    return(false);
                }

                // get cables class
                ESRI.ArcGIS.Geodatabase.IDataset cablesDataset;
                cablesDataset = (ESRI.ArcGIS.Geodatabase.IDataset)cablesFeature.Class;

                // if not the right class do nothing
                if (cablesDataset.Name.IndexOf("cables") == 0)
                {
                    return(false);
                }

                // get workspace
                ESRI.ArcGIS.Geodatabase.IFeatureWorkspace cablesWorkspace;
                cablesWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)cablesDataset.Workspace;

                // open table cables_attributes
                ESRI.ArcGIS.Geodatabase.ITable cablesTable;
                cablesTable = cablesWorkspace.OpenTable("cables_attributes");
                if (cablesTable == null)
                {
                    return(false);
                }

                // get diameter value
                object cableDiameter = cablesTable.GetRow(cablesFeature.OID).get_Value(1);

                if (cableDiameter.ToString() != "8")
                {
                    return(false);                                                 //if not 8 do nothing
                }
                schemAssociatedLink = enumLink.Next();
            }
            return(true);            // if this far
        }
示例#3
0
        public ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature SelectElementsToCollapse(ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureNode node, ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeature relatedFeatures)
        {
            // get feature
            ESRI.ArcGIS.Geodatabase.IFeature esriFeature;
            esriFeature = node as ESRI.ArcGIS.Geodatabase.IFeature;
            if (esriFeature == null)
            {
                return(null);
            }

            // get feature class
            ESRI.ArcGIS.Geodatabase.IFeatureClass esriFeatureClass;
            esriFeatureClass = esriFeature.Class as ESRI.ArcGIS.Geodatabase.IFeatureClass;

            // if not the right feature class do nothing
            if (esriFeatureClass.AliasName != "plants")
            {
                return(null);
            }

            bool okToCollapse = true;

            relatedFeatures.Reset();

            // Test if you want to collapse related element
            //ESRI.ArcGIS.Schematic.ISchematicElement schemElement = relatedElements.Next();
            //while ((schemElement != null) && okToCollapse)
            //{
            //  okToCollapse = CanCollapseElement(schemElement);
            //  schemElement = relatedElements.Next();
            //}

            if (!okToCollapse)
            {
                return(null);                // if nothing to collapse return nothing
            }
            else if (relatedFeatures.Count == 0)
            {
                EnumCollapsedElts enumCollapse = new EnumCollapsedElts();                 // create a list of feature to collapse

                // get incident links
                ESRI.ArcGIS.Schematic.IEnumSchematicInMemoryFeatureLink enumLinks;
                enumLinks = node.GetIncidentLinks(ESRI.ArcGIS.Schematic.esriSchematicEndPointType.esriSchematicOriginOrExtremityNode);

                if (enumLinks == null)
                {
                    return(enumCollapse);
                }
                if (enumLinks.Count > 1)
                {
                    enumLinks.Reset();
                    ESRI.ArcGIS.Schematic.ISchematicInMemoryFeatureLink schemLink;
                    // for each link
                    schemLink = enumLinks.Next();
                    if (schemLink != null)
                    {
                        enumCollapse.Add((ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature)node);                         // Add node to collapse

                        while (schemLink != null)
                        {
                            enumCollapse.Add((ESRI.ArcGIS.Schematic.ISchematicInMemoryFeature)schemLink);                             // Add link to collapse
                            schemLink = enumLinks.Next();
                        }
                    }
                }
                return(enumCollapse);
            }
            else
            {
                return(relatedFeatures);
            }
        }