Example #1
0
    public static void Init2DMatrix(out ArrayClass m, out int[][] refm)
    {
        int i, j, temp;

        i = 0;

        //m = new int[size, size];
        m    = new ArrayClass(size);
        refm = new int[size][];

        for (int k = 0; k < refm.Length; k++)
        {
            refm[k] = new int[size];
        }

        while (i < size)
        {
            j = 0;
            while (j < size)
            {
                temp        = rand.Next();
                m.a2d[i, j] = temp - (temp / 120) * 120 - 60;
                refm[i][j]  = temp - (temp / 120) * 120 - 60;
                j++;
            }
            i++;
        }
    }
Example #2
0
        /// 获得个人地理数据库中要素类的名称
        /// </summary>
        /// <param name="pAccessWorkSpace">个人地理数据库工作空间</param>
        /// <returns pArrayFeatureClassName>个人地理数据库中要素类的名称</returns>
        public static IArray GetFeactureClassName_From_AccessWorkSpace(IWorkspace pAccessWorkSpace)
        {
            IArray pArrayFeatureClassName = new ArrayClass();

            //遍历直接位于地理数据库下的要素类FeatureClass
            IEnumDatasetName enumDatasetName = ((IWorkspace)pAccessWorkSpace).get_DatasetNames(esriDatasetType.esriDTFeatureClass);
            IDatasetName     datasetName     = enumDatasetName.Next();

            while (datasetName != null)
            {
                pArrayFeatureClassName.Add(datasetName.Name.ToString());
                datasetName = enumDatasetName.Next();//推进器
            }

            //遍历位于地理数据库数据集featuredataset下的要素类
            enumDatasetName = ((IWorkspace)pAccessWorkSpace).get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
            datasetName     = enumDatasetName.Next();
            while (datasetName != null)
            {
                IFeatureDatasetName featureDatasetName = (IFeatureDatasetName)datasetName;
                IEnumDatasetName    enumDatasetNameFC  = featureDatasetName.FeatureClassNames;
                IDatasetName        datasetNameFC      = enumDatasetNameFC.Next();
                while (datasetNameFC != null)
                {
                    pArrayFeatureClassName.Add(datasetNameFC.Name.ToString());
                    datasetNameFC = enumDatasetNameFC.Next();//推进器
                }
                datasetName = enumDatasetName.Next();
            }

            return(pArrayFeatureClassName);
        }
Example #3
0
        public IArray get_DatasetNames(esriDatasetType DatasetType)
        {
            if (m_connString == null)
            {
                return(null);
            }

            if (DatasetType == esriDatasetType.esriDTAny ||
                DatasetType == esriDatasetType.esriDTFeatureClass)
            {
                IArray datasets = new ArrayClass();

                int count = m_datasource.GetLayerCount();

                for (int i = 0; i < count; i++)
                {
                    OSGeo.OGR.Layer layer = m_datasource.GetLayerByIndex(i);

                    OGRDataset dataset = new OGRDataset(layer);

                    datasets.Add(dataset);
                }

                return(datasets);
            }

            return(null);
        }
Example #4
0
    public static void Init2DMatrix(out ArrayClass m, out int[][] refm)
    {
        int i, j, temp;
        i = 0;

        //m = new int[size, size];
        m = new ArrayClass(size);
        refm = new int[size][];

        for (int k = 0; k < refm.Length; k++)
            refm[k] = new int[size];

        while (i < size)
        {
            j = 0;
            while (j < size)
            {
                temp = rand.Next();
                m.a2d[i, j] = temp - (temp / 120) * 120 - 60;
                refm[i][j] = temp - (temp / 120) * 120 - 60;
                j++;
            }
            i++;
        }
    }
