Beispiel #1
0
        //On click, verify valid inputs are provided and send parameters to LoadLayers.cs
        private void button1_Click(object sender, EventArgs e)
        {
            if (m_pBUILDINGSDE == null || m_pDOFTAXMAPSDE == null || m_pCSCLSDE == null)
            {
                MessageBox.Show("Folder required for all connections.", "No folder provided", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Verify that map type is selected
            else if ((isCSCL && isCustom) || (!(isCSCL) && !(isCustom)))
            {
                MessageBox.Show("Select only one map type.", "Map Type Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
            //Verify that at least one layer is selected (if custom)
            else if ((isCustom) && (!(isAddressPoint) && !(isBuilding) && !(isCenterline) && !(isTaxLot)))
            {
                MessageBox.Show("Select at least one map layer to load into map", "Custom Map Type Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }

            else
            {
                //Create Connection file (removed from final project)
                //SDEConnection.SDEWorkspace(server, instance, user, password, database, version);

                //Load layers using input folders/SDE connections
                LoadLayers.BuildMap(m_pBUILDINGSDE, m_pCSCLSDE, m_pDOFTAXMAPSDE, isCSCL, isCustom,
                                    isAddressPoint, isCenterline, isBuilding, isTaxLot, isSave);
                this.Close();
            }
        }
Beispiel #2
0
        public static void BuildMap(string m_pBUILDINGSDE, string m_pCSCLSDE, string m_pDOFTAXMAPSDE, bool isCSCL, bool isCustom,
                                    bool isAddressPoint, bool isCenterline, bool isBuilding, bool isTaxLot, bool isSave)

        {
            //Point to map document
            IMxDocument pMxDoc;

            pMxDoc = (IMxDocument)ArcMap.Application.Document;

            IMap pMap;

            pMap = pMxDoc.FocusMap;

            //Zoom in so that layers don't take too long to load
            double    x      = 988217;
            double    y      = 192020;
            double    border = 200;
            IEnvelope pEnvelope;

            pEnvelope = new EnvelopeClass {
                XMin = x - border, YMin = y - border, XMax = x + border, YMax = y + border
            };

            pMxDoc.ActiveView.Extent = pEnvelope;

            //Create layer groups
            IGroupLayer pBoundaryLayerGroup = new GroupLayerClass();

            pBoundaryLayerGroup.Name     = "Boundary";
            pBoundaryLayerGroup.Expanded = true;
            pBoundaryLayerGroup.Visible  = true;

            IGroupLayer pTransportationLayerGroup = new GroupLayerClass();

            pTransportationLayerGroup.Name     = "Transportation";
            pTransportationLayerGroup.Expanded = true;
            pTransportationLayerGroup.Visible  = true;

            IGroupLayer pPlacesLayerGroup = new GroupLayerClass();

            pPlacesLayerGroup.Name     = "Places";
            pPlacesLayerGroup.Expanded = true;
            pPlacesLayerGroup.Visible  = true;

            IGroupLayer pEMSLayerGroup = new GroupLayerClass();

            pEMSLayerGroup.Name     = "EMS";
            pEMSLayerGroup.Expanded = true;
            pEMSLayerGroup.Visible  = true;

            IGroupLayer pReferenceLayerGroup = new GroupLayerClass();

            pReferenceLayerGroup.Name     = "Reference";
            pReferenceLayerGroup.Expanded = true;
            pReferenceLayerGroup.Visible  = true;

            IGroupLayer pLayerGroup = new GroupLayerClass();

            pLayerGroup.Name     = "Featured Layers";
            pLayerGroup.Expanded = true;
            pLayerGroup.Visible  = true;

            //Load Layers into layer groups using input SDE connection using LoadCSCLFeatureClass method
            if (isCSCL)
            {
                LoadCSCLFeatureClass(isCSCL, "CityLimit", pBoundaryLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "ZipCode", pBoundaryLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "AssemblyDistrict", pBoundaryLayerGroup, m_pCSCLSDE);

                LoadCSCLFeatureClass(isCSCL, "CensusBlock2010", pReferenceLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "CensusTract2010", pReferenceLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "Elevation", pReferenceLayerGroup, m_pCSCLSDE);

                LoadCSCLFeatureClass(isCSCL, "FireBattalion", pEMSLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "FireCompany", pEMSLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "FireDivision", pEMSLayerGroup, m_pCSCLSDE);

                LoadCSCLFeatureClass(isCSCL, "Rail", pTransportationLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "Subway", pTransportationLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "SubwayStation", pTransportationLayerGroup, m_pCSCLSDE);
                LoadCSCLFeatureClass(isCSCL, "TransitEntrance", pTransportationLayerGroup, m_pCSCLSDE);

                LoadCSCLFeatureClass(isCSCL, "PointOfInterest", pPlacesLayerGroup, m_pCSCLSDE);
            }

            //Load Featured Layers if CSCL map or feature selected for custom map
            if (isCSCL || isTaxLot)
            {
                LoadLayers.LoadCSCLFeatureClass(isCSCL, "Cadastral", pLayerGroup, m_pDOFTAXMAPSDE);
            }
            if (isCSCL || isCenterline)
            {
                LoadLayers.LoadCSCLFeatureClass(isCSCL, "StreetCenterline", pLayerGroup, m_pCSCLSDE);
            }
            if (isCSCL || isBuilding)
            {
                LoadLayers.LoadCSCLFeatureClass(isCSCL, "Building", pLayerGroup, m_pBUILDINGSDE);
            }
            if (isCSCL || isAddressPoint)
            {
                LoadLayers.LoadCSCLFeatureClass(isCSCL, "AddressPoint", pLayerGroup, m_pCSCLSDE); //0
            }

            //If cscl, load group layers
            if (isCSCL)
            {
                pMap.AddLayer(pBoundaryLayerGroup);
                pMap.AddLayer(pReferenceLayerGroup);
                pMap.AddLayer(pTransportationLayerGroup);
                pMap.AddLayer(pPlacesLayerGroup);
                pMap.AddLayer(pEMSLayerGroup);
                pMap.AddLayer(pLayerGroup);
            }

            //Update map contents and refresh
            IActiveView pActiveView;

            pActiveView        = (IActiveView)pMap;
            pActiveView.Extent = pEnvelope;
            pActiveView.Refresh();
            pMxDoc.UpdateContents();

            //Prompt save directory if isSave checkbox selected
            if (isSave)
            {
                UID uid = new UIDClass();
                uid.Value   = "esriArcMapUI.MxFileMenuItem";
                uid.SubType = 3;
                ICommandItem item = ArcMap.Application.Document.CommandBars.Find(uid, false);
                item.Execute();
            }
        }