A Sample Print Web Service Utilizing ArcGIS Server and

Download Report

Transcript A Sample Print Web Service Utilizing ArcGIS Server and

A Sample Print Web Service
Utilizing ArcGIS Server and
ArcObjects
Cheryl Spencer, IndyGIS
Marianne Cardwell, Woolpert
Overview
IndyGIS background
Current web service use
Why the need for a print web service?
Business reasons
Technological reasons
Nuts and bolts
Components of the Print Web Service
How components are used
Challenges & Lessons Learned
IndyGIS Background
Numerous internal applications and
public applications
ArcGIS Server purchased in 2004
Currently migrating to version 9.2
Until recently have used ArcGIS Server
behind the scenes to perform spatial
analysis (non-map centric applications)
Current Web Services
Address Validator
Geocode
Point In Polygon
Find Nearest
Find Within Radius
Polygon Analysis
Buffer
…and Print
Example Applications Using Web
Services
Business Reasons for a Print Web
Service
Target audience – Developers
Reusable print component can be used
for all ArcGIS Server applications
developed
Plug and Play
• Saves time…and money
Consistent user experience when printing
from a variety of applications.
Technological Reasons for a Print
Web Service
Current ArcGIS Server technology does not
provide for map printing functionality.
Printing the page using the browser’s print
functionality does not provide very good
quality print-outs.
Web service clearly separates out the print
logic from the rest of the code.
Print WS returns ArcMap-styled PDF map,
including all elements one can expect in a
map: scale, North arrow, legend, map,
overview map, as well as text elements.
Components of the Print Web Service
How components are used
The first step is
to create a
layout in
ArcMap.
The second
step is to
export the
layout to an
XML file.
XML Configuration File
Custom ArcMap tool wizard created to
convert an ArcMap layout to an XML
document using a custom schema.
Schema is read by Print Web Service to
recreate the layout.
XML Configuration File
Example Use of Print Web Service
A web site utilizing an ArcGIS Server
map control can use the Print WS to
request a PDF map.
Multiple parameters are requested,
including the map description(s), map
scale, map extent, text elements, and
XML configuration file name.
Sample Web Interface
Print Web Service Process
Get all parameters ready for the Web Service
call:
Public Function ExportForUrl(ByVal
ByVal
ByVal
ByVal
ByVal
ByVal
ByVal
ByVal
ByVal
ByVal
ByVal
textElements As TextElement(), _
pageConfigName As String, _
pageSize As String, _
pageOrientation As String, _
extent As Envelope, _
webMapScale As Double, _
mapServices() As MapService, _
overviewMapServices() As MapService,
graphicElements() As GraphicElement,
limitLegendLayers As Boolean, _
legendLayers() As String) As String
Print Web Service Process (cont’d)
Print WS goes through the following
steps:
Create a Server Object Manager
Create an empty Server Context
Create (a) new IMap(s)
Add layers to the map (re-created from
MapDescription)
Add graphics to the map
Print Web Service Process (cont’d)
Set up the page layout and the extent of the map
Add all the page elements to the layout. These
include:
•
•
•
•
•
•
•
•
Map frames
Legends
North arrows
Scale bars
Text elements
Neatlines
Pictures
Scale texts
Export the map to PDF.
Challenges
ArcObjects does not always respond the same way in
a Web Service as it does in the Desktop environment.
Don’t make too many assumptions.
Legend was tricky. Spent a lot of time trying to get it
right and required a lot of manual coding to resize it
to the correct dimensions.
Graphic layers with transparencies are not supported
in ArcObjects (ArcMap) whereas they are in ArcGIS
Server map controls (think of buffer overlays).
Solution was to export the graphics to temporary
shapefiles to apply transparency.
Lessons Learned
Do your homework.
Document!
Make it flexible.
Put thought into web service signature.
Think about error handling.
Consider wrapping fine-grained
ArcObjects calls into separate DLLs.
Questions?