=============MapInfo MIF/MID file format description=========
MapInfo MIF/MID文件格式描述
(from Appendix A of MapInfo Reference)
(摘自MapInfo參考資料的附錄a)
This appendix describes the data interchange format for MapInfo. In this
appendix, you will find information on:
這個(gè)附錄描述了MapInfo的數(shù)據(jù)交換格式。在這個(gè)附錄中,你會(huì)發(fā)現(xiàn)如下信息:
MIF File header
MIF Data Section
Pen, Brush, Symbol, and Font Codes in MIF
MID File
This versatile format allows generic data to be attached to a variety of
graphical items. It's ASCII, so it is editable, relatively easy to generate,
and works on all platforms supported by MapInfo. Perhaps the best way to
understand the MapInfo Interchange Format (MIF) is to study the sample file
at the end of this appendix in conjunction with the explanation of the file
format. You can also create samples of your own by exporting files to MIF and
then examining those files in a text editor.
這種通用的格式允許把普通的數(shù)據(jù)添加到多種的圖像元素中。MIF/MID文件采用ASCII編碼,因此它是可編輯的、相對(duì)比較容易生成、并且可以工作在MapInfo支持的所有平臺(tái)上。也許理解MIF格式的最好的方法是在讀完這篇文章后,拿著MIF格式說明,研究一個(gè)MIF文件。你也可以通過“exporting files to MIF”創(chuàng)建你自己的MIF文件,然后在文本編輯器中好好的研究它。
Mapinfo data is in two file -- the graphics reside in a .MIF file and textual
data is contained in a .MID file. The textual data is delimited data, with
one row per record and either Carriage Return, Carriage Return plus Line Feed,
or Line Feed between lines. The MIF file has two areas -- the file header and
the data section. Information on how to create MapInfo tables is in the
header; the graphical object definitions are in the data section.
MapInfo數(shù)據(jù)存在于兩種文件中--圖形數(shù)據(jù)存儲(chǔ)在.MIF文件、文本數(shù)據(jù)存儲(chǔ)在.MID文件。文本數(shù)據(jù)包括每一項(xiàng)記錄的一行和回車,回車加換行,行之間的換行。MIF文件的數(shù)據(jù)包括兩部分--文件頭和數(shù)據(jù)區(qū)。文件頭存放著如何創(chuàng)建MapInfo表格的信息;數(shù)據(jù)區(qū)存放著圖形對(duì)象的解釋。
=================MIF FILE HEADER===============
This is a description of MIF file header with optional information in square
brackets.
下面是MIF文件頭的描述(包括可選項(xiàng),下表中由“[]”括起來的部分就是可選項(xiàng))。
Version n
Charset "characterSetName"
[ DELIMITER "<c>" ]
[ UNIQUE n,n.. ]
[ INDEX n,n.. ]
[ COORDSYS... ]
[ TRANSFORM... ]
COLUMNS n
<name> <type>
<name> <type>
…
…
DATA
1.Version 版本號(hào)
The Version clause states whether you are using VERSION 1, VERSION 2, or
VERSION 300 of the format. Version 300, introduced with Mapinfo 3.0, allows
multiple-section polyline objects.
“Version”說明你使用的MIF格式的版本(VERSION 1, VERSION 2, VERSION 300中的一種)。Version 300,引自Mapinfo 3.0,允許形容由多段組成的折線對(duì)象。
2.Charset 字符集
The Charset clause specifies which character set was used to create text in
the table. For example: Specify "WindowsLatin1" to indicate that the file was
created using the Windows US & Western Europe character set; specify
"MacRoman" to specify the Macintosh US & Western Europe character set; or
specify "Neutral" to avoid converting the text into another character set.
If you are not using one of these character sets, you can determine the
correct syntax for your character set by exporting a table and examining the
.MIF file in a text editor.
“Charset”指定表(此處還不知道是哪一個(gè)表)中創(chuàng)建文本所使用的字符集。比如說:"WindowsLatin1"說明文件使用的是the Windows US & Western Europe字符集;"MacRoman"說明文件使用的是the Macintosh US & Western Europe字符集;或者,注明"Neutral"是為了防止將文本轉(zhuǎn)成了另外的字符集。如果你沒有使用其中任何一個(gè)字符集,你可以通過exporting a table和examining the .MIF file in a text editor為你的字符集指定正確的語法。
3.Delimiter 分隔符
Specify the delimiting character in quotation marks, for example:
指定引號(hào)(即""或者'')之間的分隔符,比如說:
DELIMITER ";"
The default delimiter is Tab; if you are using the default, you do not need
the DELIMITER line.
默認(rèn)的分隔符是Tab;如果你使用的是默認(rèn)分隔符,你不需要“DELIMITER”這一行。
4.Unique
Specify a number. This number refers to a database column; 3 is the third
column, 7 is the seventh column, and so forth. What happens to column in the
UNIQUE list is subtle. For example, imagine that you have a database with
highways in it. Each highway has only one name, but it might be represented
by several segments. You would put the NAME column in the UNIQUE list, while
the column containing data for the individual segments would not be in that
list. This has the effect of creating two related tables; one with names,
and one with the other attributes of the objects. This is how MapInfo's
various street maps (StreetInfo) are prepared.
指定一個(gè)數(shù)字。這個(gè)數(shù)字指定一個(gè)數(shù)據(jù)庫的列;3是第三列,7是第七列,以此類推。發(fā)生在UNIQUE指定的列上的事情是微妙的。比如說,想象一下你建立一個(gè)高速公路的數(shù)據(jù)庫。每一條路都只有一個(gè)名字,但是在每一路段中都會(huì)把名字重寫一遍。這時(shí)你會(huì)把NAME這一列放在一個(gè)單獨(dú)的表中,而包含每個(gè)路段的信息的其他列不會(huì)放在那個(gè)表中。這樣就可以創(chuàng)建兩個(gè)相關(guān)的表格:一個(gè)NAME表,一個(gè)包含其他信息。This is how MapInfo's various street maps(StreetInfo) are prepared.(這句不會(huì)翻譯)
5.Index 索引
To indicate that columns in the table are indexed, include a number (or a
comma-separated list of numbers) in the Index clause. Each number refers to
a database column; 3 is the third column, 7 is the seventh column, and so
forth. Columns in the INDEX list will have indexes prepared for them.
“Index”指明表中已經(jīng)建立索引(什么?你不知道什么是索引?自己查閱大學(xué)課本)的列,“INDEX”項(xiàng)包括一個(gè)數(shù)字(或者一系列數(shù)字)。每一個(gè)數(shù)字指定一個(gè)數(shù)據(jù)庫的列;3是第三列,7是第七列,以此類推。在“INDEX”表中指定的列會(huì)建立索引。
6.CoordSys
Specify the COORDSYS clause to note that the data is not stored in
longitude/latitude(經(jīng)/緯) form. When no COORDSYS clause is specified, data is
assumed to be stored in longitude/latitude forms. All coordinates are stored
with respect to the northeast quadrant. The coordinates for points in the
United States have a negative X while coordinates for points in Europe (east
of Greenwich) have a positive X .coordinates for points in the Northern
hemisphere have a positive Y while coordinates for points in the Southern
hemisphere have a negative Y.
指定“COORDSYS”項(xiàng)表示數(shù)據(jù)不是以經(jīng)緯度的形式存儲(chǔ)的。當(dāng)沒有指定“COORDSYS”這一項(xiàng)時(shí),數(shù)據(jù)被認(rèn)為是以經(jīng)緯度的方式存儲(chǔ)。All coordinates are stored with respectto the northeast quadrant.(這句話不知道怎么翻譯)。 在美國(guó)的點(diǎn)的x坐標(biāo)為負(fù)而在歐洲的點(diǎn)(Greenwich以東)的坐標(biāo)為正。在北半球的點(diǎn)的y坐標(biāo)為正而在南半球的點(diǎn)的坐標(biāo)為負(fù)。
Syntax 1:(不大懂,最好找兩個(gè)例子)
CoordSys Earth
[ Projection type,
datum,
unitname
[,origin_longtitude ]
[,origin_lattitude ]
[,standard_parallel_1
[,standard_parallel_2]]
[,azimuth ]
[,scale_factor ]
[,false_easting ]
[,false_northing]
[,range ]]
[ Bounds (minx,miny) (maxx,maxy) ]
Syntax 2:
CoordSys Nonearth
Units unitname
Bounds (minx,miny) (maxx,maxy)
下面是我對(duì)“Syntax 2”的理解:
<!--[if !vml]--><!--[endif]-->
7.Transform 轉(zhuǎn)換
When you have MIF files with coordinates stored with respect to the northwest
quadrant (quadrant 2), you can transform them to northeast quadrant
(quadrant 1) with a transform clause.
你可以通過“Transform”實(shí)現(xiàn)地理元素的坐標(biāo)轉(zhuǎn)換。(這句話是我自己的理解,并沒有按原文翻譯)
--------------------------------------------
| Quadrant 2: | Quadrant 1: |
| Nortwest Quadrant | Norteast Quadrant |
--------------------------------------------
| Quadrant 3: | Quadrant 4: |
| Southwest Quadrant | Southeast Quadrant |
--------------------------------------------
The transofrm clause has the following syntax:
“Transform”的用法如下:
TRANSFORM Xmultiplier, Ymultiplier, Xdisplacement, Ydisplacement
To transform quadrant 2 data into quadrant 1 data, use the following
transform clause:
如果想把第2象限的數(shù)據(jù)轉(zhuǎn)換到第一象限,可以像如下使用“Transform”:
TRANSFORM -1,0,0,0
The zeroes instruct MapInfo to ignore that parameter.
0告訴MapInfo忽略那一項(xiàng):
When you have an application which creates MIF files in quadrant 2, you can:
當(dāng)你的程序在第二象限創(chuàng)建MIF文件,你可以:
Add the TRANSFORM clause to the MIF files
Change the application so that it creates coordinates in quadrant 1
Change the application so that it adds a TRANSFORM clause to the MIF Files
8.Columns 列
Specify the number of column. Then, for each column, create a row containing
the column name, the column type, and, for character and decimal columns, a
number to indicate the width of the field. Valid column types are:
指定列數(shù)。然后,為每一列,建立一行(包括the column name、the column type、一個(gè)用來指定域長(zhǎng)度的數(shù)字--僅為character和decimal類型的列建立)用來說明其格式。有效的列類型包括:
char(width)
integer[說明:which is 4 bytes, from -2^31 to 2^31-1]
smallint[說明:which is 2 bytes, so it can only store numbers between -32767 and +32767)]
decimal (width, decimals)
float
date
logical
This is an example of the columns section of the header:
下面是mif文件頭的COLUMNS部分的一個(gè)例子:
STATE char (15)
POPULATION integer
AREA decimal (8,4)
For the database specified in this header, the MID file has three columns:
通過上面指定的數(shù)據(jù)庫,我們知道對(duì)應(yīng)的MID文件有三列:
a 15 character field that represents the STATE column,
an integer field that represents the POPULATION column,
an AREA column that consists of a decimal field with up to 8 total
and 4 character after the decimal.
列名列類型
STATEchar(15) 15位長(zhǎng)的字符串
POPULATIONINTGER整型
AREAdecimal(8,4) 一個(gè)最長(zhǎng)8位、小數(shù)點(diǎn)后有4位的小數(shù)
=================MIFDATASECTION======================
The data section of the MIF file follows the header and must be introduced
with DATA on a single line:
MIF文件的“data”部分緊跟著文件頭并且必須由一個(gè)單行“DATA”引出:
DATA
The data section of the MIF file can have any number of graphical primitives,
one for each graphic object. MapInfo matches up entries in the MIF and MID
files, associating the first object in the MIF file with the first row in the
MID file, the second object in the MIF file with the second row in the MID
file, and so on.
MIF文件的數(shù)據(jù)部分可以包括任意長(zhǎng)度的圖形變量,其中每一項(xiàng)對(duì)映著一個(gè)圖形對(duì)象。MapInfo自動(dòng)使MIF和MID文件里面的每一條相一致,比如說:MIF文件的第一個(gè)object對(duì)應(yīng)著MID文件的第一行,MIF文件的第二個(gè)object對(duì)應(yīng)著MID文件的第二行。
When there is no graphic object corresponding to a particular row in the MID
file, a "blank" object (NONE) must be written as a place holder in the
corresponding place in the MIF file.
當(dāng)MIF文件中沒有圖形對(duì)象與MID文件的行對(duì)應(yīng)時(shí),一個(gè)“blank”對(duì)象必須寫在MIF文件中相應(yīng)的位置。
NONE
The graphical objects that can be specified are:
圖形對(duì)象可以被指定為如下幾種類型:
point //點(diǎn)
line//線
polyline //折線
region//區(qū)域
arc//弧
text//文本
rectangle//矩形
rounded rectangle//圓矩(即4個(gè)角做“鈍化”處理的矩形)
ellipse//橢圓
(下面是針對(duì)每一種類型的說明,很簡(jiǎn)單,我就不翻譯了)
--------point---------
A point object takes two parameters; an X coordinate and a Y coordinate. As an
option, specify the symbol that represents the point. Symbols are designated
by numbers. If you omit the SYMBOL clause, the current symbol is used.
POINT x y
[ SYMBOL (shape, color, size) ]
MapInfo 4.0 also supports two variations on the SYMBOL clause; see Symbol
discussion later in this appendix.
-------line----------
A line object requires four parameters; an X and a Y coordinate for each end
point. As an option, specify a pen type. When no pen type is specified,
the current pen type is used.
LINE x1 y1 x2 y2
[ PEN (width, pattern, color) ]
--------polyline-----------
A polyline object consists of one or more sections. If the polyline has more
than one section, include the MULTIPLE keyword, followed by the number of
sections. For each section, specify a numpts argument (which indicates the
number of nodes in that section), followed by an x/y coordinate pair for each
node. Use the optional PEN clause (described later in this appendix) to
specify the line style. If you include the optional SMOOTH keyword, the
polyline is smoothed.
PLINE [ MULTIPLE numsections ]
numpts1
x1 y1
x2 y2
…
…
[ numpts 2
x1 y1
x2 y2 ]
…
…
[ PEN (width, pattern, color) ]
[ SMOOTH ]
-----------region------------
A region object consists of one or more polygons(多邊形). Specify the number of
polygons through the numpolygons argument (immediately after the REGION
keyword). For each polygon, specify a numpts argument (which indicates the
number of nodes in that polygon), followed by an x/y coordinate pair for each
node. Use the optional PEN and BRUSH clauses (described later in this
appendix) to specify the object's style. Use the optional CENTER clause to
define the object's centroid explicitly.
REGION numpolygons
numpts1
x1 y1
x2 y2
…
…
[ numpts 2
x1 y1
x2 y2
…
…
[ PEN (width, pattern, color) ]
[ BRUSH (pattern, forecolor, backcolor) ]
[ CENTER x y ]
---------arc------------
An arc requires the diagonally opposite corners of its bounding rectangle
and the beginning (a) and ending (b) angles of the arc in degrees, moving
counter-clockwise with zero at three o'clock. As an option, specify the arc
type. (An arc specifies a section of an ellipse, the corners of which are
determined by the bounding rectangle.)
ARC x1 y1 x2 y2
a b
[ PEN (width, pattern, color) ]
-----------text--------------
A text object consists of a text string, up to 255 characters long. To make
the text string wrap onto multiple lines, insert the characters n within the
textstring argument (e.g. "First line nSecond line nThird line". The x1,
y1, x2, and y2 arguments specify the location of the text on the map.
Spacing can be 1.0 (single spacing), 1.5, or 2.0 (double spacing). Use the
Font clause (described later in this chapter) to control the typeface, etc.
TEXT "textstring"
x1 y1 x2 y2
[ FONT... ]
[ Spacing {1.0 | 1.5 | 2.0} ]
[ Justify {Left | Center | Right } ]
[ Angle text_angle ]
[ Label Line {simple | arrow} x y ]
------------rectangle-----------------
A rectangle requires the coordinates of the diagonally opposite corners. As
an option, specify pen and brush types.
RECT x1 y1 x2 y2
[ PEN (width, pattern, color) ]
[ BRUSH (pattern, forecolor, backcolor) ]
------------rounded rectangle------------------
A rounded rectangle requires the coordinates of the diagonally opposite
corners and the degree of rounding (a). As an option, specify pen and brush
types. Degree of rounding is expressed in coordinate units.
ROUNDRECT x1 y1 x2 y2
a
[ PEN (width, pattern, color) ]
[ BRUSH (pattern, forecolor, backcolor) ]
------------ellipse---------------------
An ellipse object requires the coordinates of the diagonally opposite corners
of its bounding rectangle. As an option, specify pen and brush types.
ELLIPSE x1 y1 x2 y2
[ PEN (width, pattern, color) ]
[BRUSH (pattern, forecolor, backcolor) ]
================================================================
PEN STYLES
The Pen clause specifies the width, pattern, and color of a linear object,
such as a line, polyline or arc. The Pen clause has the following syntax:
PEN (width, pattern, color)
Width is a number from zero to 7. Note: zero-width lines are invisible.
Color is an integer, representing a 24-bit RGB color value.
Pattern is an integer from 1 to 77; patter number 1 is invisible.
Due to a limitness of a text file patterns cannot be shown, however they are
available in MapInfo Refernce book. More info can be obtained by contacting
MapInfo. (
http://www.mapinfo.com on internet)
===============================================
BRUSH STYLES
Brush specifies the pattern, foreground color, and background color of a
filled object, such as a circle or region. The Brush clause has the following
syntax:
BRUSH (pattern, forecolor [, backcolor ] )
The forecolor and backcolor arguments are both integers, representing 24-bit
RGB color values.
Pattern is a number from 1 to 71. Note: Pattern number 1 is "no fill," and
pattern number 2 is a solid fill. Pattern numbers 9-11 are reserved.
Tip: To specify a transparent fill style, use pattern number three or larger,
and omit the backcolor argument. For example: Brush( 5, 255 )
Due to a limitness of a text file patterns cannot be shown, however they are
available in MapInfo Refernce book. More info can be obtained by contacting
MapInfo. (
http://www.mapinfo.com on internet)
===============================================
SYMBOL STYLES
The Symbol clause specifies the appearance of a Point object. There are
three different forms of the Symbol clause, described below.
Symbol Clause -- MapInfo 3.0 Syntax
The Symbol clause specifies the appearance of a Point object. There are
three different forms of the Symbol clause. To specify a symbol style using
"Old MapInfo Symbols" (the symbols that were used in earlier version of
MapInfo), use the following syntax:
SYMBOL (shape, color, size)
The shape argument is an integer value, 31 or larger; 31 represents a blank
symbol (i.e. the object will not be visible). The standard set of symbols
includes symbols 32 through 67, inclusive, but the user can customize the
symbol set by using the Symbol application.
The color argument is an integer representing a 24-bit RGB color value.
The size argument is an integer from 1 to 48, representing a point size.
The following table lists the default symbols provided with Mapinfo:
Due to a limitness of a text file symbols cannot be shown, however they are
available in MapInfo Refernce book. More info can be obtained by contacting
MapInfo. (
http://www.mapinfo.com on internet)
=================================================
Symbol Clause -- TrueType Font Syntax
To specify a symbol style based on a character from a TrueType font, use
the following syntax:
SYMBOL (shape, color, size, fontname, fontstyle, rotation)
The fontstyle argument is an integer that controls settings such as Bold.
The following table lists the values you can use as fontstyle.
--------------------------------------------
fontstyle value Effect on Symbol style
--------------------------------------------
0 Plain text
1 Bold text
16 Black border around symbol
32 Drop shadow
256 White border around symbol
--------------------------------------------
To specify two or more style attributes, add the values from the lef column.
For example, to specify Bold and Drop Shadow, use 33.
The rotation argument is a floating-point number, representing a rotation
angle, in degrees.
==============================================
Symbol clause - Custom Bitmap File Syntax
To specify a symbol style based on a character from a TrueType font, use the
following syntax:
SYMBOL (filename, color, size, customstyle)
The filename argument is a text string that identifies a bitmap file (e.g.
"Arrow.BMP" in the CustSymb directory.
The customstyle argument is an integer that controls whether color and
background attributes are used. The following table lists the values
you can use as customstyle:
-----------------------------------------
customstyle value Effect on Symbol style
-----------------------------------------
0 Both the Shadow Background setting and the
Apply Color setting are off; symbol appears
in default states. White pixels in the bitmap
appear transparent, allowing whatever is
behind the symbol to show through.
1 The Show Background setting is on; white
pixels in the image are opaque.
2 The Apply Color setting is on; non-white
colors in the image are replaced with the
Symbol's color value.
3 Both Show Background and Apply Color settings
are on.
====================================================
FONT STYLES
The Font clause specifies the appearance (typeface, color, etc.) or text
objects. The Font clause has the following syntax:
FONT ("fontname", style, size, forecolor [, backcolor] )
Fontname in double quotation marks is the typeface to be displayed. Style is
the text attribute of the typeface as shown in the following table. Size
must be 0 in a MIF file, because each text object on a Map is attached to
the map itself (thus the text size changes as you zoom in or out). Forecolor
is an integer representing a 24-bit RGB color. The background color is
optional; if you include it, MapInfo fills the are behind the text with the
color you specify.
--------------------------------------
style value Effect on Font Appearance
--------------------------------------
0 Plain 1 Bold
2 Italic 4 Underline
16 Outline (only supported on the Macintosh)
32 Shadow 256 Halo
512 All Caps 1024 Expanded
--------------------------------------
To specify two or more style attributes, add the values from the left column.
For example, to specify Bold and All Caps, use 513.
====================================================
COLORS
Colors are often defined in relative concentractions of red, green, and blue.
Each color is a number from 0 to 255, inclusive; the RGB value of a color is
calculated by the following formula:
(red * 65536) + (green * 256) + blue
These are some often used colors and their values:
Red: 16711680
Green: 65280
Blue: 255
Cuan: 65535
Magenta: 16711935
Yellow: 16776960
Black: 0
==========================================================
=====================MID FILE=================
The MID file contains data, one record of data per row, delimited by the
character specified in the delimiter statement. The default delimiter is
Tab. Each row in the MID file is associated with a corresponding object in
the MIF file; first row with first object, second row with second object.
If delimiter character is included as part of the data in a field, enclose
the field in quotation marks.
The MID file is an optional file. When ther is no MID file, all fields are blank.