Mapinfo development in. net: layer read/write (2)

Source: Internet
Author: User


After MapControl is placed on the form, you can add layers in the form of code. You can add layers to MapControl. map attributes to add a layer. This attribute is a Map layer. You can attach a Map in three ways: MapControl. map is a Map type, indicating a Map. There is a Load method for this type. Three types of maps are supported: Geoset, Workspace, and Tables, because the Load method is an abstract class of MapLoader, class MapGeosetLoader, MapWorkSpaceLoader, and MapTableLoader represent three maps respectively. These loaders are constructed in string type, namely, three file paths, and the extension of the three files is *. gst ,*. mws and *. tab.
Now draw a layer with two groups of broken lines named test. tab.
 

First, analyze the two groups of broken lines. The first group of broken lines consists of five points, and the second group of broken lines consists of three points. The Table corresponding to this layer should have two rows of data.
 

The following code queries layer points:
Catalog Cat = MapInfo. Engine. Session. Current. Catalog;
Table tblTemp = Cat. GetTable ("");
DataTable dt = new DataTable ();
MIDataReader dr = tblTemp. ExecuteReader ();
Dt. Load (dr );
DataGridView1.DataSource = dt;
 
For (int I = 0; I <dt. Rows. Count; I ++)
{
MultiCurve mc = dt. Rows [I]. ItemArray [0] as MapInfo. Geometry. MultiCurve;
Curve cur = mc [0];
Foreach (var v in cur. SamplePoints ())
{
MessageBox. Show ("X:" + v. x + "Y:" + v. y );
}
}
Query using ADO. NET:
MIConnection con = new MIConnection ();
MICommand cmd = con. CreateCommand ();
Cmd. CommandText = "select * from ";
Con. Open ();
MIDataReader dr = cmd. ExecuteReader ();
While (dr. Read ())
{
MapInfo. Geometry. MultiCurve mc = dr. GetValue (0) as MapInfo. Geometry. MultiCurve;
Curve cur = mc [0];
Foreach (var v in cur. SamplePoints ())
{
MessageBox. Show ("X:" + v. x + "Y:" + v. y );
}
}
Dr. Close ();
Con. Close ();
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.