SDK Programming interface details

The programming interface consists of the following functions, callable from C or C++. These allow your application to communicate with a running instance of Memory-Map, extract information and manipulate overlay data.

 

MMAPI_API int MM_Start(bool run_mmnav);

// Initialize the library. If run_mmnav is true, launch MMNav if it is not already running.

 

MMAPI_API int MM_End(bool close_mmnav);    

// Closes the library. If close_mmnav is true, MMNav is closed.

 

#define MMAPI_MINBUILDNUMBER 522

// This is the minimum Memory-Map build number that supports this version of the API.

// However, a subset of the API will work with earlier builds, so don't quit if you are

// prepared to handle NOT_IMPLEMENTED errors.

 

MMAPI_API int MM_GetVersion(int version[8]);

// Returns the version, the build number,

// and the serial number

 

MMAPI_API int MM_ShowWindow(int cmd);     

// Control the MMNav main window. cmd is SW_SHOW, SW_MINIMIZE, etc.

 

MMAPI_API int MM_SetWindow(int left, int top, int right, int bottom);     

// Set the position and size of the main MMNav window.

 

MMAPI_API int MM_SetWindow(double max_lat, double min_lat, double max_lon, double min_lon);

// MMNav zooms to the approximate area requested, loading an

// appropriate map, if needed. If max_lat==min_lat and

// max_lon==min_lon, then this point is placed at the

// center of the window in the largest available scale

// map. Note: The zoom level is limited to factors of two, and

// the size and shape of the window are not changed by this function.

 

struct MM_position_data2

{

double lat, lon;

float course; // degrees

float speed; // knots

float altitude; // meters

float heading; // degrees (if not known, set to a value > 360)

float rate_of_turn; // degrees per minute, clockwise

unsigned int time; // seconds since Jan 1, 1970.

bool valid; // false if there is no GPS update for 5 seconds

};

 

MMAPI_API int MM_GetCurrentPositionStruct(struct MM_position_data2 *pos);

// Returns the most recent position received from GPS.

 

MMAPI_API int MM_SetCurrentPositionStruct(struct MM_position_data2 *pos);

// Sets the current position object.

//  NB. The GPS in MMnav should be set to "None" when using this function.

//  The if valid is non-zero, the icon is shown in red, and the central dot

//  alternates on and off with each call. If valid is zero, the icon is shown

//  in grey.

 

MMAPI_API int MM_ObjFind(const TCHAR *name, int type, HANDLE *h);

// Returns a handle of an object with matching name and type

//  Wildcards (* and ?) are allowed in the name. h is an in/out

//  parameter: Call with h==NULL first time, then with the returned

//  handle, and so on until the return value is NULL. The

//  objects are returned in the reverse order of creation,

//  i.e., the most recently created object is returned

//  first. Type is MM_OT... values below.

 

MMAPI_API int MM_ObjGetType(HANDLE h, int *type);

// returns one of the following in *type.

#define MM_OT_UNKNOWN -1

#define MM_OT_ANY -1

#define MM_OT_MARKWP 1

#define MM_OT_ROUTE 2

#define MM_OT_TRACK 4

#define MM_OT_POSITION 8

#define MM_OT_CHART 16

#define MM_OT_TEXT 32

 

MMAPI_API int MM_ObjGetName(HANDLE h, TCHAR *name, int max_chars);

// Returns the name of the object;

 

MMAPI_API int MM_ObjDelete(HANDLE h);

// Object is permanently deleted from mmnav, even if it is locked

//  NB. When you delete a Route object, all the waypoints that

//  are not locked are are not part of any other routes are

//  also deleted.

 

MMAPI_API int MM_ObjRename(HANDLE h, const TCHAR *name);

// Rename object.

 

MMAPI_API int MM_ObjLock(HANDLE h, bool locked);

// Control whether user can change/delete the object.

 

MMAPI_API int MM_ObjVisible(HANDLE h, bool visible);

// Control whether object is visible or hidden.

 

MMAPI_API int MM_ObjGetCategory(HANDLE h, TCHAR *category, int max_chars);

// Returns the category of the object;

 

MMAPI_API int MM_ObjSetCategory(HANDLE h, const TCHAR *category);

// Change the object's category

 

MMAPI_API int MM_AddIcon(const TCHAR *bmp_filename, int id);

// Adds the mark/WP icon with the specified ID.

// This just registers the icon image. Use MM_MarkCreate to create a mark that uses the icon.

// The file must be a BMP 32x32 pixels, 16-color.

// Use a full pathname, not a relative path.

// The ID must be > 100.

 

MMAPI_API int MM_RemoveIcon(int id);

// Remove the icon with that id. Any marks that use this icon default

// to a plain dot.

 

MMAPI_API int MM_MarkCreate(const TCHAR *name, double lat, double lon, int icon_id, HANDLE *h);

// Create a new mark / waypoint. The icon_id is one of the mm_smbl values below, or an icon id

//  defined with MM_AddIcon()

 

MMAPI_API int MM_MarkMove(HANDLE h, double lat, double lon);

// Change the position of a mark / waypoint

 

MMAPI_API int MM_MarkGetPosition(HANDLE h, double *lat, double *lon);

// Return the lat/lon of the mark / waypoint

 

MMAPI_API int MM_MarkLinkFile(HANDLE h, const TCHAR *filename);