Example #5
0
        private void NewVerion_ItemClick(object sender, ItemClickEventArgs e)
        {
            ListViewItem item = this.VersionInfolist.SelectedItems[0];
            string       name = item.SubItems[1].Text + "." + item.SubItems[0].Text;

            try
            {
                IVersion unk = null;
                unk = this.iversionedWorkspace_0.FindVersion(name);
                IArray array = new ArrayClass();
                array.Add(unk);
                frmNewVersion version2 = new frmNewVersion
                {
                    ParentVersions = array
                };
                if (version2.ShowDialog() == DialogResult.OK)
                {
                    this.method_1();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Example #6
0
        /// <summary>
        /// 多个要素同时闪烁 add by xisheng 2011.07.01
        /// </summary>
        private void DefaultSelNde()
        {
            Application.DoEvents();
            IArray geoArray = new ArrayClass();

            for (int i = 0; i < this.advTree.Nodes.Count; i++)
            {
                if (!this.advTree.Nodes[i].HasChildNodes)
                {
                    continue;
                }
                for (int j = 0; j < this.advTree.Nodes[i].Nodes.Count; j++)
                {
                    IFeature pFeature = this.advTree.Nodes[i].Nodes[j].Tag as IFeature;
                    geoArray.Add(pFeature);
                }
            }
            if (geoArray == null)
            {
                return;
            }
            HookHelperClass hookHelper = new HookHelperClass();

            hookHelper.Hook = m_pMapControl.Object;
            IHookActions hookAction = (IHookActions)hookHelper;

            hookAction.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsFlash);
        }
Example #7
0
        /*
         * This method queries the device layer and returns a set of features
         */
        private IPropertySetArray QueryDevices(string whereClause, IStringArray outFields)
        {
            IPropertySetArray results = new PropertySetArray();

            int           deviceLayerId = soeUtil.GetLayerIdByName(mapService, DEVICE_LAYER_NAME);
            IFeatureClass deviceFC      = (IFeatureClass)mapServerDataAccess.GetDataSource(mapService.DefaultMapName, deviceLayerId);

            IQueryFilter filter = new QueryFilterClass();

            filter.WhereClause = whereClause;
            IFeatureCursor resultsFeatureCursor = deviceFC.Search(filter, false);

            IArray fieldIndex = new ArrayClass();

            for (int i = 0; i < outFields.Count; i++)
            {
                fieldIndex.Add(deviceFC.FindField(outFields.Element[i]));
            }
            IFeature resultFeature = null;

            while ((resultFeature = resultsFeatureCursor.NextFeature()) != null)
            {
                IPropertySet values = new PropertySet();
                for (int i = 0; i < outFields.Count; i++)
                {
                    values.SetProperty(outFields.Element[i], resultFeature.Value[(int)fieldIndex.Element[i]]);
                }
                results.Add(values);
            }
            Marshal.ReleaseComObject(resultsFeatureCursor);

            return(results);
        }
Example #8
0
        public IActionResult Arrays(string what, [FromBody] ArrayClass numbers)
        {
            int result = 0;

            if (numbers.array.Length == 0)
            {
                return(Json(new { error = "Please provide an array" }));
            }

            for (int i = 1; i < numbers.array.Length; i++)
            {
                if (what == "sum")
                {
                    result += numbers.array[i];
                }

                if (what == "multiply")
                {
                    result *= numbers.array[i];
                }

                if (what == "double")
                {
                    result = numbers.array[i * 2];
                }
            }

            return(Json(new { result = result }));
        }
        public IArray get_DatasetNames(esriDatasetType datasetType)
        {
            IArray datasets = new ArrayClass();

            if (datasetType == esriDatasetType.esriDTAny || datasetType != esriDatasetType.esriDTFeatureDataset)
            {
                // Since the state of the filesystem is beyond our control,
                // GetFiles() could throw.  If it does, we return an empty array.
                try
                {
                    foreach (var file in Directory.GetFiles(_workspacePath, GpxFilter))
                    {
                        string localName = Path.GetFileNameWithoutExtension(file);
                        if (!String.IsNullOrEmpty(localName))
                        {
                            datasets.Add(new GpxDataset(_workspacePath, localName));
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (ex is IOException || ex is UnauthorizedAccessException)
                        System.Diagnostics.Trace.TraceError(ex.Message);
                    else
                        throw;
                }
            }
            return datasets;
        }
Example #10
0
        private void Map_SearchByShape()
        {
            IMap       pMap             = axMapControl1.Map;
            ISelection pFeatureSelction = pMap.FeatureSelection;

            IEnumFeature      pEnumFeature      = pFeatureSelction as IEnumFeature;
            IEnumFeatureSetup pEnumFeatureSetup = pEnumFeature as IEnumFeatureSetup;

            pEnumFeatureSetup.AllFields = true;
            FeatureAttributeEventArgs FeatureAttributes = new FeatureAttributeEventArgs();
            IArray pFArray = new ArrayClass();

            pEnumFeature.Reset();
            IFeature pFeature = pEnumFeature.Next();

            while (pFeature != null)
            {
                pFArray.Add(pFeature);
                pFeature = pEnumFeature.Next();
            }
            FeatureAttributes.SelectFeatures = pFArray;
            if (SelectFeaturEvent != null)
            {
                SelectFeaturEvent(this, FeatureAttributes);
            }
        }
Example #11
0
 public void TestMethod2()
 {
     ArrayClass ac     = new ArrayClass();
     string     a      = "21";
     string     b      = "2";
     int        result = string.Compare(a, b);
 }
        public void TastArrayA()
        {
            int[] arrayA       = { 4, 5, 8, 3, 4 };
            int[] sortedArrayA = { 3, 4, 4, 5, 8 };

            Assert.IsTrue(sortedArrayA.SequenceEqual(ArrayClass.Sorted(arrayA)));
        }
Example #13
0
    // Use this for initialization
    void Start()
    {
        fillArray(75);

        for (int j = 0; j < levelY; j++)
        {
            for (int i = 0; i < levelX; i++)
            {
                if (i % 2 != 0 && j % 2 != 0)
                {
                    level[i, j] = new ArrayClass(ArrayTypes.SOLID, null);
                }
                else if (level[i, j] == null || i == 0 && j == 0 || i == 0 && j == 1 || i == 1 && j == 0 ||
                         i == levelX - 1 && j == 0 || i == levelX - 1 && j == 1 || i == levelX - 2 && j == 0 ||
                         i == 0 && j == levelY - 1 || i == 1 && j == levelY - 1 || i == 0 && j == levelY - 2 ||
                         i == levelX - 1 && j == levelY - 1 || i == levelX - 1 && j == levelY - 2 || i == levelX - 2 && j == levelY - 1)
                {
                    level[i, j] = new ArrayClass(ArrayTypes.EMPTY, null);
                }
                else if (level[i, j].Type == ArrayTypes.BLOCK)
                {
                    level[i, j].Obj = createObject(i, j, block, 0);
                }
            }
        }
    }
Example #14
0
        /// <summary>Creates new network attribute parameters</summary>
        private static void AddNetworkParameters(NetworkAttributeInfo nai, IEvaluatedNetworkAttribute netAttr)
        {
            // Create parameters
            if ((nai.Parameters != null) && (nai.Parameters.Count > 0))
            {
                IArray naParams = new ArrayClass();

                foreach (ParameterInfo paramInfo in nai.Parameters)
                {
                    INetworkAttributeParameter nap = new NetworkAttributeParameterClass();
                    nap.Name = paramInfo.Name;

                    if (paramInfo.DefaultValue is double)
                    {
                        nap.VarType = (int)VarEnum.VT_R8;
                    }
                    else if (paramInfo.DefaultValue is bool)
                    {
                        nap.VarType = (int)VarEnum.VT_BOOL;
                    }
                    else if (paramInfo.DefaultValue is string)
                    {
                        nap.VarType = (int)VarEnum.VT_BSTR;
                    }

                    nap.DefaultValue = paramInfo.DefaultValue;

                    naParams.Add(nap);
                }

                ((INetworkAttribute3)netAttr).Parameters = naParams;
            }
        }
Example #15
0
        private void method_2(IGroupLayer igroupLayer_1, ILayer ilayer_0, int int_0)
        {
            ICompositeLayer layer = igroupLayer_1 as ICompositeLayer;

            if ((layer.Count - 1) == int_0)
            {
                igroupLayer_1.Delete(ilayer_0);
                igroupLayer_1.Add(ilayer_0);
            }
            else
            {
                int    num;
                IArray array = new ArrayClass();
                for (num = 0; num < layer.Count; num++)
                {
                    array.Add(layer.get_Layer(num));
                }
                igroupLayer_1.Clear();
                for (num = 0; num < array.Count; num++)
                {
                    if (layer.Count == int_0)
                    {
                        igroupLayer_1.Add(ilayer_0);
                    }
                    ILayer layer2 = array.get_Element(num) as ILayer;
                    if (layer2 != ilayer_0)
                    {
                        igroupLayer_1.Add(layer2);
                    }
                }
            }
        }
        public bool GetAllFabricSubLayers(out IArray CFSubLayers)
        {
            ICadastralFabricSubLayer pCFSubLyr     = null;
            IArray        CFParcelFabricSubLayers2 = new ArrayClass();
            IFeatureLayer pParcelFabricSubLayer    = null;
            UID           pId = new UIDClass();

            pId.Value = "{BA381F2B-F621-4F45-8F78-101F65B5BBE6}"; //ICadastralFabricSubLayer

            IEnumLayer pEnumLayer = ArcMap.Editor.Map.get_Layers(pId, true);

            pEnumLayer.Reset();
            ILayer pLayer = pEnumLayer.Next();

            while (pLayer != null)
            {
                pCFSubLyr             = (ICadastralFabricSubLayer)pLayer;
                pParcelFabricSubLayer = (IFeatureLayer)pCFSubLyr;
                IDataset pDS = (IDataset)pParcelFabricSubLayer.FeatureClass;
                if (pDS.Workspace.Equals(ArcMap.Editor.EditWorkspace))
                {
                    CFParcelFabricSubLayers2.Add(pParcelFabricSubLayer);
                }
                pLayer = pEnumLayer.Next();
            }
            CFSubLayers = CFParcelFabricSubLayers2;
            if (CFParcelFabricSubLayers2.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #17
0
        public void BufferOfFeatures(AxMapControl axMap, IFeatureLayer pFeatureLayer, double bRadiusInKm)
        {
            if (pFeatureLayer == null)
            {
                return;
            }
            IPoint pTransform = GeoBaseLib.PRJtoGCS(bRadiusInKm * 1000.0, 0);
            //double bRadiusInDegree = pTransform.X;
            double bRadiusInDegree = bRadiusInKm;

            GeoBaseLib       gb = new GeoBaseLib(axMap);
            IArray           pFaultFeatureArray = gb.Search(pFeatureLayer, null);
            IArray           pGeometries        = new ArrayClass();
            esriGeometryType geoType            = GeoBaseLib.GeometryType(pFeatureLayer);

            for (int i = 0; i < pFaultFeatureArray.Count; i++)
            {
                IFeature pFaultFeature = pFaultFeatureArray.get_Element(i) as IFeature;
                if (pFaultFeature.Shape.IsEmpty || pFaultFeature.Extent.Height == 0.0 || pFaultFeature.Extent.Width == 0.0)
                {
                    pFaultFeatureArray.Remove(i);
                    i--;
                    continue;
                }
                IGeometry pBufferGeometry = Buffer(pFaultFeature.Shape, bRadiusInDegree);
                pGeometries.Add(pBufferGeometry);
            }
            gb.CreateShapefile(pFeatureLayer.Name + ("_") + bRadiusInKm.ToString(), pFaultFeatureArray, pGeometries, esriGeometryType.esriGeometryPolygon);
        }
Example #18
0
        /// <summary>
        /// 闪烁选中图斑
        /// </summary>
        /// <param name="featureCursor"></param>
        private void FlashPolygons(IFeatureCursor featureCursor)
        {
            IArray   geoArray = new ArrayClass();
            IFeature feature  = null;

            while ((feature = featureCursor.NextFeature()) != null)
            {
                //feature是循环外指针,所以必须用ShapeCopy
                geoArray.Add(feature.ShapeCopy);
            }

            //通过IHookActions闪烁要素集合
            HookHelperClass m_pHookHelper = new HookHelperClass();

            m_pHookHelper.Hook = m_MapControl.Object;
            IHookActions hookActions = (IHookActions)m_pHookHelper;

            hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsPan);

            System.Windows.Forms.Application.DoEvents();
            m_pHookHelper.ActiveView.ScreenDisplay.UpdateWindow();

            hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsFlash);
            System.Windows.Forms.Application.DoEvents();
            m_pHookHelper.ActiveView.ScreenDisplay.UpdateWindow();
        }
Example #19
0
        public IArray get_DatasetNames(esriDatasetType DatasetType)
        {
            if (m_sWkspPath == null)
            {
                return(null);
            }

            //HIGHLIGHT: get_DatasetNames - Go through wksString to look for csp files
            if (DatasetType != esriDatasetType.esriDTAny &&
                DatasetType != esriDatasetType.esriDTTable)
            {
                return(null);
            }

            string[] sFiles = System.IO.Directory.GetFiles(m_sWkspPath, "*.csp");
            if (sFiles == null || sFiles.Length == 0)
            {
                return(null);
            }

            IArray datasets = new ArrayClass();

            foreach (string sFileName in sFiles)
            {
                SimplePointDataset ds = new SimplePointDataset(m_sWkspPath, System.IO.Path.GetFileNameWithoutExtension(sFileName));
                datasets.Add(ds);
            }

            return(datasets);
        }
Example #20
0
        /// <summary>
        /// 替换原地图容器中的元素为模板的元素
        /// </summary>
        /// <param name="tempGraph">模板</param>
        /// <param name="oldMapFrame">原地图容器</param>
        /// <returns></returns>
        private static IArray ReplaceOldIntoTempElement(IGraphicsContainer tempGraph, IMapFrame oldMapFrame)
        {
            tempGraph.Reset();
            IElement tempElement = tempGraph.Next();
            IArray   pArray      = new ArrayClass();

            while (tempElement != null)
            {
                if (tempElement is IMapFrame)
                {
                    //改变布局边框几何形状
                    IElement pMapFrameElement = oldMapFrame as IElement;
                    if (pMapFrameElement != null)
                    {
                        pMapFrameElement.Geometry = tempElement.Geometry;
                    }
                }
                else
                {
                    IMapSurroundFrame pTempMapSurroundFrame = tempElement as IMapSurroundFrame;
                    if (pTempMapSurroundFrame != null)
                    {
                        //设置地图框架
                        pTempMapSurroundFrame.MapFrame = oldMapFrame;
                    }

                    //获取图例指北针等元素
                    pArray.Add(tempElement);
                }

                tempElement = tempGraph.Next();
            }

            return(pArray);
        }
        private static void RunGPFieldMapping()
        {
            // Initialize the Geoprocessor
            ESRI.ArcGIS.Geoprocessor.Geoprocessor GP = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            GP.OverwriteOutput = true;

            // Create the GPUtilites object
            IGPUtilities gputilities = new GPUtilitiesClass();

            // Create a DETable data element object 
            IDETable inputTableA = (IDETable)gputilities.MakeDataElement(@"C:\data\citiblocks.gdb\census", null, null);

            // Create an array of input tables
            IArray inputtables = new ArrayClass();
            inputtables.Add(inputTableA);

            // Initialize the GPFieldMapping
            IGPFieldMapping fieldmapping = new GPFieldMappingClass();
            fieldmapping.Initialize(inputtables, null);

            // Create a new output field
            IFieldEdit trackidfield = new FieldClass();
            trackidfield.Name_2 = "TRACTID";
            trackidfield.Type_2 = esriFieldType.esriFieldTypeString;
            trackidfield.Length_2 = 50;

            // Create a new FieldMap
            IGPFieldMap trackid = new GPFieldMapClass();
            trackid.OutputField = trackidfield;

            // Find field map "STFID" containing the input field "STFID". Add input field to the new field map.
            int fieldmap_index = fieldmapping.FindFieldMap("STFID");
            IGPFieldMap stfid_fieldmap = fieldmapping.GetFieldMap(fieldmap_index);
            int field_index = stfid_fieldmap.FindInputField(inputTableA, "STFID");
            IField inputField = stfid_fieldmap.GetField(field_index);
            trackid.AddInputField(inputTableA, inputField, 5, 10);

            // Add the new field map to the field mapping
            fieldmapping.AddFieldMap(trackid);

            // Execute Table to Table tool using the FieldMapping
            TableToTable tblTotbl = new TableToTable();
            tblTotbl.in_rows = inputTableA;
            tblTotbl.out_path = @"C:\data\citiblocks.gdb";
            tblTotbl.out_name = "census_out";
            tblTotbl.field_mapping = fieldmapping;

            object sev = null;
            try
            {
                GP.Execute(tblTotbl, null);
                System.Windows.Forms.MessageBox.Show(GP.GetMessages(ref sev));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                System.Windows.Forms.MessageBox.Show(GP.GetMessages(ref sev));
            }
        }
        public void fromXmlString13Test()
        {
            ArrayClass arr_ = (ArrayClass)SerializeXmlObject.fromXmlStringObject("<StreamTests.StreamTests.ArrayClass><array field=\"sampleArray\" class=\"StreamTests.StreamTests.ArrayClass\" type=\"mscorlib.System.Int32\"><mscorlib.System.Int32 value=\"5\" /><mscorlib.System.Int32 value=\"3\" /></array></StreamTests.StreamTests.ArrayClass>");

            Assert.AreEqual(2, arr_.getSampleArray().Length);
            Assert.AreEqual(5, arr_.getSampleArray().ElementAt(0));
            Assert.AreEqual(3, arr_.getSampleArray().ElementAt(1));
        }
Example #23
0
        private void bbiFlashFeature_ItemClick(object sender, ItemClickEventArgs e)
        {
            int[]    selectedRows = (this.gcFeatures.MainView as ColumnView).GetSelectedRows();
            IFeature feature      = this._features[selectedRows[0]];
            IArray   pArray       = new ArrayClass();

            pArray.Add(feature.ShapeCopy);
            ((IHookActions)this._hook).DoActionOnMultiple(pArray, esriHookActions.esriHookActionsFlash);
        }
        public static IArray Parameters(IEnumerable <AoGPParameter> ps)
        {
            IArray r = new ArrayClass();

            foreach (AoGPParameter p in ps)
            {
                r.Add(p.GPParameter);
            }
            return(r);
        }
        public void toXmlString13Test()
        {
            ArrayClass arr_ = new ArrayClass();

            int[] i_ = new int[2];
            i_[0] = 5;
            i_[1] = 3;
            arr_.setSampleArray(i_);
            Assert.AreEqual("<StreamTests.StreamTests.ArrayClass><array field=\"sampleArray\" class=\"StreamTests.StreamTests.ArrayClass\" type=\"mscorlib.System.Int32\"><mscorlib.System.Int32 value=\"5\"/><mscorlib.System.Int32 value=\"3\"/></array></StreamTests.StreamTests.ArrayClass>", SerializeXmlObject.toXmlString(arr_));
        }
        public IArray GetSelectLegendItem()
        {
            IArray array = new ArrayClass();

            for (int i = 0; i < this.listLegendLayers.Items.Count; i++)
            {
                array.Add(this.listLegendLayers.Items[i]);
            }
            return(array);
        }
        public static IArray RemoveAttributesByKeyName(IArray netAttributes, string keyName, bool keyIsPrefix)
        {
            IArray preservedNetAttributes = new ArrayClass();

            int keyNameLen = keyName.Length;
            int netAttributeNameLen;
            INetworkAttribute netAttribute;
            string            netAttributeName;
            bool isKeyAttribute;
            bool ignoreCase = true;

            int count = netAttributes.Count;

            for (int i = 0; i < count; ++i)
            {
                netAttribute = netAttributes.get_Element(i) as INetworkAttribute;
                if (netAttribute == null)
                {
                    continue;
                }

                netAttributeName    = netAttribute.Name;
                netAttributeNameLen = netAttributeName.Length;

                isKeyAttribute = false;
                if (keyNameLen == 0)
                {
                    isKeyAttribute = false;
                }
                else if (netAttributeNameLen < keyNameLen)
                {
                    isKeyAttribute = false;
                }
                else
                {
                    int startIndex = 0;
                    if (!keyIsPrefix)
                    {
                        startIndex = netAttributeNameLen - keyNameLen;
                    }

                    if (String.Compare(netAttributeName.Substring(startIndex, keyNameLen), keyName, ignoreCase) == 0)
                    {
                        isKeyAttribute = true;
                    }
                }

                if (!isKeyAttribute)
                {
                    preservedNetAttributes.Add(netAttribute);
                }
            }

            return(preservedNetAttributes);
        }
        protected override void OnClick()
        {
            //Enable publisher extension
            if (EnablePublisherExtension())
            {
                System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;

                IMxDocument mapDoc = ArcMap.Document;

                IPMFPublish3 publishMaps = new PublisherEngineClass();

                //Accept the default settings when the map is published.
                IPropertySet settings = publishMaps.GetDefaultPublisherSettings();              

                IArray orderedMaps = new ArrayClass();
                //Loop over all the maps in the map document and each one to an Array object
                for (int i = 0; i <= mapDoc.Maps.Count - 1; i++)
                {
                    orderedMaps.Add(mapDoc.Maps.get_Item(i));
                }

                try
                {
                    //Create the PMF file using the current settings and the map order specified in the IArray parameter
                    //It will be written to C:\\PublishedMap.pmf and the data will be referenced using relative paths.
                    publishMaps.PublishWithOrder(orderedMaps, mapDoc.PageLayout, mapDoc.ActiveView, settings,
                                                 true, "C:\\PublishedMap.pmf");


                    //Report outcome to the user
                    string mapdocTitle = ((IDocument)ArcMap.Document).Title;
                    string msg = string.Empty;

                    if (orderedMaps.Count == 1)
                    {
                        msg = "The map in " + mapdocTitle + " has been published successfully";
                    }
                    else
                    {
                        msg = "The maps in " + mapdocTitle + " have been published successfully";
                    }

                    MessageBox.Show(msg);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Publishing Map: " + ex.Message, "Error");
                }

                System.Windows.Forms.Cursor.Current = Cursors.Default;

            }

            ArcMap.Application.CurrentTool = null;
        }
Example #29
0
 public static void InnerProduct2D(out int res, ref ArrayClass a2d, ref ArrayClass b, int row, int col)
 {
     int i;
     res = 0;
     i = 0;
     while (i < size)
     {
         res = res + a2d.a2d[row, i] * b.a2d[i, col];
         i++;
     }
 }
        protected override void OnClick()
        {
            //Enable publisher extension
            if (EnablePublisherExtension())
            {
                System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;

                IMxDocument mapDoc = ArcMap.Document;

                IPMFPublish3 publishMaps = new PublisherEngineClass();

                //Accept the default settings when the map is published.
                IPropertySet settings = publishMaps.GetDefaultPublisherSettings();

                IArray orderedMaps = new ArrayClass();
                //Loop over all the maps in the map document and each one to an Array object
                for (int i = 0; i <= mapDoc.Maps.Count - 1; i++)
                {
                    orderedMaps.Add(mapDoc.Maps.get_Item(i));
                }

                try
                {
                    //Create the PMF file using the current settings and the map order specified in the IArray parameter
                    //It will be written to C:\\PublishedMap.pmf and the data will be referenced using relative paths.
                    publishMaps.PublishWithOrder(orderedMaps, mapDoc.PageLayout, mapDoc.ActiveView, settings,
                                                 true, "C:\\PublishedMap.pmf");


                    //Report outcome to the user
                    string mapdocTitle = ((IDocument)ArcMap.Document).Title;
                    string msg         = string.Empty;

                    if (orderedMaps.Count == 1)
                    {
                        msg = "The map in " + mapdocTitle + " has been published successfully";
                    }
                    else
                    {
                        msg = "The maps in " + mapdocTitle + " have been published successfully";
                    }

                    MessageBox.Show(msg);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Publishing Map: " + ex.Message, "Error");
                }

                System.Windows.Forms.Cursor.Current = Cursors.Default;
            }

            ArcMap.Application.CurrentTool = null;
        }
Example #31
0
        public void ArrayTest()
        {
            ArrayClass arrayClass = faker.Create <ArrayClass>();

            Assert.AreNotEqual(null, arrayClass.intSingleRateArray);
            Assert.AreNotEqual(null, arrayClass.objectSingleRateArray);
            Assert.AreEqual(0, arrayClass.objectSingleRateArray.Length);
            Assert.AreNotEqual(null, arrayClass.intJaggedArray);
            Assert.AreEqual(0, arrayClass.intJaggedArray.Length);
            Assert.AreEqual(null, arrayClass.intDoubleRateArray);
        }
        public void AddIntElementInObjectArray()
        {
            var data = new int[] { 1, 2, 3, 0, 0, 0, 0, 0 };
            var newElement = 1;

            var array = new ArrayClass<int>(data, 3);
            array.Add(newElement);
            var count = array.GetCount();

            Assert.AreEqual(4, count);
        }
        public void AddIntElementInObjectArrayWithLength17()
        {
            var data = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
            var newElement = 17;

            var array = new ArrayClass<int>(data, 16);
            array.Add(newElement);
            var count = array.GetCount();

            Assert.AreEqual(17, count);
        }
Example #34
0
    public static void InnerProduct3D(out int res, ArrayClass a3d, ArrayClass b, int row, int col)
    {
        int i;

        res = 0;
        i   = 0;
        while (i < size)
        {
            res = res + a3d.a3d[row, i, 0] * b.a3d[i, col, 0];
            i++;
        }
    }
Example #35
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);
        }
        public void AddEightIntElementInObjectArray()
        {
            var array = new ArrayClass<int>();

            for (var i = 1; i <= 11; i++)
            {
                array.Add(i);
            }
            var count = array.GetCount();

            Assert.AreEqual(11, count);
        }
Example #37
0
    public static void InnerProduct2D(out int res, ref ArrayClass a2d, ref ArrayClass b, int row, int col)
    {
        int i;

        res = 0;
        i   = 0;
        while (i < size)
        {
            res = res + a2d.a2d[row, i] * b.a2d[i, col];
            i++;
        }
    }
Example #38
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add SearchAndZoomIn.OnMouseDown implementation
            //空间查询
            try
            {
                MyMapControl.Map.ClearSelection();
                MyMapControl.Refresh();
                IArray geoArray = new ArrayClass();

                if (MyselectedLayer == null)
                {
                    return;
                }
                IFeatureLayer featureLayer = MyselectedLayer as IFeatureLayer;
                if (featureLayer == null)
                {
                    return;
                }
                IFeatureClass featureClass = featureLayer.FeatureClass;
                if (featureClass == null)
                {
                    return;
                }

                IEnvelope      envelope      = MyMapControl.TrackRectangle();
                IGeometry      geometry      = envelope as IGeometry;
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                spatialFilter.Geometry = geometry;//指定几何体
                switch (featureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;
                    break;
                }
                spatialFilter.GeometryField = featureClass.ShapeFieldName;

                IQueryFilter filter = spatialFilter as IQueryFilter;//筛选器

                IFeatureCursor cursor = featureClass.Search(filter, false);
                // 缩放到选择结果集,并高亮显示
                ZoomToSelectedFeature((IFeatureLayer)MyselectedLayer, filter);
            }
            catch { }
        }
Example #39
0
    public static void Init3DMatrix(ArrayClass m, int[][] refm)
    {
        int i, j, temp;
        i = 0;

        while (i < size)
        {
            j = 0;
            while (j < size)
            {
                temp = rand.Next();
                m.a3d[i, j, 0] = temp - (temp / 120) * 120 - 60;
                refm[i][j] = temp - (temp / 120) * 120 - 60;
                j++;
            }
            i++;
        }
    }
		public IArray get_DatasetNames(esriDatasetType DatasetType)
		{
			if (m_sWkspPath == null)
				return null;

			//HIGHLIGHT: get_DatasetNames - Go through wksString to look for csp files
			if (DatasetType != esriDatasetType.esriDTAny && 
				DatasetType != esriDatasetType.esriDTTable)
				return null;

			string[] sFiles = System.IO.Directory.GetFiles(m_sWkspPath, "*.csp");
			if (sFiles == null || sFiles.Length == 0)
				return null;

			IArray datasets = new ArrayClass();
			foreach (string sFileName in sFiles)
			{
				SimplePointDataset ds = new SimplePointDataset(m_sWkspPath, System.IO.Path.GetFileNameWithoutExtension(sFileName));
				datasets.Add(ds);
			}

			return datasets;
		}
        public bool GetFabricSubLayersFromFabric(IMap Map, ICadastralFabric Fabric, out IFeatureLayer CFPointLayer, out IFeatureLayer CFLineLayer,
          out IArray CFParcelLayers, out IFeatureLayer CFControlLayer, out IFeatureLayer CFLinePointLayer)
        {
            ICadastralFabricLayer pCFLayer = null;
              ICadastralFabricSubLayer pCFSubLyr = null;
              ICompositeLayer pCompLyr = null;
              IArray CFParcelLayers2 = new ArrayClass();

              IDataset pDS = (IDataset)Fabric;
              IName pDSName = pDS.FullName;
              string FabricNameString = pDSName.NameString;

              long layerCount = Map.LayerCount;
              CFPointLayer = null; CFLineLayer = null; CFControlLayer = null; CFLinePointLayer = null;
              IFeatureLayer pParcelLayer = null;
              for (int idx = 0; idx <= (layerCount - 1); idx++)
              {
            ILayer pLayer = Map.get_Layer(idx);
            bool bIsComposite = false;
            if (pLayer is ICompositeLayer)
            {
              pCompLyr = (ICompositeLayer)pLayer;
              bIsComposite = true;
            }

            int iCompositeLyrCnt = 1;
            if (bIsComposite)
              iCompositeLyrCnt = pCompLyr.Count;

            for (int i = 0; i <= (iCompositeLyrCnt - 1); i++)
            {
              if (bIsComposite)
            pLayer = pCompLyr.get_Layer(i);
              if (pLayer is ICadastralFabricLayer)
              {
            pCFLayer = (ICadastralFabricLayer)pLayer;
            break;
              }
              if (pLayer is ICadastralFabricSubLayer)
              {
            pCFSubLyr = (ICadastralFabricSubLayer)pLayer;
            IDataset pDS2 = (IDataset)pCFSubLyr.CadastralFabric;
            IName pDSName2 = pDS2.FullName;
            if (pDSName.NameString.ToLower() == pDSName2.NameString.ToLower() &&
            pCFSubLyr.CadastralTableType == esriCadastralFabricTable.esriCFTParcels)
            {
              pParcelLayer = (IFeatureLayer)pCFSubLyr;
              CFParcelLayers2.Add(pParcelLayer);
            }
            if (CFLineLayer == null && pDSName.NameString.ToLower() == pDSName2.NameString.ToLower() &&
            pCFSubLyr.CadastralTableType == esriCadastralFabricTable.esriCFTLines)
              CFLineLayer = (IFeatureLayer)pCFSubLyr;
            if (CFPointLayer == null && pDSName.NameString.ToLower() == pDSName2.NameString.ToLower() &&
            pCFSubLyr.CadastralTableType == esriCadastralFabricTable.esriCFTPoints)
              CFPointLayer = (IFeatureLayer)pCFSubLyr;
            if (CFLinePointLayer == null && pDSName.NameString.ToLower() == pDSName2.NameString.ToLower() &&
            pCFSubLyr.CadastralTableType == esriCadastralFabricTable.esriCFTLinePoints)
              CFLinePointLayer = (IFeatureLayer)pCFSubLyr;
            if (CFControlLayer == null && pDSName.NameString.ToLower() == pDSName2.NameString.ToLower() &&
            pCFSubLyr.CadastralTableType == esriCadastralFabricTable.esriCFTControl)
              CFControlLayer = (IFeatureLayer)pCFSubLyr;
              }
            }

            //Check that the fabric layer belongs to the requested fabric
            if (pCFLayer != null)
            {
              if (pCFLayer.CadastralFabric.Equals(Fabric))
              {
            CFPointLayer = (IFeatureLayer)pCFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRPoints);
            CFLineLayer = (IFeatureLayer)pCFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRLines);
            pParcelLayer = (IFeatureLayer)pCFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRParcels);
            CFParcelLayers2.Add(pParcelLayer);
            Debug.WriteLine(pParcelLayer.Name);
            CFControlLayer = (IFeatureLayer)pCFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRControlPoints);
            CFLinePointLayer = (IFeatureLayer)pCFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRLinePoints);
              }

              if (CFLinePointLayer != null)
            CFParcelLayers2.Add(CFLinePointLayer);

              if (CFControlLayer != null)
            CFParcelLayers2.Add(CFControlLayer);

              if (CFLineLayer != null)
            CFParcelLayers2.Add(CFLineLayer);

              if (CFPointLayer != null)
            CFParcelLayers2.Add(CFPointLayer);

              CFParcelLayers = CFParcelLayers2;
              return true;
            }
              }
              //at the minimum, just need to make sure we have a parcel sublayer for the requested fabric
              if (pParcelLayer != null)
              {
            if (CFLinePointLayer != null)
              CFParcelLayers2.Add(CFLinePointLayer);

            if (CFControlLayer != null)
              CFParcelLayers2.Add(CFControlLayer);

            if (CFLineLayer != null)
              CFParcelLayers2.Add(CFLineLayer);

            if (CFPointLayer != null)
              CFParcelLayers2.Add(CFPointLayer);

            CFParcelLayers = CFParcelLayers2;
            return true;
              }
              else
              {
            CFParcelLayers = null;
            return false;
              }
        }
        protected override void OnClick()
        {
            bool bShowProgressor = false;
              IStepProgressor pStepProgressor = null;
              //Create a CancelTracker.
              ITrackCancel pTrackCancel = null;
              IProgressDialogFactory pProgressorDialogFact;

              IMouseCursor pMouseCursor = new MouseCursorClass();
              pMouseCursor.SetCursor(2);

              //first get the selected parcel features
              UID pUID = new UIDClass();
              pUID.Value = "{114D685F-99B7-4B63-B09F-6D1A41A4DDC1}";
              ICadastralExtensionManager2 pCadExtMan = (ICadastralExtensionManager2)ArcMap.Application.FindExtensionByCLSID(pUID);
              ICadastralEditor pCadEd = (ICadastralEditor)ArcMap.Application.FindExtensionByCLSID(pUID);

              //check if there is a Manual Mode "modify" job active ===========
              ICadastralPacketManager pCadPacMan = (ICadastralPacketManager)pCadExtMan;
              if (pCadPacMan.PacketOpen)
              {
            MessageBox.Show("The Delete linepoint command cannot be used when there is an open job.\r\nPlease finish or discard the open job, and try again.",
              "Delete Selected LinePoints");
            return;
              }

              IEditor pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");

              IActiveView pActiveView = ArcMap.Document.ActiveView;
              IMap pMap = pActiveView.FocusMap;
              ICadastralFabric pCadFabric = null;
              clsFabricUtils FabricUTILS = new clsFabricUtils();
              IProgressDialog2 pProgressorDialog = null;

              //if we're in an edit session then grab the target fabric
              if (pEd.EditState == esriEditState.esriStateEditing)
            pCadFabric = pCadEd.CadastralFabric;

              if (pCadFabric == null)
              {//find the first fabric in the map
            if (!FabricUTILS.GetFabricFromMap(pMap, out pCadFabric))
            {
              MessageBox.Show
            ("No Parcel Fabric found in the map.\r\nPlease add a single fabric to the map, and try again.");
              return;
            }
              }

              IArray CFLinePointLayers = new ArrayClass();

              if (!(FabricUTILS.GetLinePointLayersFromFabric(pMap, pCadFabric, out CFLinePointLayers)))
            return; //no fabric sublayers available for the targeted fabric

              bool bIsFileBasedGDB = false; bool bIsUnVersioned = false; bool bUseNonVersionedDelete = false;
              IWorkspace pWS = null;
              ITable pLinePointTable = null;

              try
              {
            if (pEd.EditState == esriEditState.esriStateEditing)
            {
              try
              {
            pEd.StartOperation();
              }
              catch
              {
            pEd.AbortOperation();//abort any open edit operations and try again
            pEd.StartOperation();
              }
            }

            IFeatureLayer pFL = (IFeatureLayer)CFLinePointLayers.get_Element(0);
            IDataset pDS = (IDataset)pFL.FeatureClass;
            pWS = pDS.Workspace;

            if (!FabricUTILS.SetupEditEnvironment(pWS, pCadFabric, pEd, out bIsFileBasedGDB,
              out bIsUnVersioned, out bUseNonVersionedDelete))
              return;

            //loop through each linepoint layer and
            //Get the selection of linepoints
            int iCnt = 0;
            int iTotalSelectionCount = 0;
            for (; iCnt < CFLinePointLayers.Count; iCnt++)
            {
              pFL = (IFeatureLayer)CFLinePointLayers.get_Element(iCnt);
              IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
              ISelectionSet2 pSelSet = (ISelectionSet2)pFeatSel.SelectionSet;
              iTotalSelectionCount += pSelSet.Count;
            }

            if (iTotalSelectionCount == 0)
            {
              MessageBox.Show("Please select some line points and try again.", "No Selection",
            MessageBoxButtons.OK, MessageBoxIcon.Information);
              if (bUseNonVersionedDelete)
              {
            pCadEd.CadastralFabricLayer = null;
            CFLinePointLayers = null;
              }
              return;
            }

            bShowProgressor = (iTotalSelectionCount > 10);

            if (bShowProgressor)
            {
              pProgressorDialogFact = new ProgressDialogFactoryClass();
              pTrackCancel = new CancelTrackerClass();
              pStepProgressor = pProgressorDialogFact.Create(pTrackCancel, ArcMap.Application.hWnd);
              pProgressorDialog = (IProgressDialog2)pStepProgressor;
              pStepProgressor.MinRange = 1;
              pStepProgressor.MaxRange = iTotalSelectionCount;
              pStepProgressor.StepValue = 1;
              pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
            }

            //loop through each linepoint layer and
            //delete from its selection
            m_pQF = new QueryFilterClass();
            iCnt = 0;
            for (; iCnt < CFLinePointLayers.Count; iCnt++)
            {
              pFL = (IFeatureLayer)CFLinePointLayers.get_Element(iCnt);
              IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
              ISelectionSet2 pSelSet = (ISelectionSet2)pFeatSel.SelectionSet;

              ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
              string sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
              string sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);

              if (bShowProgressor)
              {
            pProgressorDialog.ShowDialog();
            pStepProgressor.Message = "Collecting line point data...";
              }

              //Add the OIDs of all the selected linepoints into a new feature IDSet
              bool bCont = true;
              m_pFIDSetLinePoints = new FIDSetClass();

              ICursor pCursor = null;
              pSelSet.Search(null, false, out pCursor);//code deletes all selected line points
              IFeatureCursor pLinePointFeatCurs = (IFeatureCursor)pCursor;
              IFeature pLinePointFeat = pLinePointFeatCurs.NextFeature();

              while (pLinePointFeat != null)
              {
            //Check if the cancel button was pressed. If so, stop process
            if (bShowProgressor)
            {
              bCont = pTrackCancel.Continue();
              if (!bCont)
                break;
            }
            bool bExists = false;
            m_pFIDSetLinePoints.Find(pLinePointFeat.OID, out bExists);
            if (!bExists)
              m_pFIDSetLinePoints.Add(pLinePointFeat.OID);

            Marshal.ReleaseComObject(pLinePointFeat); //garbage collection
            pLinePointFeat = pLinePointFeatCurs.NextFeature();

            if (bShowProgressor)
            {
              if (pStepProgressor.Position < pStepProgressor.MaxRange)
                pStepProgressor.Step();
            }
              }
              Marshal.ReleaseComObject(pCursor); //garbage collection

              if (!bCont)
              {
            AbortEdits(bUseNonVersionedDelete, pEd, pWS);
            return;
              }

              if (bUseNonVersionedDelete)
              {
            if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
            {
              if (bUseNonVersionedDelete)
                pCadEd.CadastralFabricLayer = null;
              return;
            }
              }

              //delete all the line point records
              if (bShowProgressor)
            pStepProgressor.Message = "Deleting selected line points...";

              bool bSuccess = true;
              pLinePointTable = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTLinePoints);

              if (!bUseNonVersionedDelete)
            bSuccess = FabricUTILS.DeleteRowsByFIDSet(pLinePointTable, m_pFIDSetLinePoints, pStepProgressor, pTrackCancel);
              if (bUseNonVersionedDelete)
            bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pLinePointTable,
                m_pFIDSetLinePoints, pStepProgressor, pTrackCancel);
              if (!bSuccess)
              {
            AbortEdits(bUseNonVersionedDelete, pEd, pWS);
            return;
              }
            }

            if (bUseNonVersionedDelete)
              FabricUTILS.StopEditing(pWS);

            if (pEd.EditState == esriEditState.esriStateEditing)
              pEd.StopOperation("Delete Line Points");
              }

              catch (Exception ex)
              {
            MessageBox.Show(ex.Message);
            return;
              }
              finally
              {
            RefreshMap(pActiveView, CFLinePointLayers);

            //update the TOC
            IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(ArcMap.Application.Document);
            for (int i = 0; i < mxDocument.ContentsViewCount; i++)
            {
              IContentsView pCV = (IContentsView)mxDocument.get_ContentsView(i);
              pCV.Refresh(null);
            }

            if (pProgressorDialog != null)
              pProgressorDialog.HideDialog();

            if (bUseNonVersionedDelete)
            {
              pCadEd.CadastralFabricLayer = null;
              CFLinePointLayers = null;
            }

            if (pMouseCursor != null)
              pMouseCursor.SetCursor(0);
              }
        }
 public bool GetAllFabricSubLayers(out IArray CFSubLayers)
 {
     ICadastralFabricSubLayer pCFSubLyr = null;
     IArray CFParcelFabricSubLayers2 = new ArrayClass();
     IFeatureLayer pParcelFabricSubLayer = null;
     UID pId = new UIDClass();
     pId.Value = "{BA381F2B-F621-4F45-8F78-101F65B5BBE6}"; //ICadastralFabricSubLayer
     IMap pMap = AAState._editor.Map;
     IEnumLayer pEnumLayer = pMap.get_Layers(pId, true);
     pEnumLayer.Reset();
     ILayer pLayer = pEnumLayer.Next();
     while (pLayer != null)
     {
         pCFSubLyr = (ICadastralFabricSubLayer)pLayer;
         pParcelFabricSubLayer = (IFeatureLayer)pCFSubLyr;
         IDataset pDS = (IDataset)pParcelFabricSubLayer.FeatureClass;
         if (pDS.Workspace.Equals(AAState._editor.EditWorkspace))
             CFParcelFabricSubLayers2.Add(pParcelFabricSubLayer);
         pLayer = pEnumLayer.Next();
     }
     CFSubLayers = CFParcelFabricSubLayers2;
     if (CFParcelFabricSubLayers2.Count > 0)
         return true;
     else
         return false;
 }
        ////////////////////////////////////////////////////////////////////////
        // METHOD: PopulateAOIListUsingParent
        private bool PopulateAOIListUsingParent(IJTXJob2 pParentJob, ref IArray aoiList, int numCopies)
        {
            try
            {
                aoiList = new ArrayClass();
                for (int i = 0; i < numCopies; i++)
                {
                    aoiList.Add(pParentJob.AOIExtent);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to create AOIs based on parent job's AOI: " + ex.Message);
            }

            return true;
        }
    /// <summary>
    /// Identifying all the weather items falling within the given envelope
    /// </summary>
    /// <param name="pGeom"></param>
    /// <returns></returns>
    public IArray Identify(IGeometry pGeom)
    {
      IEnvelope intersectEnv = new EnvelopeClass();
      IEnvelope inEnv;
      IArray array = new ArrayClass();

      //get the envelope from the geometry 
      if(pGeom.GeometryType == esriGeometryType.esriGeometryEnvelope)
        inEnv = pGeom.Envelope;
      else
        inEnv = pGeom as IEnvelope;

      //reproject the envelope to the source coordsys
      //this would allow to search directly on the Lat/Lon columns
			if (null != m_spatialRef && m_mapSpatialRef.FactoryCode != m_layerSRFactoryCode && null != inEnv.SpatialReference)
        inEnv.Project(base.m_spatialRef);

      //expand the envelope so that it'll cover the symbol
      inEnv.Expand(4,4,true);

      double xmin, ymin, xmax, ymax;
      inEnv.QueryCoords(out xmin, out ymin, out xmax, out ymax);  
      
      //select all the records within the given extent
      string qry = "LON >= " + xmin.ToString() + " AND LON <= " + xmax.ToString() + " AND Lat >= " + ymin.ToString() + " AND LAT <= " + ymax.ToString();
      DataRow[] rows = m_table.Select(qry);
      if(0 == rows.Length)
        return array;
      
      long zipCode;
      IPropertySet			propSet		= null;
      IIdentifyObj			idObj			= null;
      IIdentifyObject		idObject	= null;
      bool	            bIdentify	= false;

      foreach(DataRow r in rows)
      {
        //get the zipCode
        zipCode = Convert.ToInt64(r["ZIPCODE"]); 
 
        //get the properties of the given item in order to pass it to the identify object
        propSet = this.GetWeatherItem(zipCode);
        if(null != propSet)
        {
          //instantiate the identify object and add it to the array
          idObj = new RSSWeatherIdentifyObject();
          //test whether the layer can be identified
          bIdentify = idObj.CanIdentify((ILayer)this);
          if(bIdentify)
          {
            idObject = idObj as IIdentifyObject;
            idObject.PropertySet = propSet;
            array.Add(idObj);
          }
        }
      }

      //return the array with the identify objects
      return array;
    }
        /// <summary>Creates new network attribute parameters</summary>
        private static void AddNetworkParameters(NetworkAttributeInfo nai, IEvaluatedNetworkAttribute netAttr)
        {
            // Create parameters
            if ((nai.Parameters != null) && (nai.Parameters.Count > 0))
            {
                IArray naParams = new ArrayClass();

                foreach (ParameterInfo paramInfo in nai.Parameters)
                {
                    INetworkAttributeParameter nap = new NetworkAttributeParameterClass();
                    nap.Name = paramInfo.Name;

                    if (paramInfo.DefaultValue is double)
                        nap.VarType = (int)VarEnum.VT_R8;
                    else if (paramInfo.DefaultValue is bool)
                        nap.VarType = (int)VarEnum.VT_BOOL;
                    else if (paramInfo.DefaultValue is string)
                        nap.VarType = (int)VarEnum.VT_BSTR;

                    nap.DefaultValue = paramInfo.DefaultValue;

                    naParams.Add(nap);
                }

                ((INetworkAttribute3)netAttr).Parameters = naParams;
            }
        }
        /// <summary>Creates a temporary network dataset to use during turn feature creation</summary>
        private INetworkDataset CreateTempNDS()
        {
            const string TEMP_NDS_NAME = "TEMP_TURN_NDS";

            IDENetworkDataset2 deNDS = new DENetworkDatasetClass();
            deNDS.Buildable = true;

            ((IDataElement)deNDS).Name = TEMP_NDS_NAME;

            // Copy the feature dataset's extent and spatial reference to the network dataset
            IDEGeoDataset deGeoDataset = (IDEGeoDataset)deNDS;
            deGeoDataset.Extent = _extent;
            deGeoDataset.SpatialReference = _spatialReference;

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

            IArray sources = new ArrayClass();
            foreach (INetworkSource ns in EnumerateNetworkSources())
                sources.Add(ns);

            deNDS.Sources = sources;

            // Get the feature dataset extension and create the network dataset from the data element.
            IFeatureDatasetExtension fdExtension = ((IFeatureDatasetExtensionContainer)_osmDataset).FindExtension(esriDatasetType.esriDTNetworkDataset);
            INetworkDataset nds = (INetworkDataset)((IDatasetContainer2)fdExtension).CreateDataset((IDEDataset)deNDS);
            if (nds == null)
                throw new ArgumentNullException("NetworkDataset");

            return nds;
        }
        /// <summary>Adds edge feature classes to the network dataset</summary>
        /// <remarks>
        /// - For each 'edge' element in the config file, adds a new EdgeFeatureSource to the NDS
        /// - A new feature class is extracted from *_OSM_LN using a filter specified in the config file
        /// </remarks>
        private void ExtractEdgeFeatureClasses()
        {
            IList<SourceFeatureClassInfo> edges = _xml.EdgeFeatureClasses().ToList();
            if ((edges == null) || (edges.Count == 0))
                return;

            ConvertRequiredTagsToAttributes(true);

            // Create the new feature class using the query filter from the config XML
            foreach (SourceFeatureClassInfo edge in edges)
            {
                string edgeClassName = GetFullClassName(edge.Name);
                SelectFeaturesToNewFeatureClass(_osmLinePath, _dsPath + "\\" + edgeClassName, edge.Query);

                INetworkSource edgeNetworkSource = new EdgeFeatureSourceClass();
                edgeNetworkSource.Name = edgeClassName;
                edgeNetworkSource.ElementType = esriNetworkElementType.esriNETEdge;

                IEdgeFeatureSource edgeFeatureSource = (IEdgeFeatureSource)edgeNetworkSource;
                edgeFeatureSource.UsesSubtypes = false;
                edgeFeatureSource.ClassConnectivityPolicy = (esriNetworkEdgeConnectivityPolicy)edge.ConnectPolicy;

                if (edge.StreetNameFields != null)
                {
                    // Create a StreetNameFields object and populate its settings for the Streets source.
                    IStreetNameFields streetNameFields = new StreetNameFieldsClass();
                    streetNameFields.Priority = 1;
                    streetNameFields.StreetNameFieldName = edge.StreetNameFields.StreetName;
                    streetNameFields.PrefixDirectionFieldName = edge.StreetNameFields.DirectionPrefix;
                    streetNameFields.SuffixDirectionFieldName = edge.StreetNameFields.DirectionSuffix;
                    streetNameFields.PrefixTypeFieldName = edge.StreetNameFields.TypePrefix;
                    streetNameFields.SuffixTypeFieldName = edge.StreetNameFields.TypeSuffix;

                    INetworkSourceDirections sourceDirections = new NetworkSourceDirectionsClass();
                    IArray streetNameFieldsArray = new ArrayClass();
                    streetNameFieldsArray.Add(streetNameFields);
                    sourceDirections.StreetNameFields = streetNameFieldsArray;
                    ((INetworkSource)edgeFeatureSource).NetworkSourceDirections = sourceDirections;
                }

                _edgeSources.Add(edgeFeatureSource);
            }
        }
Example #49
0
 private static void TestMultiDimensionalArray()
 {
     using (var target = new MemoryStream())
     {
         var item = new ArrayClass { Array = new int[5, 5, 5] };
         item.Array[2, 2, 2] = 5;
         SerializerService.Serialize(item, target);
         target.Position = 0;
         var result = SerializerService.Deserialize<ArrayClass>(target);
         Console.WriteLine("{0}", result.Array[2, 2, 2] == item.Array[2, 2, 2]);
     }
 }
Example #50
0
		public void ArrayTest1 () {
			ArrayClass c = new ArrayClass ("arraytest1");
			ScriptObject so = (ScriptObject) HtmlPage.Window.Eval (@"new function () { this.test1 = function (arg) {
				return arg[0].Prop;
			}}");

			object ret = so.Invoke ("test1", new object[] {new List<ArrayClass>(){c} });
			Assert.AreEqual (ret, c.Prop, "ArrayTest1 #1");
		}
        public bool GetFabricSubLayersByClass(esriCadastralFabricTable FabricSubClass, out IArray CFParcelFabSubLayers)
        {
            ICadastralFabricSubLayer pCFSubLyr = null;
            IArray CFParcelFabricSubLayers2 = new ArrayClass();
            IFeatureLayer pParcelFabricSubLayer = null;
            UID pId = new UIDClass();
            //pId.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";//IGeoFeatureLayer
            pId.Value = "{BA381F2B-F621-4F45-8F78-101F65B5BBE6}"; //ICadastralFabricSubLayer

            IMap pMap = AAState._editor.Map;
            IEnumLayer pEnumLayer = pMap.get_Layers(pId, true);
            pEnumLayer.Reset();
            ILayer pLayer = pEnumLayer.Next();
            while (pLayer != null)
            {
                pCFSubLyr = (ICadastralFabricSubLayer)pLayer;
                if (pCFSubLyr.CadastralTableType == FabricSubClass)
                {
                    pParcelFabricSubLayer = (IFeatureLayer)pCFSubLyr;
                    IDataset pDS = (IDataset)pParcelFabricSubLayer.FeatureClass;
                    if (pDS.Workspace.Equals(AAState._editor.EditWorkspace))
                        CFParcelFabricSubLayers2.Add(pParcelFabricSubLayer);
                }
                pLayer = pEnumLayer.Next();
            }
            CFParcelFabSubLayers = CFParcelFabricSubLayers2;
            if (CFParcelFabricSubLayers2.Count > 0)
                return true;
            else
                return false;
        }
 void AddEmptyPlansToList(ICadastralFabric Fabric, IFIDSet EmptyPlansFIDSet, dlgEmptyPlansList EmptyPlansList)
 {
     ITable pPlansTable = Fabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPlans);
       CheckedListBox list = EmptyPlansList.checkedListBox1;
       IArray array = new ArrayClass();
       for (int idx = 0; idx <= (EmptyPlansFIDSet.Count() - 1); idx++)
       {
     // Add the name of the plan to the list
     Int32 i_x;
     Int32 iPlanName;
     iPlanName = pPlansTable.FindField("NAME");
     EmptyPlansFIDSet.Next(out i_x);
     array.Add(i_x);
     string sPlanName = (string)pPlansTable.GetRow(i_x).get_Value(iPlanName);
     list.Items.Add(sPlanName, true);
       }
       // Bind array of plan ids with the list
       list.Tag = (object)array;
       if(list.Items.Count>0)
     EmptyPlansList.checkedListBox1_SelectedValueChanged(null, null);
 }
        public void AddOneIntElementInObjectArray()
        {
            var newElement = 1;

            var array = new ArrayClass<int>();
            array.Add(newElement);
            var count = array.GetCount();

            Assert.AreEqual(1, count);
        }
        /// <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);
        }
        ////////////////////////////////////////////////////////////////////////
        // METHOD: PopulateAOIListUsingOverlapFeatureClass
        private bool PopulateAOIListUsingOverlapFeatureClass(IJTXJob2 pParentJob, ref IArray aoiList)
        {
            try
            {
                // Make sure all the information exists to get the data workspace
                if (pParentJob.ActiveDatabase == null)
                {
                    MessageBox.Show("Unable to proceed: Please set the data workspace for this job.");
                    return false;
                }
                if (pParentJob.AOIExtent == null)
                {
                    MessageBox.Show("Unable to proceed: Please assign the AOI for this job.");
                    return false;
                }

                // Get the feature workspace from the current data workspace
                IJTXDatabase2 pJTXDB = (IJTXDatabase2)m_ipDatabase;
                string activeDBID = pParentJob.ActiveDatabase.DatabaseID;
                IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)pJTXDB.GetDataWorkspace(activeDBID, pParentJob.VersionExists() ? pParentJob.VersionName : "");
                if (featureWorkspace == null)
                {
                    MessageBox.Show("Unable to connect to Data Workspace");
                    return false;
                }

                IFeatureClass featureClass = null;
                try
                {
                    featureClass = featureWorkspace.OpenFeatureClass(m_AOIOverlapFeatureClassName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to connect to feature class to generate AOIs: " +
                        m_AOIOverlapFeatureClassName + "\n Error: " + ex.ToString());
                    return false;
                }

                // Get all features that intersect the parent job's AOI
                //
                // Note: The parent job's AOI is shrunk very slightly so features that merely adjoin the parent's AOI 
                // are *not* returned.  Only features that have some part of their actual area intersecting the parent's 
                // AOI are returned.
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                ITopologicalOperator topOp = (ITopologicalOperator)pParentJob.AOIExtent;
                IPolygon slightlySmallerExtent = (IPolygon)topOp.Buffer(-0.0001);
                spatialFilter.Geometry = slightlySmallerExtent;
                spatialFilter.GeometryField = featureClass.ShapeFieldName;
                spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                IFeatureCursor featureCursor = featureClass.Search(spatialFilter, false);

                aoiList = new ArrayClass();
                IFeature feature = null;
                while ((feature = featureCursor.NextFeature()) != null)
                {
                    aoiList.Add(feature.Shape);
                }

                // Explicitly release the cursor.  
                Marshal.ReleaseComObject(featureCursor);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to create AOIs based on feature class: " + m_AOIOverlapFeatureClassName + ". " + ex.ToString());
            }

            return true;
        }
