Showing posts with label arcgis server. Show all posts
Showing posts with label arcgis server. Show all posts

Sunday, April 10, 2011

Get current user info in a Server Object Extension

Server Object Extensions (SOEs) give developers the ability to utilize the extensive geoanalytical capabilities of ArcObjects within an ArcGIS Server service. They also provide a framework that enables access to custom functionality in a service through the standard Web service protocols SOAP and REST. Enabling Web access to an SOE is well documented in the ArcObjects SDK.

ArcGIS Server Web services can also be secured using token or Web server authentication methods. Since SOEs are can be enabled on a specific service, authentication rules configured on a service apply to all of its extensions, including custom SOEs. This poses the question: if an SOE is enabled on a secured Web service, can the authenticated user be retrieved within the SOE? Yes, in ArcGIS Server 10 this is possible.

Use the C# code provided below as an example. Basically, within your SOE code get the current server environment and cast to IServerEnvironment2 to gain access to UserInfo. If authentication is enabled for ArcGIS Server Web services, each request to a service will be associated with an authenticated user. UserInfo will contain the user name and roles within which that user is present for the current request. Note, when Web server authentication is based on Windows users and groups, the user name is in the format domain\user.



Unfortunately, REST SOE's hosted on ArcGIS Server for .NET require ArcGIS Server 10 service pack 2 for this to function. ArcGIS Server 10 service pack 2 will be available for download on the ArcGIS Resource Center soon.

Monday, April 5, 2010

Dev Summit 2010, Image Services, and Silverlight

About a week before the Dev Summit I was tasked with showcasing ArcGIS Server 10 image services in the plenary using Silverlight as the platform. The tricky part was limiting the temptation to “light it up” with Silverlight so as not to overshadow image services. And there was another problem - the last time I did anything related to image processing my cell phone was the size of an army field radio, Netscape was the browser du jour, and Enron was a hot stock buy. So I had to ramp up on image services quickly… which meant spending some quality time with the raster gurus at the factory (ESRI). Along the way, I gathered some valuable info and thought it might be interesting to relay a few pivotal gems on the use of image services and Silverlight in ArcGIS 10.


  • ArcGIS 10 supports a new geodatabase model, the mosaic dataset, which can easily and effectively manage small and large collections of imagery. They are created and maintained in ArcMap or ArcCatalog and you use a set of GP tools to manage. Mosaic datasets support imagery from multiple sensor platforms including QuickBird, IKONOS, and WorldView. Most importantly, there is no preprocessing required. Mosaicking, pansharpening, and ortho-rectification happen on the fly. Merely add the image to the mosaic dataset and it assimilates.

  • Mosaic datasets support time awareness. Image services are time aware if the underlying mosaic dataset has been time enabled. You enable time awareness in the mosaic dataset properties, not the layer properties (as with feature layers in a map service).

  • Sometimes rasters in a mosaic dataset will not display at full or larger extents. In this case, overviews must be generated. Overviews are similar to pyramid layers in that they allow for the quick display of very large collections of imagery. Overviews do this by resampling source data to generate "snapshot" images for larger map resolutions (larger extents). In most cases, you will want to generate overviews. However, this poses a problem when you want to display a set of rasters that occupy the same space in a time series. Overviews are generated for a specific map resolution (map units/pixel) ranges, not a specific instant or span of time. Therefore if you're viewing your image service at a map resolution that uses an overview, the overview will only show one instant of time regardless of the time extent you specify. In this situation, avoid generating overviews and increase the maximum cell size range factor to enable the display of primary rasters at larger map resolutions. To do this, use the Calculate Cell Size Ranges option from the mosaic dataset context menu in ArcCatalog/ArcMap or use the geoprocessing tool of the same name. Increase the range factor to increase the threshold at which overviews are used, if available.

  • 9.3.1 Image Server functionality is now part of core ArcGIS Server 10.

  • All rasters, including mosaic datasets, can be published as image services. An individual image on disk is termed a "raster dataset" or "raster layer".

  • Image services include an enhanced export image operation and three new operations: query, identify, and download. Each are covered in detail below.

  • The export image operation has a new JPGPNG image format which lets the image service define the ideal output format. If the extent requested contains transparent portions, generate a png. If not, generate a jpg.

  • The export image operation uses mosaic rules to order, filter, and select tiles displayed in the mosaicked image. For example, if a service hosts a set of overlapping images you can define which ones are displayed over others based on an attribute such as date, or a point of interest. The REST API documentation provides minimal insight into parameter descriptions. The SOAP API documentation may provide more information (it definitely will in ArcGIS Server 10 final). Also note, the identify operation uses mosaic rules to order and filter rasters to modify results.

  • The export image operation provides rendering rules to dynamically change the display of raster data using a set of predefined raster functions. For example, you can apply a custom aspect, slope, color map or shaded relief on the fly. Only 8 raster functions are available with the ArcGIS Server 10 REST API. One item you may notice in a rendering rule is the variableName attribute. It must be set to the value defined in the REST API doc, either “DEM” or “Raster”. It represents a property defined in ArcObjects where values may include “Raster2” or a user defined name for a function chain. These other values are not exposed in the REST API.

  • The query operation enables clients to define an attribute and/or spatial query and return information about rasters in a dataset hosted by an image service. You can also use it to return raster footprints or a raster thumbnail.

  • The identify operation enables clients to return a pixel value for rasters hosted in an image service given a user-defined location. The location can be a point or polygon. If a polygon, the centroid of the polygon is used. The order of rasters during the operation can be defined by a mosaic rule. Unlike the identify operation on a map service, image services do not provide a tolerance since only one pixel value per raster can be returned. Do not let the pixel size parameter fool you; it defines a pixel resolution to use when identifying pixel values. This means you can identify on overviews available in the mosaic dataset, and return an interpolated value in an overview image. Interpolation occurs when the overview is generated by resampling source rasters.

  • The download operation basically enables clients to download individual rasters and metadata hosted by an image service. You can also clip imagery on the server before download and define the download image format. If you don't want users to download individual rasters, you can easily disable this capability of the service.