// Set the mark's HotSpot link to the given filename.

 

MMAPI_API int MM_MarkGetLinkFile(HANDLE h, TCHAR *filename, int max_chars);

// Returns the full path of the linked filename

 

MMAPI_API int MM_MarkSetIcon(HANDLE h, int id);

// Change the mark's symbol icon.

 

MMAPI_API int MM_MarkSetRadius(HANDLE h, float radius, int alarm_type);

// Radius in meters, alarm_type is one of:

//  0=>no circle shown 1=>show circle with no alarm (grey),

//  2=>proximity alarm (red), 3=>anchor alarm (green)

 

MMAPI_API int MM_MarkSetComment(HANDLE h, const TCHAR *comment);

// Set the mark's comment field

 

MMAPI_API int MM_RouteCreate(COLORREF color, HANDLE *h);

// Creates an empty route. Color is ignored in the current version.

// the handle is returned in h

 

MMAPI_API int MM_RouteAdd(HANDLE hRoute, HANDLE hMark);

// Adds the WP (created with MM_MarkCreate) to the route.

 

MMAPI_API int MM_RouteGetWP(HANDLE hRoute, int i, HANDLE *h);

// Returns waypoint handle at position i in the route

//  i==0 is the first WP. h is returned NULL if i is >=

// the number of WP.

 

MMAPI_API int MM_TrackCreate(TCHAR *name, COLORREF color, bool closed_polygon, HANDLE *h);

// Creates an empty track

 

MMAPI_API int MM_TrackAdd(HANDLE hTrack, int n, double *lat, double *lon,

  unsigned int *times, float *altitude);

// Adds n points to the end of the track.

//  time is in seconds since Jan 1, 1970.

//  time and/or altitude may be null.

 

MMAPI_API int MM_TrackGetNumPoints(HANDLE hTrack, int *n);

// returns via n the number of points in the track

 

MMAPI_API int MM_TrackGetPoints(HANDLE hTrack, int start, int n,

double *lat, double *lon, unsigned int *times, float *altitude);

// returns n track data points, starting from the zero-based index 'start'

// times and/or altitude pointers may be NULL

 

MMAPI_API int MM_SetLineStyle(HANDLE hTrackOrRoute, int width, int style, COLORREF col, int transparency);

// Set the line drawing attributes

//   width: 0 (thin) 1 (normal) 2 (thick) 3 (very thick)

//   style:   Solid = 0, Dash = 1, Dot = 2, DashDot = 3, DashDotDot = 4,

//  color:   RGB value

//   transparency = 0 (Solid) ... 4 (Faint)

// (Style and transparency are ignored on Windows Mobile)

 

MMAPI_API int MM_PosnCreate(const TCHAR *name_mmsi, HANDLE *h);

// Create a tracked target position

// The name given when the object is created can be used to Find it, even

// after it has been renamed

 

MMAPI_API int MM_PosnDetails(HANDLE h, const TCHAR *name, const TCHAR *details, const TCHAR *category);

// Set the name and cursor popup details

 

MMAPI_API int MM_PosnUpdate(HANDLE h, unsigned int time, double lat, double lon, double altitude,

double course, double speed, double heading, double rate_of_turn,

COLORREF color, const TCHAR *status);

// Update the Position object

 

MMAPI_API int MM_GetCurrentPositionObj(HANDLE *h);

// Returns the handle to the current position object.

 

MMAPI_API int MM_SetPosnPolygon(HANDLE h, int num_points, int *xy_array);

// Set the true size and shape of the vehicle in meters. The outline of the vehicle is shown

// when the map is zoomed in to a sufficiently detailed scale.

// The xy_array is [ x0, y0, x1, y1, ... ]. x and y coordinates are measured

// from the position sensor.

// The Y axis points ahead, and the X axis points to the right of the vehicle.

 

struct MM_NavigationInfo

{

HANDLE nav_wp; // NULL if no nav windows are shown

HANDLE nav_route; // NULL in "Goto WP" mode

double to_lat;

double to_long;

float distance; // NM

float bearing;

float crosstrack; // NM, +ve => turn R, -ve => turn left

float closing_velocity; // knots

TCHAR to_name[16]; // Next Waypoint name (truncated)

};

 

MMAPI_API int MM_GetNavigationInfo(MM_NavigationInfo *data);

// Get information for guidance to a waypoint

 

MMAPI_API int MM_SetNavigationObj(HANDLE hWPorRoute);

// Display navigation windows in MMNav

 

 

// All functions return one of the following Error codes

#define MMERR_OK 0

#define MMERR_OLDER_MMNAV   1  // Version of MMNav application is too old

#define MMERR_API_INUSE 2

#define MMERR_LAUNCH_FAILED 3

#define MMERR_BAD_HWND 4

#define MMERR_NO_MAP 5

#define MMERR_HANDSHAKE_ERR 6

#define MMERR_TIMEOUT 7

#define MMERR_FILE_ERR 8

#define MMERR_STRING_TRUNC  9

#define MMERR_LICENSE 10

#define MMERR_NOT_IMPLEMENTED 11

#define MMERR_NOT_AVAILABLE 12

#define MMERR_BAD_HANDLE    13

#define MMERR_FAILED        14

#define MMERR_BAD_INPUT     15

#define MMERR_NOT_RUNNING 16