Map sources can be added in a way of adding plugin dll into Terra Incognita folder. Plugins are .NET class libraries with implemented interface TerraIncognita.IMapSourcePlugin or TerraIncognita.IMapSavePlugin. Those interfaces are defined in TerraIncognita.exe which must be included in project references.
~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Drawing;
using System.Collections.Generic;
namespace ExampleMaps
{
public class MyMapSource : TerraIncognita.IMapSourcePlugin
{
int m_currentZoomLevel = 0;
public string Name //shown in menu with map sources { get { return "map example"; } } public string Description //used as tooltip in menu map sources { get { return "Test map"; } } public string Group //group name if map used with layers (used in menu map sources) { get { return null; } } public string Copyright { get { return null; } } public string[] IsLayerOnMaps //names of maps where can be used as a transparent layer { get { return null; } } public string[] LevelNames { get { return new string[] { "1km", "500m", "250m", "120m", "60m", "30m" }; } } public float[] LevelResolutions { get { return new float[] { 1000, 500, 250, 120, 60, 30 }; } } public string MapProjection { get { return "Latitude/Longitude"; } } public string ProjectionParameters { get { return null; } } public TerraIncognita.stReferencePoint[] ReferencePoints { get { int maxx, maxy; bool fg; GetProjectionTilesCount(out maxx, out maxy, out fg); TerraIncognita.stReferencePoint[] pts = new TerraIncognita.stReferencePoint[2]; pts[0].x = 0; pts[0].y = 0; pts[0].longitude = -180.0; pts[0].latitude = 90.0; pts[1].x = maxx * TileSize.Width; pts[1].y = maxy * TileSize.Height; pts[1].longitude = 180.0; pts[1].latitude = -90.0; return pts; } } //size of map in tiles count, fullGlobe=true if map can be scrolled infinitely around public void GetProjectionTilesCount(out int width, out int height, out bool fullGlobe) { width = 3 * (1 << m_currentZoomLevel); height = 5 * (1 << m_currentZoomLevel); fullGlobe = false; } //crop size used to limit part of map to be shown public void GetTilesCropFrame(out int left, out int top, out int right, out int bottom) { left = 0; top = 0; right = 0; bottom = 0; } public int CurrentLevel { get { return m_currentZoomLevel; } set { m_currentZoomLevel = value; } } public TerraIncognita.Size TileSize //tile size in pixels width and height (usually 256,256) { get { return new TerraIncognita.Size((m_currentZoomLevel + 1) * 30, (m_currentZoomLevel + 1) * 20); } } public bool Start() //code called before first use of map, return false if map can't be used { return true; } public void Finish() //code called before another map source is selected { } public System.Drawing.Bitmap GetTileBitmap(int x, int y, int level, TerraIncognita.delegateTileDownloaded callback) { Bitmap bmp = new Bitmap(TileSize.Width, TileSize.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Graphics gr = Graphics.FromImage(bmp); gr.DrawLine(Pens.Red, 30, 30, TileSize.Width - 30, TileSize.Height - 30); gr.DrawRectangle(Pens.LightPink, 0, 0, TileSize.Width - 1, TileSize.Height - 1); Font fnt = new Font("sansserif", 8f); gr.DrawString("x:" + x + " y:" + y, fnt, Brushes.DarkRed, 10, 10); gr.DrawString(LevelNames[m_currentZoomLevel], fnt, Brushes.DarkRed, 10, 30); gr.Dispose(); fnt.Dispose(); return bmp; //callback should be called when null returned } public Dictionary<string, object> Settings { get { return null; } set { } }
}
}
~~~~~~~~~~~~~~~~~~~~~~