[ ] MapXtreme .Net |
MapInfo MapXtreme for .Net Microsoft .Net, -.
MapXtreme Developers Reference
MapXtreme Version 8.0 Developer Guide
, ..
Tools -> Choose ToolBox Items...
private void Form1_Load(object sender, EventArgs e)
{
addrectangleToolStripButton1.MapControl = mapControl1;
....
}
, , ! ?
var layerTemp = mapControl1.Map.Layers["wldcty25"];
LayerHelper.SetInsertable(layerTemp, true);//
LayerHelper.SetEditable(layerTemp, true); //
mapControl1.Map.Layers.Move(lastPosition, nextPosition);
. , / MapXtreme. .
SimpleLineStyle border;//
border= new SimpleLineStyle(< MapXtreme>, < >, < >)
SimpleInterior interior;//
interior = new SimpleInterior(< >, < >,< >)
AreaStyle polygon;//
polygon = new AreaStyle(border, interior);
SimpleLineStyle line;//
line = new SimpleLineStyle(< MapXtreme>, < >, < >)
BasePointStyle point;//
point = new SimpleVectorPointStyle(< >, < >, < >)
CompositeStyle compStyle;//
compStyle = CompositeStyle(polygon, line, null, point);
FeatureOverrideStyleModifier fosm;
fosm = new FeatureOverrideStyleModifier(parStyleName, parStyleAlias, compStyle);
myLayer.Modifiers.Append(featureOverrideStyleModifier);
Feature feature = null;
feature = new Feature(< >, compStyle);
//
DPoint[] pts1 = new DPoint[5];
pts1[0] = new DPoint(-20, 10);//
pts1[1] = new DPoint(10, 15);
pts1[2] = new DPoint(15, -10);
pts1[3] = new DPoint(-10, -10);
pts1[4] = new DPoint(-20, 10);
//
DPoint[] pts2 = new DPoint[5];
pts2[0] = new DPoint(-40, 50);
pts2[1] = new DPoint(60, 45);
pts2[2] = new DPoint(65, -40);
pts2[3] = new DPoint(25, 20);
pts2[4] = new DPoint(-40, 50);
//LineString DPoint
LineString lineString1 = new LineString(coordSys, pts1);
LineString lineString2 = new LineString(coordSys, pts2);
//Ring coordSys LineString
Ring ring1 = new Ring(coordSys, lineString1);
Ring ring2 = new Ring(coordSys, lineString2);
Ring[] rng1 = new Ring[2];
rng1[0] = ring2;
rng1[1] = ring1;
//MultiPolygon Ring
MultiPolygon multiPol = new MultiPolygon(coordSys, rng1);
//Curve coordSys LineString
Curve curve4 = new Curve(coordSys, lineString1);
Curve curve5 = new Curve(coordSys, lineString2);
Curve[] crv = new Curve[2];
crv[0] = curve5;
crv[1] = curve4;
//MultiCurve Curve
MultiCurve mc = new MultiCurve(coordSys, crv);
CoordSys oordSys= mapControl1.Map.GetDisplayCoordSys();
CoordSys cs = Session.Current.CoordSysFactory.CreateCoordSys("EPSG:3395", CodeSpace.Epsg);
mapControl1.Map.SetDisplayCoordSys(cs);
mapControl1.Map.RasterReprojectionMethod = ReprojectionMethod.Always;
/**
*ReprojectionMethod
* None = 0, //
* Always = 1,//
* Optimized = 2// ,
*
*/
private string CreateTabFile(List parImageCoordinate)//
{
NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;
var ext = m_fileName.Split(new Char[] { '.' });
var fileExt = ext[ext.GetLength(0) - 1];
string fileTabName = m_fileName.Substring(0, m_fileName.Length - fileExt.Length) + "TAB";
StreamWriter sw = new StreamWriter(fileTabName);
string header = "!table\n!version 300\n!charset WindowsCyrillic\n \n";
sw.WriteLine(header);
string definitionTables = "Definition Table\n ";
definitionTables += "File \"" + m_fileName + "\"\n ";
definitionTables += "Type \"RASTER\"\n ";
for (var i = 0; i < parImageCoordinate.Count; i++)
{
definitionTables += "(" + parImageCoordinate[i].Longitude.ToString("N", nfi) + "," + parImageCoordinate[i].Latitude.ToString("N", nfi) + ") ";
definitionTables += "(" + parImageCoordinate[i].PixelColumn.ToString() + "," + parImageCoordinate[i].PixelRow.ToString() + ") ";
definitionTables += "Label \" " + (i + 1).ToString() + " \",\n ";
}
definitionTables = definitionTables.Substring(0, definitionTables.Length - 4);
definitionTables += "\n ";
definitionTables += "CoordSys Earth Projection 1, 104\n ";
definitionTables += "Units \"degree\"\n";
sw.WriteLine(definitionTables);
string metaData = "begin_metadata\n";
metaData += "\"\\IsReadOnly\" = \"FALSE\"\n";
metaData += "\"\\MapInfo\" = \"\"\n";
string hash;
using (MD5 md5Hash = MD5.Create())
{
hash = GetMd5Hash(md5Hash, m_fileName);
}
metaData += "\"\\MapInfo\\TableID\" = \"" + hash + "\"\n";
metaData += "end_metadata\n";
sw.WriteLine(metaData);
sw.Close();
return fileTabName;
}