示例#1
0
        private ESRI.ArcGIS.Carto.IMap PrivateCreateMxd(string sPathToMXDToSave)
        {
            try
            {
                _pMapDocument = new MapDocumentClass();

                //Copy the MXD
                System.IO.File.Copy(_sMxdTemplate, sPathToMXDToSave, true);

                _sNewDocument = sPathToMXDToSave;

                if (_pMapDocument.get_IsMapDocument(_sNewDocument))
                {
                    _pMapDocument.Open(_sNewDocument, null);
                    IMap pMap;
                    pMap = _pMapDocument.get_Map(0);
                    return(pMap);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        private ESRI.ArcGIS.Carto.IMap PrivateCreateMxd(string sPathToMXDToSave)
        {

            try
            {

                _pMapDocument = new MapDocumentClass();

                //Copy the MXD
                System.IO.File.Copy(_sMxdTemplate, sPathToMXDToSave, true);

                _sNewDocument = sPathToMXDToSave;

                if (_pMapDocument.get_IsMapDocument(_sNewDocument))
                {
                    _pMapDocument.Open(_sNewDocument, null);
                    IMap pMap;
                    pMap = _pMapDocument.get_Map(0);
                    return pMap;
                }

                return null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public MXD(string mxdPath)
        {
            path = mxdPath;
            // GUIDs finden: http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=31115
            LayerTypeUIDs[0] = "{EDAD6644-1810-11D1-86AE-0000F8751720}";
            LayerTypeUIDs[1] = "{5CEAE408-4C0A-437F-9DB3-054D83919850}";
            LayerTypeUIDs[2] = "{DBCA59AC-6771-4408-8F48-C7D53389440C}";
            LayerTypeUIDs[3] = "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}";
            LayerTypeUIDs[4] = "{605BC37A-15E9-40A0-90FB-DE4CC376838C}";
            LayerTypeUIDs[5] = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";
            LayerTypeUIDs[6] = "";

            if (InitializeLicense() == esriLicenseStatus.esriLicenseCheckedOut)
            {
                mapDoc = new MapDocumentClass();
                if (mapDoc.get_IsPresent(path))
                {
                    if (mapDoc.get_IsMapDocument(path))
                    {
                        mapDoc.Open(path, null);
                        if (mapDoc.DocumentType == esriMapDocumentType.esriMapDocumentTypeMxd)
                        {
                            activateMapDocument();

                            // alle Layer holen
                            layerList = getLayerList(null);

                            // alle GroupLayer holen
                            processLayer(LayerTypes.GroupLayer);

                            // alle AnnotationLayer holen
                            processLayer(LayerTypes.AnnotationLayer);

                            // alle AnnotationSubLayer holen
                            processLayer(LayerTypes.AnnotationSubLayer);

                            // alle RasterLayer holen
                            processLayer(LayerTypes.RasterLayer);

                            // alle RasterCatalogLayer holen
                            processLayer(LayerTypes.RasterCatalogLayer);

                            // alle FeatureLayer holen
                            processLayer(LayerTypes.FeatureLayer);

                            // übrige Layer holen
                            foreach (ILayer lyr in layerList)
                            {
                                if (!processedLayers.Contains(lyr))
                                {
                                    LayerInfo lyrInfo = new LayerInfo(mapDoc);
                                    lyrInfo.processOtherLayer(lyr);
                                    lyrInfos.Add(lyrInfo);
                                    processedLayers.Add(lyr);
                                }
                            }

                            // Resultate ausgeben
                            foreach (LayerInfo info in lyrInfos)
                            {
                                Console.WriteLine(info.writeCSV());
                            }

                            // Dokument schliessen
                            mapDoc.Close();

                        } else {
                            Console.Error.WriteLine("FEHLER: kein gültiges MXD-File");
                        }
                    } else {
                        Console.Error.WriteLine("FEHLER: kein gültiges MXD-File");
                    }
                } else {
                    Console.Error.WriteLine("FEHLER: Angegebenes File nicht gefunden");
                }

            } else
            {
                Console.Error.WriteLine("FEHLER: Keine ArcView-Lizenz verfügbar");
            }

            // Lizenz zurückgeben
            TerminateLicense();
        }
示例#4
0
        public MXD(string mxdPath)
        {
            path = mxdPath;
            // GUIDs finden: http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=31115
            LayerTypeUIDs[0] = "{EDAD6644-1810-11D1-86AE-0000F8751720}";
            LayerTypeUIDs[1] = "{5CEAE408-4C0A-437F-9DB3-054D83919850}";
            LayerTypeUIDs[2] = "{DBCA59AC-6771-4408-8F48-C7D53389440C}";
            LayerTypeUIDs[3] = "{D02371C7-35F7-11D2-B1F2-00C04F8EDEFF}";
            LayerTypeUIDs[4] = "{605BC37A-15E9-40A0-90FB-DE4CC376838C}";
            LayerTypeUIDs[5] = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";
            LayerTypeUIDs[6] = "";

            if (InitializeLicense() == esriLicenseStatus.esriLicenseCheckedOut)
            {
                mapDoc = new MapDocumentClass();
                if (mapDoc.get_IsPresent(path))
                {
                    if (mapDoc.get_IsMapDocument(path))
                    {
                        mapDoc.Open(path, null);
                        if (mapDoc.DocumentType == esriMapDocumentType.esriMapDocumentTypeMxd)
                        {
                            activateMapDocument();

                            // alle Layer holen
                            layerList = getLayerList(null);

                            // alle GroupLayer holen
                            processLayer(LayerTypes.GroupLayer);

                            // alle AnnotationLayer holen
                            processLayer(LayerTypes.AnnotationLayer);

                            // alle AnnotationSubLayer holen
                            processLayer(LayerTypes.AnnotationSubLayer);

                            // alle RasterLayer holen
                            processLayer(LayerTypes.RasterLayer);

                            // alle RasterCatalogLayer holen
                            processLayer(LayerTypes.RasterCatalogLayer);

                            // alle FeatureLayer holen
                            processLayer(LayerTypes.FeatureLayer);

                            // übrige Layer holen
                            foreach (ILayer lyr in layerList)
                            {
                                if (!processedLayers.Contains(lyr))
                                {
                                    LayerInfo lyrInfo = new LayerInfo(mapDoc);
                                    lyrInfo.processOtherLayer(lyr);
                                    lyrInfos.Add(lyrInfo);
                                    processedLayers.Add(lyr);
                                }
                            }

                            // Resultate ausgeben
                            foreach (LayerInfo info in lyrInfos)
                            {
                                Console.WriteLine(info.writeCSV());
                            }

                            // Dokument schliessen
                            mapDoc.Close();
                        }
                        else
                        {
                            Console.Error.WriteLine("FEHLER: kein gültiges MXD-File");
                        }
                    }
                    else
                    {
                        Console.Error.WriteLine("FEHLER: kein gültiges MXD-File");
                    }
                }
                else
                {
                    Console.Error.WriteLine("FEHLER: Angegebenes File nicht gefunden");
                }
            }
            else
            {
                Console.Error.WriteLine("FEHLER: Keine ArcView-Lizenz verfügbar");
            }

            // Lizenz zurückgeben
            TerminateLicense();
        }