So what does this mean for the ArcGIS API for Microsoft Silverlight/WPF? To put it simply, the ArcGISImageServiceLayer has been updated to support working with ArcGIS Server 10 image services. A set of new classes will be included to support mosaic and rendering rules. The QueryTask can be used with the image service Query operation. The Identify operation will require a new task, and the Download operation may be supported in the near future. 2.0 public beta will be released in April and you'll get a chance to try out some of this new functionality.


Also, at some point in the near future a set of ArcGIS Server 10 image services will be hosted online by ESRI to demonstrate their functionality. They may or may not be officially announced. In any case, I’ll tweet when they’re up, running, and public (@rex_hansen).

Sunday, December 6, 2009

ESRI's European User Conference 2009 - Asides and Slides


In October 2009 HNIT-Baltic hosted ESRI's European Users Conference in Vilnius, Lithuania. I attended as an ambassador for ArcGIS Server, its Web APIs, and MapIt. This was my first foray into eastern Europe, and it turned out quite simply fantastic. Discussions with users and partners were spirited and exciting, and attendees in my sessions were engaged. The folks I met that work at HNIT-Baltic were exceptionally knowledgable and courteous, and simply ready for the next challenge.

The city itself was inviting, fresh, and personal. And I discovered a few things during my adventure: Lithuanians enjoy pizza with ketchup, because I was told it "adds flavor"; shopping malls look like factories on the outside, but they rival the best of So Cal on the inside, with better prices; and if you see a glass of water on a table at a party... it's probably vodka.

I've included a montage of a few photos I snapped with my trusty iPhone while in Vilnius (press "P" to pause).

If you attended the EUC in Vilnius or just want to view the conference materials, you can view and download the plenary and paper session materials from HNIT-Baltic.

To peruse the technical sessions I presented, I've made PDF versions of the session slides available below:
Building Mashups with ArcGIS Server
Building Great Web Map Applications
Whats New in ArcGIS Server 9.3.1

Sunday, November 1, 2009

