Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly
get the code
more resources

Build Real-Time Web Images
Use Microsoft's TerraService and MapPoint Web Services to start your own VS.NET-based mapping projects.
by Roger Jennings

Posted June 4, 2004

Technology Toolbox: VB.NET, XML, Visual Studio .NET 2003, XML Web services

Location-based Web services will play an increasingly important role as handheld devices gain carrier-based and GPS positioning capabilities. You can expect Microsoft, other map providers, and cellular carriers to offer an expanding array of geocoded imaging Web services. Now's the time to start exploring new VS.NET mapping applications.

Existing production Web services mostly deliver character-based XML data—such as ADO.NET DataSets—between server endpoints. Not many commercial services interact with desktop clients yet. Consequently, you rarely see Web services that deliver base64Encoded bitmap data you can display in a Web or Windows client.

ADVERTISEMENT

User demand is growing for image delivery, however, and developers who hear the call are starting to discover what they can do with VS.NET 2003's Add Web Reference dialog. This dialog makes it easy to create proxies for Web services that return encoded images. True, it isn't a walk in the park to write VB.NET or C# code for specifying geographic image coordinates and displaying them in a WinForm or Web Form app—especially if you haven't mastered the members of the .NET Framework 1.1's System.Drawing.Imaging and System.Drawing.Printing namespaces.

I'll give you a head start by describing two WinForm imaging apps that consume mapping Web services. I'll provide highlights of the VB.NET code required to acquire, display, and navigate aerial photographs and annotated topograpic maps. You can download the complete source code for both VS.NET 2003 projects.

The first project, TerraService.sln, connects to Microsoft Research's ASP.NET TerraService and LandmarkService (see Additional Resources). TerraService provides direct access to the 3.5 terabyte (TB) TerraServer SQL Server 2000 database of satellite and U.S. Geological Survey (USGS) aerial photographs, along with scanned images of USGS paper topographic maps. The TerraServer project started in 1997 as a SQL Server 7.0 scalability demonstration. Public Web access to 1.5 GB of TerraServer images commenced in 1998, and is currently in version 6.0. Microsoft Research added TerraService Web services in 2001.

TerraService delivers images as Simple Object Access Protocol (SOAP) response documents containing base64Encoded bitmaps of 200-by-200-pixel tiles, specified by theme, scale, scene, and X and Y indexes (see Listing 1). Available members of the theme enumeration are Photo (1), Topo (2), or Relief (3). The scale enum specifies the resolution of the tile in meters per pixel (m/px). The base resolution of the tiles is 1 m/px and ranges downward to 2,048 km/px, but 256 m/px is the lowest resolution that delivers a useful image.

A scene (integer) is one of 60 Universal Transverse Mercator (UTM) zones of the earth; scenes 10 and 11 show America's West Coast, with the East Coast in scenes 17, 18, and 19. Indexes are related to the integer UTM eastings (X) and northings (Y) of the tile. Photo tiles are JPEG gray-scale images in 8-bit indexed format; topo map tiles are 24-bit RGB or 8-bit indexed GIF color images. Typical size of a TerraService GetTile method SOAP response document is about 10K for photos and 24K for topo maps. Fortunately, the Web service proxy code converts base64Encoded byte arrays to the appropriate binary encoding automatically. Also, imaging namespace members make it easy to handle JPEG, GIF, PNG, TIFF, and BMP format translation.

Draw a Photo or Map on the Form
You display photos or topo map images of reasonable size by assembling multiple tiles. The projects' 640-by-480-pixel active display area below the main form's title and menu bars requires from 12 to 20 tiles, depending on the relationship of the image's latitude/longitude centerpoint coordinates to the centerpoint of the central tile. You express the coordinates in pixels as XOffset and YOffset. Pass the centerpoint coordinates as a LatLonPt. Add that to the theme, scale, and bitmap width and height as arguments of the GetAreaFromPt Web method. The system then returns an AreaBoundingBox type. This type's members define the range of tile indexes required and the XOffset and YOffset values.

1 2 3 Next



Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home