Feature collections, Searching for features, Feature collections searching for features – Pitney Bowes MapXtreme User Manual

Page 187

Advertising
background image

Chapter 8: Working with Data

Features and Feature Collections

MapXtreme v7.1

194

Developer Guide

You can force a Load using the Load method. Changes made to the Feature are not reflected in the
underlying table (if there is one) until the Feature is saved back to the table. This is done using the
Update method, or UpdateFeature or InsertFeature. You can throw away any edits done to the
Feature object before it is saved using the DiscardEdits method.

A Feature has a schema that describes the attributes of the Feature. The Columns property
describes the schema.

Retrieving Features from a Table

A Table is a type of Feature collection. As such, the Features within the table may be enumerated
directly. For example:

VB example:

Dim ftr As Feature
For Each ftr In table
...

The default feature enumerator for a table uses an MIDataReader internally with the following
command:

command.CommandText = "Select MI_Key, * From \"" + table.Alias + "\"";

To retrieve a subset of the features in a table, use one of the Catalog.Search methods or use one of
the MICommand.ExecuteFeatureCollection methods.

Modifying Features in a Table

To modify features in a table, use one of the following methods.

Feature.Update

Table.UpdateFeature

Table.InsertFeature

Feature Collections

Feature collections are a group of Feature objects. All Features in a collection share the same
Schema (columns). The Feature collection has a schema which is the schema of all of its member
feature instances. Some Feature collections own their Features while other Feature collections
maintain references to Features.

Searching for Features

One of the most common tasks in Pitney Bowes Software’s mapping applications is to search for
features that meet certain criteria. Once you have the features you are interested in, you can carry
out further analysis, such as thematic mapping. In MapXtreme, searching for features can be done
in a number of ways: using tools, using Catalog search methods, or using SQL and the MapInfo
ADO.NET Data Provider.

The following code sample shows two ways to search for the same thing, in this case, cities in New
York.

Advertising