Using the ArcGIS Server REST API in .NET applications

Over the past year I've handled a number of questions regarding the use the ArcGIS Server REST API in a .NET application. It can be done quite effectively, but isn't explicitly promoted by ESRI since the REST API is primarily designed to be consumed by pre-packaged Web clients like the ArcGIS JavaScript, Flex, and Silverlight/WPF APIs. However, using REST programmatically in a .NET application context without installing an ESRI product can make for some powerful and focused yet lightweight solutions. In addition, if you need to do something relatively simple you don't have to generate a load of client-side proxy classes like you do with SOAP.

I've included a simple code example below to highlight how easy it is to integrate ArcGIS Server services via REST in your .NET app. The example uses an ArcGIS Online geocode service to geocode an address and return a location.

Download the sample here.


There are a few items to consider when using ArcGIS services via REST in .NET:

  1. You will construct the url that will execute an operation on the server. Inputs to the operation are included in the url as parameters with values. Add a reference to the System.Web.dll and use the HttpUtility class to encode parameter values in the url.
  2. In most cases you will return results in JSON (JavaScript Object Notation) format. Add a reference to the System.Web.Extensions.dll (included with .NET 3.5, separate install for .NET 2.0) and use the JavaScriptSerializer class to deserialize JSON results into a dictionary you can use more effectively.

This example can easily be modified for use in a .NET CLR trigger for SQL Server to geocode address information upon entry into a table -or- in a batch process to geocode addresses in a database -or- show a location in a WinForm or WPF desktop client. The same idea can cross over into other ArcGIS Server services such as querying layers in a map or executing a geoprocessing service. In any case, you'll find the simplicity of the REST API refreshingly simple for those scenarios where you need to plug a little GIS into your app. One parting note, if you use ArcGIS Online services via REST, you'll need to follow the subscription model for the Web Mapping APIs. For example if you geocode more than 1000 addresses, you'll need to purchase a subscription.

Sunday, August 23, 2009

ArcIMS equivalency in ArcGIS Server?

In May of 2000, ArcIMS 3.0 was released and over the next few years it took the Web GIS world by storm. There were few competitors, so the market was ripe. While it was considered complicated initially, most folks were able to buckle down and wrap their head around the technology - and build some rock solid solutions. HTML Viewer based applications, servlet connectors, and custom solutions using the ActiveX, ColdFusion or Java connector started popping up all over the Web. Turns out, ArcIMS was actually simple – all interaction was stateless and anything it could do on the server was dictated by ArcXML – so its boundaries were well defined. Plus it did its job very well. Dynamic mapping, feature streaming, queries, geocoding, extract... all were quick and efficient.

In the Web mapping world of late 2009, ESRI brings its wealth of GIS intelligence to a party that includes companies originally founded on search engines, operating systems, and business software. The market has expanded dramatically since ArcIMS was first released, and it continues to grow. ArcGIS Server now provides a comprehensive enterprise GIS solution for the Web with seemingly unlimited capabilities, especially when you factor in access to ArcObjects on the server. In general, it integrates with a diverse range of back-end data stores, utilizes an effective and robust authoring environment to build data and logic into a service, and it exposes numerous public Web service formats and protocols to support a wide range of consumers. In addition, a bevy of Web clients are available… server-side AJAX solutions using the ADFs, lightweight browser clients using the JavaScript API, and rich Web clients using Silverlight or Flex. With the sheer volume of features, functionality, frameworks and APIs in the ArcGIS Server suite, it remains unmatched as a complete enterprise GIS solution.

So with all this said, we know that ArcGIS Server can do so much more than ArcIMS in many areas, but are there still some things ArcIMS can do that ArcGIS Server can’t – or can’t do very easily? Yes. Let’s step through the ArcIMS service (virtual server) types as see:

Geocode? Yes, ArcGIS Server has it covered in the geocode service.

Route? Yes, ArcGIS Server has it covered in the network analyst extension on a map service.

Metadata? Yes. The GIS Portal Toolkit was added as an extension to 9.3. At 9.3.1 it was termed the ArcGIS Server Geoportal extension.

