Monthly Archives: September 2007

Adding spatial reference systems to a WMS service's capabilities file

Yingqi Tang, a product engineer specializing in ArcGIS Server and OGC services, contributed the following post:

In ArcGIS Server 9.2 you can publish a map document as an OGC WMS service. All WMS services advertise the spatial reference systems they support through capabilities files. WMS clients read the capabilities file to find out which spatial reference systems they can use to request a map.

The WMS services you create with ArcGIS Server support hundreds of spatial reference systems, but only two are advertised in the capabilities file: EPSG 4326 (required by every WMS service) and the spatial reference of the data frame from which you published the service. Although you can request a map from the WMS service using any of the hundreds of supported spatial reference systems, some WMS clients will return an error if the spatial reference you request does not appear in the capabilities file. Other clients, such as ArcMap, only allow you to switch among the spatial reference systems listed in the capabilities file.

This post shows how to add more spatial reference systems to the capabilities file of a WMS service that you have published with ArcGIS Server. To do this, you publish the WMS service using an external capabilities file. You can then manually add spatial reference systems to this file. This procedure is mentioned in the ArcGIS Server 9.2 documentation as one reason to use external WMS capabilities files.

Assume that you have a map document whose data frame’s spatial reference system is “World_Fuller (EPSG:54050)”. So by default the WMS service being published on that map document will only support spatial reference system EPSG:4326 and EPSG:54050. Now let’s add one additional spatial reference system “World_Aitoff (EPSG:54043)” into this WMS service by following detailed steps below.

  1. Publish the map document as a WMS service using system generated capabilities
    files. Use a system generated capabilities file as a template when creating an
    external WMS capabilities file. To use system generated capabilities files,
    select the option “Enter service properties below” in the WMS capabilities page
    in the Service Properties.

    Publishing with system generated capabilities files

  2. Assume you named your map service “world”, so the WMS service URL for “world”
    will be something like
    “http://<host>:port/arcgis/services/world/MapServer/WMSServer?”. Start a
    browser and type
    “http://<host>:port/arcgis/services/world/MapServer/WMSServer?version=1.1.1&service=WMS&request=GetCapabilities”.
    Save the response as an XML file called “capabilities111.xml”.

  3. Copy “capabilities111.xml” to a place on your file system and make it
    accessible as a URL. As an example, “capabilities111.xml” can be copied to
    “C:InetpubwwwrootArcGISWmsworld” (assuming you are using ArcGIS Server for
    the Microsoft .NET Framework and you have created the folder “world” yourself).
    So now the file can be accessible as URL
    “http://<host>/arcgis/wms/world/capabilities111.xml”. Before you keep
    going, start a browser and type in this URL to make sure the file is
    accessible.
  4. Stop the map service you just published in step 1. Go to the WMS capabilities
    page of the map service properties panel.

    Switch to use the second option “Use external capabilities files” to publish
    this WMS service. Type in the URL of the folder where you put
    “capabilities111.xml” plus the prefix of file “capabilities” in the “Specify
    the location and prefix” input box. (So in this example you would type
    “http://<host>/arcgis/wms/world/capabilities”) The reason why only the
    URL of folder and file prefix are required is to allow you to create external
    capabilities files for other versions of WMS (1.0.0, 1.1.0, 1.3.0). Click “OK”
    and restart the map service “world”.

    Publishing with external capabilities files

  5. Before you keep going,
    make a connection in ArcCatalog
    to the WMS service you just republished
    in step 4. The URL of your service is “http://<server name>/<instance
    name>/services/<folder name (if applicable)>/<service
    name>/MapServer/WMSServer?”. Preview the WMS service and make sure it’s
    working properly.

  6. Now you can add spatial reference systems to your WMS service. Make a copy of
    your map document and open the copy in ArcMap. Change the data frame’s
    coordinate system to “World_Aitoff (EPSG:54043)”, which is the one we want to
    add, and save the map document.

    World Aitoff projection in ArcMap

  7. Zoom to the full extent of the map. Right click the data frame and click
    Properties > Data Frame. Write down the extent values of current map (see
    the values in Extent > Fixed Extent).

    Getting the extent of the map

  8. Open “capabilities111.xml” which you saved in step 3 in a text editor. Search
    for the root “<Layer>” element (There will be only root <Layer>
    element in the xml).

    Add “<SRS>EPSG:54043</SRS>” right after
    “<SRS>EPSG:4326</SRS>” and “<SRS>EPSG:54050</SRS>”.

    How can you get the EPSG code for the spatial reference you want to add? One way
    is to look it up here in the
    Coordinate IDs and Descriptions book.

    Now add “<BoundingBox SRS=”54043″ minx=”-22041257.7736507″
    miny=”-17284666.2314989″ maxx=”22041257.7724258″ maxy=”17222309.5138405″/>”
    right after “<BoundingBox SRS=”54050″ . . .>” Substitute your own minx,
    miny, maxx, and maxy values that you wrote down.

    Original XML file:

    XML before change

    XML after adding new spatial reference system “EPSG:54043″ and its “BoundingBox” for root
    layer:

    XML after change

  9. For each layer of the map document, do the following things in order to figure
    out the layer’s extent: (1) Right-click the data frame and go to Properties
    > Data Frame. (2) Select “Other” in “Extent used by Full extent command” and
    click “Specify”; (3) Select “Outline of the Feature”, and pick the layer. (4)
    Apply the change and return to the map document. (5) Click Full Extent. (6) Go
    back to Properties > Data Frame and note the extent of the layer.

    Resetting Full Extent

  10. In “capabilities111.xml”, search for each <Layer> element according to
    its name and tile. For each layer add “<SRS>EPSG:54043</SRS>” right
    after “<SRS>EPSG:4326</SRS>” and
    “<SRS>EPSG:54050</SRS>”; Add “<BoundingBox SRS=”54043″ minx=”"
    miny=”" maxx=”" maxy=”"/>” right after “<BoundingBox SRS=”54050″……>”
    (you need to fill in minx, miny, maxx and maxy values with what you got in step
    9).

    Final XML

  11. Save “capabilities111.xml” and restart the map service.

  12. You’ve successfully added a spatial reference system to your WMS service. To
    prove it, connect to the WMS service in ArcCatalog and view the layer’s
    properties. “EPSG:54043″ should be listed as a “Supported SRS”.

    Supported spatial reference systems

  13. Add the WMS service in ArcMap. In the table of contents, right-click the service and click Change Coordinate System. Notice that World Aitoff is now a supported spatial reference system. You can use this dialog to switch among the supported spatial reference systems.

    Viewing spatial reference systems in ArcMap

Posted in Services | Tagged , | 3 Comments

Creating dash-dot symbols for polygon outlines

By Charlie Frye, Esri Chief Cartographer

Example of a dash-dot line symbol used on boundary lines

Dash-dot line symbols for polygon outlines should be displayed in a way that consistently shows the pattern of dashes and dots and clearly shows the shape of the polygon. In ArcGIS, a multi-layer line symbol is required. One layer is a cartographic line symbol with a dash pattern.  The second is a marker line symbol that shows a marker (the dot) with a complementary pattern to the dashes. Continue reading

Posted in Mapping | Tagged , , | 4 Comments

Using feature weight rankings to avoid placing labels on major streets

By Charlie Frye, Esri Chief Cartographer

Labeling toolbar with Label Weights button circled.

Notice in the first graphic below that the labels for “CAJON ST” and “CLIFTON CT” are placed over of major streets in a way that makes them difficult to read. This graphic is derived from my recent blog entry on the Maplex Street Placement option, and I was using the Street Placement option, but that left me with this problem. Well, this happened because I didn’t tell the Maplex Label Engine to treat the major streets differently. Continue reading

Posted in Mapping | Tagged , | Leave a comment

Explorer for Public Works

video featuring ArcGIS Explorer in a public works context has been published at ESRI’s GIS for Public Works Seminar site. The video demonstrates the use of Explorer for increasing operational awareness and for workforce management. The segment shows the integration of real-time weather,  asset locations, and network analysis of utility shut-off and affected customers.

 

Posted in Uncategorized | Tagged , , | Leave a comment

Tips for exporting to Adobe Illustrator format (AI) so CYMK colors are maintained

By Michael Law, Esri Product Engineer

Color Selector showing the menu that is shown be black triangle button.

For many GIS users and cartographers, the use of external graphics software is a common step in his or her workflow and production of print quality maps. One of ArcMap’s more popular export formats is the Adobe Illustrator (AI) export because of its wide compatibility with a number of graphics software packages. This export format was first made available in ArcGIS 8.1 Service Pack 1 and has been popular ever since. The ArcMap AI exporter has been fully tested to work in Adobe Illustrator CS and CS2. It is currently being tested in CS3 with good initial results. Continue reading

Posted in Mapping | Tagged , , | 12 Comments

NEO and Explorer

Here’s an interesting post from the GIS Education Community Blog covering the use of NASA Earth Observation (NEO) content in Explorer.

Posted in Uncategorized | Tagged , , | Leave a comment

Adding context menus to a Web ADF application

In this post, Rex Hansen provides a sneak peek at a forthcoming EDN article on adding context menus to your .Net Web ADF applications.

The ContextMenu control allows users to interact with your Web ADF application at runtime, usually by right-clicking a component. A ContextMenu can contain one or more context menu items. Each item is associated with an action to execute client or server-side code. In addition, each context menu item may be displayed with an icon andor text. Both the Toc and TaskResults controls include preconfigured ContextMenus to interact with their node content. 

The ContextMenu control is not included with the out-of-the-box Web ADF controls integrated with Visual Studio. So, to use the control you can either add a declarative reference in your page or add the ContextMenu control to the Visual Studio toolbox then drag-and-drop it on the page (see Step 1 in Using the ContextMenu control section below). In addition, you must configure context menu items programmatically; no design-time configuration is provided. 

Using the ContextMenu control

  1. Add the ContextMenu control to the Visual Studio toolbox

    Since the ContextMenu control is not added to the Visual Studio toolbox during the Web ADF installation, you need to manually add it. If you have already added the ContextMenu control, skip to the next step.

    1. In Visual Studio, expand the ArcGIS Web Controls tab in the toolbox. Right-click on the tab and select “Choose Items…”.
    2. Navigate to the ContextMenu control in the namespace ESRI.ArcGIS.ADF.UI.WebControls and check the box next to the listing. Click OK. The ContextMenu control should now be available in the toolbox.

      Page with Toc control

  2. Add supporting controls to the page

    Add a MapResourceManager and Map to the page, then add a valid resource item to the MapResourceManager. In this example, we’ll construct a ContextMenu for use on a Map control. Keep in mind that a ContextMenu can be associated with any element in the page, thus the patterns presented here will apply in other situations. 

  3. Add the ContextMenu control to the page

    Drag a ContextMenu control on the page. Note that the location of the ContextMenu control at design-time does not determine the location of the context menu at runtime. Your page should resemble the following:

    Page with Toc control

  4. Set properties for the ContextMenu control

    In design mode, click on the ContextMenu control to select it. Now examine the control’s properties in the Properties window. You don’t have to manually change any of the properties, but it’s recommended that you set the BackColor property to a solid color, for example, white or gray. By default the BackColor property is not set, so the context menu appears transparent at runtime.

  5. Add context menu items

    Adding items and configuring the behavior of a ContextMenu requires writing some code. You can create new context menu items by using the ContextMenuItem class and then adding them to the ContextMenu control. Properties of a ContextMenuItem include the url to an image, the menu item text, and a string representing some custom JavaScript code to execute when the item is clicked. An appropriate time to add new context menu items during the page lifecycle is during the initial page load event. Add the following code to the code behind for your page:

    [C#]

    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
      {
        ESRI.ArcGIS.ADF.Web.UI.WebControls.ContextMenuItem contextMenuItem =
          new ESRI.ArcGIS.ADF.Web.UI.WebControls.ContextMenuItem();
    
        contextMenuItem.Text = "Zoom In";
    
        ContextMenu1.Items.Add(contextMenuItem);
      }
    }
    
  6. Add event to show context menu at runtime 

    In order to display the context menu at the appropriate time, you need to add a browser event to the appropriate control, element, or item in the page. In this case, we want the ContextMenu to be displayed during a right-click on a map. At runtime, the Map control generates a div for display of map data in a browser. A set of attributes events can be configured on the div. One attribute is “oncontextmenu” which enables the browser to listen for right-click events on an element. When this event is triggered, JavaScript code displays the the ContextMenu control and its items. The Web ADF provides a set of JavaScript functions to show and hide context menus. In this case, when the oncontextmenu event is triggered on the map the esriShowContextMenu() JavaScript function will be called and our ContextMenu will be displayed. As in the previous step, an appropriate time to add new attribute information to controls and elements is during the initial page load event. Add the following code (blue) to the existing code added in the previous step (gray):

    [C#]

    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
      {
        ESRI.ArcGIS.ADF.Web.UI.WebControls.ContextMenuItem contextMenuItem =
          new ESRI.ArcGIS.ADF.Web.UI.WebControls.ContextMenuItem();
    
        contextMenuItem.Text = "Zoom In";
    
        ContextMenu1.Items.Add(contextMenuItem);
    
        string showContextMenu = string.Format("esriShowContextMenu(event,'{0}','{1}','{2}');return false;", ContextMenu1.ClientID, Map1.UniqueID, "");
    
        Map1.Attributes.Add("oncontextmenu", showContextMenu);    
      }
    }
    
  7. Handle click event on context menu item

    Once the ContextMenu is displayed at runtime, a user can click on a context menu item to initiate an action. To work with the click event on the server, handle the ItemClicked event on the ContextMenu. When the menu item is clicked, a callback request is sent to the page which contains the context menu. The context menu item can be identified by its text and made available via the ContextMenuItemEventArgs passed to the ItemClicked event. The ContextMenu control is explicitly designed to work with the ASP.NET callback architecture. Implementation code on the server can now interact with server-side content based on the context menu item clicked. Note, the ContextMenu control generates the callback response designed to be processed by the Web ADF JavaScript. As a result, changes to other controls in the page must be packaged as CallbackResults and added to the ContextMenu.CallbackResults property (a collection of CallbackResult objects). More information on Web ADF implementation of the ASP.NET callback framework is available in the topic Working with AJAX capabilities of the Web ADF.

    1. To handle the ItemClicked event on the ContextMenu in the page, open the ContextMenu property page and view the events (click the lightning bolt button).

      Page with Toc control

    2. Double-click on the ItemClicked event in the dialog. The code-behind page will display with the implementation method created for you.
    3. Add the following code to the event handler method. In this case, the Map.Zoom() convenience method will cause the map to zoom in, thus changing the map extent. Since the Map has changed, but the ContextMenu is generating the callback response, the callback results from the Map control need to be copied to the ContextMenu’s callback results collection.

      [C#]

      protected void ContextMenu1_ItemClicked(object sender, ESRI.ArcGIS.ADF.Web.UI.WebControls.ContextMenuItemEventArgs contextMenuItemEventArgs)
      {
        switch (contextMenuItemEventArgs.Item.Text)
        {
          case "Zoom In":
            {
              Map1.Zoom(2);
              ContextMenu1.CallbackResults.CopyFrom(Map1.CallbackResults);
              break;
            }
        }
      }
      					
  8. Using the ContextMenu at runtime

    When the Web application starts, the ContextMenu is not visible. Right-click on the control which will show the ContextMenu (In this example it’s the Map control). The ContextMenu will be displayed along with it’s context menu items. In this case, click on the item “Zoom In” to zoom in on the map.  

    Page with Toc control

Posted in Services | Tagged , , | 5 Comments

Find GNIS Task

A Find GNIS task has recently been added to the Community Showcase on Explorer’s Resource Center. This task was authored by Michael Waltuch of the Explorer development team, who would also like to acknowledge Dwight S. Hughes of the USGS for his invaluable help.

For those not familiar with the GNIS, the USGS Web site states:

The Geographic Names Information System (GNIS), developed by the U.S. Geological Survey in cooperation with the U.S. Board on Geographic Names, contains information about physical and cultural geographic features in the United States and associated areas, both current and historical (not including roads and highways). The database holds the Federally recognized name of each feature and defines the location of the feature by state, county, USGS topographic map, and geographic coordinates.

The task queries the GNIS database and returns results that locate physical and cultural geographic features of all types in the United States and associated areas. To return results, select a state or territory name, a county or sub-unit name (optional), and a feature type you’re interested in. There are over 1.98 million features of 65 types in the GNIS.

The task is easy to access from the Resource Center, just open it from Explorer (click Help, then ArcGIS Explorer Resource Center…) and then click the Share tab, then scroll down the list until you see it. Just click, and it will be added to your Explorer tasks.

Here’s an example query shown in the Find GNIS task:

And here’s the result:

 

Posted in Uncategorized | Tagged , , , | Leave a comment

Cartographic settings in the ArcMap Advanced Settings utility

By Aileen Buckley, Mapping Center Lead

Image of ArcMap Advanced Setting Utility

A lot of people don’t know about the ArcMap Advanced Settings utility – it can help you customize some of ArcMap’s default options and as a result make your experience with ArcMap a bit more efficient and personalized.  The executable file that starts the utility is located in your ArcGISUtilities folder.  On my computer, the path is C:Program FilesArcGISUtilities.  Double-click the AdvancedArcMapSettings.exe filename to start the utility.  Here are some options you may find useful on the various tabs: Continue reading

Posted in Mapping | Tagged , , | Leave a comment

Explorer Helps Unravel the Mystery of Lago

We don’t usually blog about these types of things, but we just couldn’t resist this one.

Clint Eastwood fans may remember the town of Lago from High Plains Drifter, but may not know where the movie set was actually located. Here’s an interesting use of Explorer to discover the real location of that movie town. From the web site, the top portion of the following image shows Lago as it was constructed. The bottom portion shows the ArcGIS Explorer view of it now.

Posted in Uncategorized | Tagged , , | Leave a comment