Grid classes, Code sample: adding a grid image to a map, Code sample: retrieving data from a grid map – Pitney Bowes MapXtreme User Manual

Page 319

Advertising
background image

Chapter 17: Working with Rasters and Grids

Grid Images

MapXtreme v7.1

326

Developer Guide

Vertical Mapper Continuous Grids

1

2

(*.grd, .*grc)

Additional grid formats may be supported on a system if a custom grid handler is installed.

Grid Classes

The main classes for grid images are MapInfo.Raster.GridInfo, GridRead,
GridCreatorFromFeatures, GridInflectionCalculator and HillShadeWrite. GridInfo and GridRead are
like RasterInfo and RasterRead, in this case, provide the ability to get information about a grid file.
Grids are created for a layer of data points using GridCreatorFromFeatures. GridInflectionCalculator
is used to set inflection values and colors. HillShadeWrite allows you to add or alter relief shading to
the grid. Many of the properties of a grid are inherited from RasterInfo, including the image class,
coordinate system, raster control points and minimum bounding rectangle (MBR).

Code Sample: Adding a Grid Image to a Map

Adding a grid image to a map is the same as adding any other layer.

C# example:

Table MyTable = Session.Current.Catalog.OpenTable("MyGrid.tab");
FeatureLayer MyLayer = new FeatureLayer(MyTable);
MyMap.Layers.Add(MyLayer);

VB example:

Dim MyTable As Table = _ Session.Current.Catalog.OpenTable("MyGrid.tab")
Dim MyLayer As FeatureLayer = New FeatureLayer(MyTable)
MyMap.Layers.Add(MyLayer)

Code Sample: Retrieving Data from a Grid Map

This example shows how to open and read information from a grid file.

VB example:

Public Shared Sub MapInfo_Raster_GridRead(ByVal strGridFilename _
As String)

Dim strHillshadeFilename As String = _
MapInfo.Raster.GridRead.DefaultHillshadeFilename(strGridFilename)
Dim session As ISession

session = MapInfo.Engine.Session.Current
Dim gridread As GridRead = New GridRead(strGridFilename,_

strHillshadeFilename)

Console.WriteLine(gridread)
End Sub

1.

Can be displayed as either grid or raster. The .TAB file determines whether the image should be drawn
using the grid handler or the raster handler.

2.

Not multi-thread safe.

Advertising