Extract? Yes, but it’s not as simple as ArcIMS. In ArcGIS Server you can emulate an extract virtual server with a custom tool (model) in a GP service. Granted GP can be very complex, but also very powerful... a good trade-off. Geodata services do provide an extract option, but the service was primary designed for the ArcGIS desktop client and functionality is limited to working with a geodatabase.

Feature? Yes, except it’s handled via a query operation on a feature layer in map service. The feature virtual server was primarily designed for the Java Viewer - the “rich” Web client when ArcIMS was first released. ArcGIS Server 9.4 will include a feature service with much greater functionality that that provided in ArcIMS.

ArcMap? Not quite. In general the ArcMap virtual server just exposes a subset of ArcGIS Server map service capabilities... so generating dynamic maps and querying layers is covered. One notable difference involves access to page layouts. In ArcIMS you can use GET_LAYOUT to generate printable output from a page layout in an mxd hosted by an ArcMap image service. In ArcGIS Server this capability is not available via a Web service protocol or format. Instead you must use ArcObjects (remote) and QI to IMapServerLayout from the map server object -or- use the Web ADF's PageLayout control which only works with local ArcGIS Server data sources. In either case interaction usually remains stateless.

Image (map) and query? No, but ArcGIS Server is crossing things off the list. On the server customization side, ArcGIS Server is unmatched. You can extend a server object in ArcGIS Server using .NET or Java –or- create and access ArcObjects remotely. In ArcIMS customizing a virtual server using C++ was rare and relatively difficult. There's also the issue of performance. Dynamic mapping in ArcIMS is notoriously fast. To match and exceed ArcIMS performance, ArcGIS Server provides the ability to pre-cache map tiles (9.2+) and to generate “fast” dynamic maps with optimized services (9.3.1+). One notable addition to ArcIMS 9.0 was the ability to reproject geometry using GET_PROJECT. This was covered in ArcGIS Server 9.3 with the release of the Geometry service.

With this out of the way, let’s focus on comparing the stateless capabilities of ArcIMS image\query and ArcGIS Server map services. Below I’ve listed six stateless capability categories that are popular in ArcIMS and still deficient at some level in ArcGIS Server:

  1. Reorder layers (including graphics) – It’s possible in ArcGIS Server but requires a stateful change and you must work with fine-grained ArcObjects.
  2. Change layer renderers – It’s possible in ArcGIS Server but requires a stateful change and you must work with fine-grained ArcObjects.
  3. Enable use of variable transparency for symbols (applied to graphic elements, selection sets, etc.) – Right now symbol transparency can be either 0% or 100%.
  4. Add dynamic layers – It’s possible in ArcGIS Server but requires a stateful change and you must work with fine-grained ArcObjects. If dynamic layers can be added, two additional capabilities will be necessary for equivalency:
    1. Enable joins in dynamic layers
    2. Query dynamic layers
  5. Support related data in query results - All ArcGIS Server map service query operations support returning joined data. In 9.3 the identify operation returns related data (SOAP only), but other query operations do not. So, to retrieve related rows in an ArcGIS Server map service right now, you have to use fine-grained ArcObjects and traverse the relationship class collection on a feature layer. This will change in 9.4; query operations will return related data.
  6. Fully support scale dependent rendering on a single layer - This is relatively easy to do with ArcXML in a map configuration file, but in ArcMap it requires VBA and the symbology is not readily accessible – namely the Toc swatches are empty. A better solution involves using a group layer in ArcMap. Essentially you add a reference to the same layer multiple times within a group and set the scale dependency and symbology for each layer. Unfortunately all the layers show up in the Toc (even those outside scale range) so the experience isn’t exactly like ArcIMS, which seems cleaner.

For the most part, ArcIMS equivalency can be found in ArcGIS Server. My interest in posting the exceptions is three-fold: to provide awareness of these issues, to mention resolutions pending in future versions, and to provide guidance on a current solutions or workarounds. If you’re aware of another ArcIMS equivalency issue in ArcGIS Server, I encourage you to add a comment below. Hope this was helpful.