Example #56
0
        //�������ĸ߳�����
        public static void ProfileGetRelatedSewerElevData(AxMapControl ppAxMapControl, IGeometricNetwork pGeoNetwork, IEnumNetEID pResultEdges, IEnumNetEID pResultJunctions)
        {
            try
            {
                //��ñ������Զ�Ӧ������׷�ٽ��
                IArray pSewerElevArray = new ArrayClass();
                IEIDHelper pEIDHelper = new EIDHelperClass();
                pEIDHelper.GeometricNetwork = pGeoNetwork;
                pEIDHelper.ReturnFeatures = true;
                pEIDHelper.ReturnGeometries = true;
                pEIDHelper.PartialComplexEdgeGeometry = true;
                pEIDHelper.AddField("Component_Key2");
                IEnumEIDInfo pEnumEIDInfo = pEIDHelper.CreateEnumEIDInfo(pResultEdges);
                //�������߻�����ص������߼�¼
                pEnumEIDInfo.Reset();
                IEIDInfo pEIDInfo = pEnumEIDInfo.Next();
                IFeature pFeature = pEIDInfo.Feature;
                IGeometry pFeatGeo = pEIDInfo.Geometry;
                //�������л�ù�ϵ
                IEnumRelationshipClass pEnumRelationshipCls = pFeature.Class.get_RelationshipClasses(esriRelRole.esriRelRoleOrigin);
                pEnumRelationshipCls.Reset();
                IRelationshipClass pRelationshipCls = pEnumRelationshipCls.Next();
                //�����ȷ�Ĺ�ϵ��
                string s = "SewerToMainline";
                while (pRelationshipCls != null)
                {
                    if (pRelationshipCls.ForwardPathLabel.ToUpper() == s.ToUpper())
                        break;
                    else
                        pRelationshipCls = pEnumRelationshipCls.Next();
                }
                //��ѯ���ɹ�����ÿ������ص����ݣ������1-1�Ĺ�ϵ����ֻ����һ����¼
                //  because the arcs are ordered and directional, if the start node is an
                //  fnode then get subsequent tnode's for the rest of the arcs, else if the
                //  start node is a tnode, get subsequent fnode's.  Related data has elev
                //  attributes for up and down stream manhole elevs, so related to from and to node of arc.
                // get the first junction in the network trace results to determine if the
                //first junction is a from-node or a to-node for graphing sewer line elev
                if (pRelationshipCls != null)
                {
                    ISet pMainlineRelatedSet;
                    IRow pMainlineRow;
                    IEIDHelper pEIDHelper2 = new EIDHelperClass();
                    pEIDHelper2.GeometricNetwork = pGeoNetwork;
                    pEIDHelper2.ReturnFeatures = true;
                    pEIDHelper2.ReturnGeometries = true;
                    pEIDHelper2.PartialComplexEdgeGeometry = true;
                    IEnumEIDInfo pEnumEIDInfo2 = pEIDHelper2.CreateEnumEIDInfo(pResultJunctions);
                    pEnumEIDInfo2.Reset();
                    //pFeature is the first arc in the network trace results
                    // check the junctions on the first arc to see which is the starting
                    // junction, this determines which sewer elev attribute (ups_elev, dwn_elev)
                    // will be used to calculate the sewer line profile
                    IEdgeFeature pEdgeFeat = pFeature as IEdgeFeature;
                    string strStartAttr;
                    string strMHelevAttr;
                    double lastelev = 0;
                    int lastnodeEID;
                    if (pEnumEIDInfo2.Next().EID == pEdgeFeat.FromJunctionEID)
                    {
                        // trace is in the direction of flow, flow goes down hill
                        strStartAttr = "Ups_elev";
                        strMHelevAttr = "Dwn_elev";
                    }
                    else
                    {
                        //trace is in the opposite direction of flow, flow goes up hill
                        strStartAttr = "Dwn_elev";
                        strMHelevAttr = "Ups_elev";
                    }
                    lastnodeEID = pEnumEIDInfo2.Next().EID;
                    // create a polyline from the result junctions, make the polyline in the
                    //direction of the trace, not in the direction of the original arcs/edges
                    IPolyline pPolyline = new PolylineClass();
                    IPointCollection pPointColl = pPolyline as IPointCollection;
                    pEnumEIDInfo2.Reset();
                    object missing = Type.Missing;
                    for (int i = 0; i <= pEnumEIDInfo2.Count - 1; i++)
                    {
                        pPointColl.AddPoint(pEnumEIDInfo2.Next().Geometry as IPoint, ref missing, ref missing);
                    }
                    ISegmentCollection pSegColl = pPolyline as ISegmentCollection;
                    //�򻯶����
                    ITopologicalOperator pTopoOp = pPolyline as ITopologicalOperator;
                    pTopoOp.Simplify();
                    pPolyline.SimplifyNetwork();
                    pPolyline.Densify(50, 0.01);
                    pResultEdges.Reset();
                    pEnumEIDInfo2.Reset();
                    IPolyline pNewSegPolyline;
                    IPolyline pPolyLineFeat;
                    IRelationalOperator pRelOpFeat;
                    ISegmentCollection pNewSegColl;
                    ISegmentCollection pSegmentColl = pPolyline as ISegmentCollection;
                    for (int i = 0; i <= pResultEdges.Count - 1; i++)
                    {
                        pMainlineRelatedSet = pRelationshipCls.GetObjectsRelatedToObject(pFeature);
                        pMainlineRelatedSet.Reset();
                        pMainlineRow = pMainlineRelatedSet.Next() as IRow;
                        pPolyLineFeat = pFeature.Shape as IPolyline;
                        pRelOpFeat = pPolyLineFeat as IRelationalOperator;
                        for (int j = 0; j <= pSegmentColl.SegmentCount - 1; j++)
                        {
                            pNewSegPolyline = new PolylineClass();
                            pNewSegColl = pNewSegPolyline as ISegmentCollection;
                            pNewSegColl.AddSegment(pSegmentColl.get_Segment(j), ref missing, ref missing);
                            if (pRelOpFeat.Contains(pNewSegPolyline as IGeometry))
                            {
                                if (j == 0)
                                {
                                    pSewerElevArray.Add(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strStartAttr)));
                                    lastelev = Convert.ToDouble(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strMHelevAttr)));
                                }
                                else
                                {
                                    if (lastelev == Convert.ToDouble(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strMHelevAttr))))
                                    {
                                        pSewerElevArray.Add(-99);
                                    }
                                    else
                                    {
                                        pSewerElevArray.Add(lastelev);
                                        lastelev = Convert.ToDouble(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strMHelevAttr)));
                                    }
                                }
                            }
                        }
                        // get the next feature and check to see what direction it's going and
                        //adjust the variables accordingly
                        if (i < pResultEdges.Count - 1)
                        {
                            lastnodeEID = pEdgeFeat.ToJunctionEID;
                            pFeature = pEnumEIDInfo.Next().Feature;
                            pEdgeFeat = pFeature as IEdgeFeature;
                            if (pEdgeFeat.FromJunctionEID == lastnodeEID)
                                strMHelevAttr = "Dwn_elev";
                            else
                                strMHelevAttr = "Ups_elev";

                        }
                        else
                        {
                            pSewerElevArray.Add(pMainlineRow.get_Value(pMainlineRow.Fields.FindField(strMHelevAttr)));

                        }
                    }
                    ProfileCreateGraph(ppAxMapControl, pPolyline, pSewerElevArray);
                }
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
Example #57
0
        //��˷׷�ٲ��ҹ����漰�ĵؿ�
        public static void UpStreamFindParcels(AxMapControl ppAxMapControl, IEnumNetEID pEnumResultEdges, IGeometricNetwork pGeoNetwork)
        {
            try
            {

                IFeatureLayer pFeatLayerSewerLines = FindFeatLayer("Sewer Lines", ppAxMapControl);
                IFeatureLayer pFeatLayerParcels = FindFeatLayer("Parcels", ppAxMapControl);
                //����ѡ���Sewer�������д������ΰ�

                IGeometryCollection pGeomBag = new GeometryBagClass();
                object missing = Type.Missing;
                int lEID;
                int iUserClassID;
                int iUserID;
                int iUserSubID;
                INetElements pNetElements = pGeoNetwork.Network as INetElements;
                pEnumResultEdges.Reset();
                IFeature pFeature;

                for (int j = 0; j <= pEnumResultEdges.Count - 1; j++)
                {
                    lEID = pEnumResultEdges.Next();
                    pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID);
                    pFeature = pFeatLayerSewerLines.FeatureClass.GetFeature(iUserID);
                    pGeomBag.AddGeometry(pFeature.Shape, ref missing, ref missing);
                    // MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString());
                }
                //���пռ����˵��Ӳ��������ڲ��ҵؿ���Ϣ
                ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                pSpatialFilter.Geometry = pGeomBag as IGeometry;
                pSpatialFilter.GeometryField = "Shape";
                pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;

                //��ý��浽�ĵؿ���Ϣ
                IFeatureCursor pFeatCursor = pFeatLayerParcels.FeatureClass.Search(pSpatialFilter, false);
                //���ӱ�ѡ��ĵؿ����ݵ���ͼ��ͼ��ͼ��������
                ICompositeGraphicsLayer pComGraphicLayer = new CompositeGraphicsLayerClass();
                ILayer pLayer = pComGraphicLayer as ILayer;
                pLayer.Name = "��Ӱ��ĵؿ�";
                IGraphicsContainer pGraphicContainer = pComGraphicLayer as IGraphicsContainer;
                //������ѡ��ĵؿ鵽ͼ��������
                ISimpleFillSymbol pSymFill = new SimpleFillSymbolClass();
                IFillSymbol pFillSymbol = pSymFill as IFillSymbol;
                IRgbColor pRgbColor = new RgbColorClass();
                pRgbColor.Red = 0;
                pRgbColor.Green = 200;
                pRgbColor.Blue = 100;
                pFillSymbol.Color = pRgbColor as IColor;
                ICartographicLineSymbol pCartoLine = new CartographicLineSymbolClass();
                IRgbColor pRgbColor2 = new RgbColorClass();
                pRgbColor2.Red = 100;
                pRgbColor2.Green = 200;
                pRgbColor2.Blue = 100;
                pCartoLine.Width = 2;
                pCartoLine.Color = pRgbColor2 as IColor;
                pFillSymbol.Outline = pCartoLine;
                //����������еؿ�����������
                IArray pFeatArray = new ArrayClass();
                pFeature = pFeatCursor.NextFeature();
                while (pFeature != null)
                {
                    IElement pPolyElement = new PolygonElementClass();
                    IFillShapeElement pFillShapeElement = pPolyElement as IFillShapeElement;
                    pPolyElement.Geometry = pFeature.Shape;
                    pFillShapeElement.Symbol = pFillSymbol;
                    pGraphicContainer.AddElement(pPolyElement, 0);
                    pFeatArray.Add(pFeature);
                    pFeature = pFeatCursor.NextFeature();
                }
                ppAxMapControl.AddLayer(pGraphicContainer as ILayer);
                ppAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                //ma
                //frmUpstreamCreateOwnerList frmUpstreamCreateOwnerList1 = new frmUpstreamCreateOwnerList(ppAxMapControl,pFeatLayerParcels, pFeatArray);
                //frmUpstreamCreateOwnerList1.Show();
            }
            catch (Exception eX)
            {
                MessageBox.Show(eX.Message);

            }
        }
        protected override void OnClick()
        {
            bool bShowProgressor=false;
              IStepProgressor pStepProgressor = null;
              //Create a CancelTracker.
              ITrackCancel pTrackCancel = null;
              IProgressDialogFactory pProgressorDialogFact;

              IMouseCursor pMouseCursor = new MouseCursorClass();
              pMouseCursor.SetCursor(2);

              //first get the selected parcel features
              UID pUID = new UIDClass();
              pUID.Value = "{114D685F-99B7-4B63-B09F-6D1A41A4DDC1}";
              ICadastralExtensionManager2 pCadExtMan = (ICadastralExtensionManager2)ArcMap.Application.FindExtensionByCLSID(pUID);
              ICadastralEditor pCadEd = (ICadastralEditor)ArcMap.Application.FindExtensionByCLSID(pUID);

              //check if there is a Manual Mode "modify" job active ===========
              ICadastralPacketManager pCadPacMan = (ICadastralPacketManager)pCadExtMan;
              if (pCadPacMan.PacketOpen)
              {
            MessageBox.Show("The Delete Control command cannot be used when there is an open job.\r\nPlease finish or discard the open job, and try again.",
              "Delete Selected Control");
            return;
              }

              IEditor pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");

              IActiveView pActiveView = ArcMap.Document.ActiveView;
              IMap pMap = pActiveView.FocusMap;
              ICadastralFabric pCadFabric = null;
              clsFabricUtils FabricUTILS = new clsFabricUtils();
              IProgressDialog2 pProgressorDialog = null;

              //if we're in an edit session then grab the target fabric
              if (pEd.EditState == esriEditState.esriStateEditing)
            pCadFabric = pCadEd.CadastralFabric;

              if (pCadFabric == null)
              {//find the first fabric in the map
            if (!FabricUTILS.GetFabricFromMap(pMap, out pCadFabric))
            {
              MessageBox.Show
            ("No Parcel Fabric found in the map.\r\nPlease add a single fabric to the map, and try again.");
              return;
            }
              }

              IArray CFControlLayers = new ArrayClass();

              if (!(FabricUTILS.GetControlLayersFromFabric(pMap, pCadFabric, out CFControlLayers)))
            return; //no fabric sublayers available for the targeted fabric

              bool bIsFileBasedGDB = false; bool bIsUnVersioned = false; bool bUseNonVersionedDelete = false;
              IWorkspace pWS = null;
              ITable pPointsTable = null;
              ITable pControlTable = null;

              try
              {
            if (pEd.EditState == esriEditState.esriStateEditing)
            {
              try
              {
            pEd.StartOperation();
              }
              catch
              {
            pEd.AbortOperation();//abort any open edit operations and try again
            pEd.StartOperation();
              }
            }

            IFeatureLayer pFL = (IFeatureLayer)CFControlLayers.get_Element(0);
            IDataset pDS = (IDataset)pFL.FeatureClass;
            pWS = pDS.Workspace;

            if (!FabricUTILS.SetupEditEnvironment(pWS, pCadFabric, pEd, out bIsFileBasedGDB,
              out bIsUnVersioned, out bUseNonVersionedDelete))
              return;

            //loop through each control layer and
            //Get the selection of control
             int iCnt=0;
             int iTotalSelectionCount = 0;
             for (; iCnt < CFControlLayers.Count; iCnt++)
             {
               pFL = (IFeatureLayer)CFControlLayers.get_Element(iCnt);
               IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
               ISelectionSet2 pSelSet = (ISelectionSet2)pFeatSel.SelectionSet;
               iTotalSelectionCount += pSelSet.Count;
             }

             if (iTotalSelectionCount == 0)
             {
               MessageBox.Show("Please select some fabric control points and try again.", "No Selection",
             MessageBoxButtons.OK, MessageBoxIcon.Information);
               if (bUseNonVersionedDelete)
               {
             pCadEd.CadastralFabricLayer = null;
             CFControlLayers = null;
               }
               return;
             }

             bShowProgressor = (iTotalSelectionCount > 10);

             if (bShowProgressor)
             {
               pProgressorDialogFact = new ProgressDialogFactoryClass();
               pTrackCancel = new CancelTrackerClass();
               pStepProgressor = pProgressorDialogFact.Create(pTrackCancel, ArcMap.Application.hWnd);
               pProgressorDialog = (IProgressDialog2)pStepProgressor;
               pStepProgressor.MinRange = 1;
               pStepProgressor.MaxRange = iTotalSelectionCount * 2; //(runs through selection twice)
               pStepProgressor.StepValue = 1;
               pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
             }

            //loop through each control layer and
            //delete from its selection
            m_pQF = new QueryFilterClass();
            iCnt=0;
            for (; iCnt < CFControlLayers.Count; iCnt++)
            {
              pFL = (IFeatureLayer)CFControlLayers.get_Element(iCnt);
              IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
              ISelectionSet2 pSelSet = (ISelectionSet2)pFeatSel.SelectionSet;

              ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
              string sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
              string sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);

              if (bShowProgressor)
              {
            pProgressorDialog.ShowDialog();
            pStepProgressor.Message = "Collecting Control point data...";
              }

              //Add the OIDs of all the selected control points into a new feature IDSet
              string[] sOIDListPoints = { "(" };
              int tokenLimit = 995;
              //int tokenLimit = 5; //temp for testing
              bool bCont = true;
              int j = 0;
              int iCounter = 0;

              m_pFIDSetControl = new FIDSetClass();

              ICursor pCursor = null;
              pSelSet.Search(null, false, out pCursor);//code deletes all selected control points
              IFeatureCursor pControlFeatCurs = (IFeatureCursor)pCursor;
              IFeature pControlFeat = pControlFeatCurs.NextFeature();
              int iPointID = pControlFeatCurs.FindField("POINTID");

              while (pControlFeat != null)
              {
            //Check if the cancel button was pressed. If so, stop process
            if (bShowProgressor)
            {
              bCont = pTrackCancel.Continue();
              if (!bCont)
                break;
            }
            bool bExists = false;
            m_pFIDSetControl.Find(pControlFeat.OID, out bExists);
            if (!bExists)
            {
              m_pFIDSetControl.Add(pControlFeat.OID);
              object obj = pControlFeat.get_Value(iPointID);

              if (iCounter <= tokenLimit)
              {
                //if the PointID is not null add it to a query string as well
                if (obj != DBNull.Value)
                  sOIDListPoints[j] += Convert.ToString(obj) + ",";
                iCounter++;
              }
              else
              {//maximum tokens reached
                //set up the next OIDList
                sOIDListPoints[j] = sOIDListPoints[j].Trim();
                iCounter = 0;
                j++;
                FabricUTILS.RedimPreserveString(ref sOIDListPoints, 1);
                sOIDListPoints[j] = "(";
                if (obj != DBNull.Value)
                  sOIDListPoints[j] += Convert.ToString(obj) + ",";
              }
            }
            Marshal.ReleaseComObject(pControlFeat); //garbage collection
            pControlFeat = pControlFeatCurs.NextFeature();

            if (bShowProgressor)
            {
              if (pStepProgressor.Position < pStepProgressor.MaxRange)
                pStepProgressor.Step();
            }
              }
              Marshal.ReleaseComObject(pCursor); //garbage collection

              if (!bCont)
              {
            AbortEdits(bUseNonVersionedDelete, pEd, pWS);
            return;
              }

              if (bUseNonVersionedDelete)
              {
            if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
            {
              if (bUseNonVersionedDelete)
                pCadEd.CadastralFabricLayer = null;
              return;
            }
              }

              //first delete all the control point records
              if (bShowProgressor)
            pStepProgressor.Message = "Deleting control points...";

              bool bSuccess = true;
              pPointsTable = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPoints);
              pControlTable = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTControl);

              if (!bUseNonVersionedDelete)
            bSuccess = FabricUTILS.DeleteRowsByFIDSet(pControlTable, m_pFIDSetControl, pStepProgressor, pTrackCancel);
              if (bUseNonVersionedDelete)
            bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pControlTable,
                m_pFIDSetControl, pStepProgressor, pTrackCancel);
              if (!bSuccess)
              {
            AbortEdits(bUseNonVersionedDelete, pEd, pWS);
            return;
              }
              //next need to use an in clause to update the points, ...
              ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)pCadFabric;
              //...for each item in the sOIDListPoints array
              foreach (string inClause in sOIDListPoints)
              {
            string sClause = inClause.Trim().TrimEnd(',');
            if (sClause.EndsWith("("))
              continue;
            if (sClause.Length < 3)
              continue;
            pSchemaEd.ReleaseReadOnlyFields(pPointsTable, esriCadastralFabricTable.esriCFTPoints);
            m_pQF.WhereClause = (sPref + pPointsTable.OIDFieldName + sSuff).Trim() + " IN " + sClause + ")";

            if (!FabricUTILS.ResetPointAssociations(pPointsTable, m_pQF, bIsUnVersioned))
            {
              pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints);
              return;
            }
            pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints);
              }
            }

            if (bUseNonVersionedDelete)
              FabricUTILS.StopEditing(pWS);

            if (pEd.EditState == esriEditState.esriStateEditing)
              pEd.StopOperation("Delete Control Points");
              }

              catch (Exception ex)
              {
            MessageBox.Show(ex.Message);
            return;
              }
              finally
              {
            RefreshMap(pActiveView, CFControlLayers);

            //update the TOC
            IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(ArcMap.Application.Document);
            for (int i = 0; i < mxDocument.ContentsViewCount; i++)
            {
              IContentsView pCV = (IContentsView)mxDocument.get_ContentsView(i);
              pCV.Refresh(null);
            }

            if (pProgressorDialog != null)
              pProgressorDialog.HideDialog();

            if (bUseNonVersionedDelete)
            {
              pCadEd.CadastralFabricLayer = null;
              CFControlLayers = null;
            }

            if (pMouseCursor != null)
              pMouseCursor.SetCursor(0);
              }
        }
		private void PlayAnimationFast(int cycles, int iteration)
		{
			IGlobe globe = axGlobeControl1.Globe;
			IGlobeDisplay globeDisplay = globe.GlobeDisplay;
			Scene scene = (Scene) globeDisplay.Scene;
			IAnimationTracks sceneTracks = (IAnimationTracks) scene;

			IArray trackCamArray = new ArrayClass();
			IArray trackGlbArray = new ArrayClass();
			IArray trackLyrArray = new ArrayClass();

			string sError;
			if (sceneTracks.TrackCount == 0)
			{
				sError = m_AnimFilePath;
				if (sError == "")
				{
					sError = "To get a Sample animation file, Developer Kit Samples need to be installed!";
					System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A  + sError);
				}
				else
				{
					System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A  + "Load " + m_AnimFilePath + @"\AnimationSample.aga for sample.");
				}
				return;
			}
			
			IAnimationTrack track;
			IAnimationTrack trackLayer;
			IAnimationTrack trackGlobe = null;
			IAnimationType animType;
			IAnimationType animLayer;
			IAnimationType animGlobeCam = null;
			IKeyframe kFGlbCam;
			IKeyframe kFGlbLayer;
			int k;
			int[] count = new int[1000];

			//get each track from the scene and store tracks of the same kind in an Array
			for (int i=0; i<=sceneTracks.TrackCount-1;i++)
			{
				track = (IAnimationTrack) sceneTracks.Tracks.get_Element(i);
				k = i;
				animType = track.AnimationType;

				if (animType.CLSID.Value.ToString() == "{7CCBA704-3933-4D7A-8E89-4DFEE88AA937}")
				{
					//GlobeLayer
					trackLayer = new AnimationTrackClass();
					trackLayer = track;
					trackLayer.AnimationType = animType;
					kFGlbLayer = new GlobeLayerKeyframeClass();
					animLayer = animType;
					//Store the keyframe count of each track in an array
					count[i] = trackLayer.KeyframeCount;
					trackLyrArray.Add(trackLayer);
				}
				else if (animType.CLSID.Value.ToString() == "{D4565495-E2F9-4D89-A8A7-D0B69FD7A424}")
				{
					//Globe Camera type
					trackGlobe = new AnimationTrackClass();
					trackGlobe = track;
					trackGlobe.AnimationType = animType;
					kFGlbCam = new GlobeCameraKeyframeClass();
					animGlobeCam = animType;
					//Store the keyframe count of each track in an array
					count[i] = trackGlobe.KeyframeCount;
					trackGlbArray.Add(trackGlobe);
				}
				else
				{
					System.Windows.Forms.MessageBox.Show("Animation Type " + animType.Name + " Not Supported. Check if the animation File is Valid!");
					return;
				}
			}

			int larger = Greatest(ref count);
			//if nothing gets passed by the argument it takes the max no of keyframes
			if (iteration == 0) iteration = larger;

			IAnimationTrack trackCamera;
			IAnimationType animCam = null;
			IKeyframe kFBkmark;
			double time = 0;
			int keyFrameLayerCount; int keyFrameCameraCount; int keyFrameCount;

			for (int i=1; i<=cycles; i++) //no of cycles...
			{
				for (int start=0; start<=iteration; start++) //no of iterations...
				{
					for (int j=0; j<=trackCamArray.Count-1; j++)
					{
						trackCamera = (IAnimationTrack) trackCamArray.get_Element(j);
						if (trackCamera != null)
						{
							if (time >= trackCamera.BeginTime)
							{
								keyFrameCameraCount = trackGlobe.KeyframeCount;
								kFBkmark = trackCamera.get_Keyframe(keyFrameCameraCount - keyFrameCameraCount);
								//reset object
								animCam.ResetObject(scene, kFBkmark);
								//interpolate by using track
								trackCamera.InterpolateObjectProperties(scene, time);
								keyFrameCameraCount = keyFrameCameraCount - 1;
							}
						}
					}

					for (k=0; k<=trackGlbArray.Count-1;k++)
					{
						trackGlobe = (IAnimationTrack) trackGlbArray.get_Element(k);
						if (trackGlobe != null)
						{
							if (time >= trackGlobe.BeginTime)
							{
								keyFrameCount = trackGlobe.KeyframeCount;
								kFGlbCam = trackGlobe.get_Keyframe(trackGlobe.KeyframeCount - keyFrameCount);
								//reset object
								animGlobeCam.ResetObject(scene, kFGlbCam);
								//interpolate by using track
								trackGlobe.InterpolateObjectProperties(scene, time);
								keyFrameCount = keyFrameCount - 1;
							}
						}
					}

					for (int t=0; t<=trackLyrArray.Count-1; t++)
					{
						trackLayer = (IAnimationTrack) trackLyrArray.get_Element(t);
						if (trackLayer != null)
						{
							if (time >= trackLayer.BeginTime)
							{
								keyFrameLayerCount = trackLayer.KeyframeCount;
								kFGlbLayer = trackLayer.get_Keyframe(trackLayer.KeyframeCount - keyFrameLayerCount);
								//interpolate by using track
								trackLayer.InterpolateObjectProperties(scene, time);
								keyFrameLayerCount = keyFrameLayerCount - 1;
							}
						}
					}

					//reset interpolation Point
					time = start / iteration;
					//refresh the globeviewer(s)
					globeDisplay.RefreshViewers();
				}
			}
		}
 /// <summary>
 /// Generates candidates for an address.
 /// </summary>
 /// <param name="address"></param>
 /// <returns>Address candidates</returns>
 public virtual IArray FindAddressCandidates(IPropertySet address)
 {
     _log.Debug("IAddressCandidates FindAddressCandidates");
       IArray addressCandidates = new ArrayClass();
       return addressCandidates;
 }