Sample: cotw (center of the world) data provider, Sample: cotw (center of the, World) data provider – Pitney Bowes MapXtreme User Manual

Page 500

Advertising
background image

Appendix D: Extensible Data Providers

Sample: COTW (Center of the World) Data Provider

MapXtreme v7.1

507

Developer Guide

The utilities are included in the MapInfo.OGC namespace. It implements data readers and writers for
well-known text and well-known binaries and supports both big endian and little endian byte
ordering.

Key implementations

A requirement of data that is to be accessed by a MapXtreme data provider is that every feature has
a key. We provide in this SDK two common key implementations: integer key and string key.

If your data is integer or string-based, you can skip the implementation of a key from the IKey
interface, and use one of these.

Sample: COTW (Center of the World) Data Provider

The "Center of the World" Data Provider is a very simple, contrived example used to illustrate how to
put a data provider implementation together. This data provider manages a table with a single row
containing a spatial point at longitude/latitude (0,0).

A logical place to start a new extensible data provider implementation is with the class implementing
IDataProvider. This class is required to be implemented as a singleton instance so that all
references to it (for example, from ITableDefinition and IDataSourceDefinition) uniquely resolve to
the same instance. Here's the beginning portion from the sample implementation:

using System;
using MapInfo.Engine;
using MapInfo.Data.Provider;

namespace COTW
{
public sealed class COTWDataProvider :
{
private static string PROVIDER_NAME = "Center of the World
Sample Extensible Data Provider for MapXtreme";
private static COTWDataProvider m_singleton = null;

private COTWDataProvider(string name)
: base(name)
{
}

public static COTWDataProvider GetInstance()
{
if (m_singleton == null)
m_singleton = new COTWDataProvider(PROVIDER_NAME);
return m_singleton;
}

}

}

Advertising