所有的GIS工程文件其实都是文本文件,读取并不困难,在VC中用CFile类就可以把它们打开。
关键是弄清楚工程文件本身的定义。它们一般是分节的,每节定义一组类似的信息,顺序存储。
比如ArcExplorer的工程文件,打开之后如下所示:
[ARCEXPLORER]
VERSION=1.1.383
DISPLAYOVERVIEW=0
DISPLAYSCALEBAR=0
DISPLAYEXPLORER=1
//地图定义
[MAP]
EXTENT=-178.951749890056^-66.2331255982255^91.13543813427^-4.43035202619499//全图范围
BACKCOLOR=16777215
BORDERSTYLE=0
CANCELACTION=1
SCROLLBARS=False
3D=1
LAYERCOUNT=4//层数
MAPUNITS=0
SCREENUNITS=1
SCALEBARUNITS=3
SELECTCOLOR=65535
//依次定义各层,INDEX从0开始
[MAPLAYER3]
WORKSPACE=/
BASE=0^CNTRY94.SHP^WORLD//层对应的SHP文件+层别名!!!
SYMBOL=8454143^Arial^8.25^2^0^0^1^1^53^0//层附属的符号
RENDERERTYPE=0
RENDERER=
REMOUTLINE=0
VISIBLE=0
SCALEFACTORS=0^0
MAPTIPFIELD=
ADDMATCH=^0^^^^^^^^^^^^^
[MAPLAYER2]
WORKSPACE=/
BASE=0^STATES.SHP^STATES
SYMBOL=50088976^Arial^8.25^2^0^0^0^1^53^0
RENDERERTYPE=1
RENDERERFIELD=STATE_NAME
RENDERER=Alabama:47723254^Arial^8.25^2^0^0^1^1^53^0|Alaska:48867577^Arial^8.25^2^0^0^1^1^53^0|Arizona:41058368^Arial^8.25^2^0^0^1^1^53^0|Arkansas:40799609^Arial^8.25^2^0^0^1^1^53^0|California:44166187^Arial^8.25^2^0^0^1^1^53^0|Colorado:37122706^Arial^8.25^2^0^0^1^1^53^0|Connecticut:45508470^Arial^8.25^2^0^0^1^1^53^0|Delaware:36320746^Arial^8.25^2^0^0^1^1^53^0|District of Columbia:49536261^Arial^8.25^2^0^0^1^1^53^0|Florida:38678793^Arial^8.25^2^0^0^1^1^53^0|Georgia:47181835^Arial^8.25^2^0^0^1^1^53^0|Hawaii:46740912^Arial^8.25^2^0^0^1^1^53^0|Idaho:43366858^Arial^8.25^2^0^0^1^1^53^0|Illinois:47945218^Arial^8.25^2^0^0^1^1^53^0|Indiana:50074304^Arial^8.25^2^0^0^1^1^53^0|Iowa:35524844^Arial^8.25^2^0^0^1^1^53^0|Kansas:44700960^Arial^8.25^2^0^0^1^1^53^0|Kentucky:34849742^Arial^8.25^2^0^0^1^1^53^0|Louisiana:37831554^Arial^8.25^2^0^0^1^1^53^0|Maine:36794308^Arial^8.25^2^0^0^1^1^53^0|Maryland:50099045^Arial^8.25^2^0^0^1^1^53^0|Massachusetts:41262493^Arial^8.25^2^0^0^1^1^53^0|Michigan:47525815^Arial^8.25^2^0^0^1^1^53^0|Minnesota:49257295^Arial^8.25^2^0^0^1^1^53^0|Mississippi:50021604^Arial^8.25^2^0^0^1^1^53^0|Missouri:47394781^Arial^8.25^2^0^0^1^1^53^0|Montana:39655778^Arial^8.25^2^0^0^1^1^53^0|Nebraska:47089555^Arial^8.25^2^0^0^1^1^53^0|Nevada:38174191^Arial^8.25^2^0^0^1^1^53^0|New Hampshire:42554496^Arial^8.25^2^0^0^1^1^53^0|New Jersey:37186776^Arial^8.25^2^0^0^1^1^53^0|New Mexico:41754715^Arial^8.25^2^0^0^1^1^53^0|New York:46328887^Arial^8.25^2^0^0^1^1^53^0|North Carolina:36898367^Arial^8.25^2^0^0^1^1^53^0|North Dakota:35780868^Arial^8.25^2^0^0^1^1^53^0|Ohio:43022645^Arial^8.25^2^0^0^1^1^53^0|Oklahoma:43636367^Arial^8.25^2^0^0^1^1^53^0|Oregon:47845142^Arial^8.25^2^0^0^1^1^53^0|Pennsylvania:43963495^Arial^8.25^2^0^0^1^1^53^0|Rhode Island:36415700^Arial^8.25^2^0^0^1^1^53^0|South Carolina:35553010^Arial^8.25^2^0^0^1^1^53^0|South Dakota:38762013^Arial^8.25^2^0^0^1^1^53^0|Tennessee:37870959^Arial^8.25^2^0^0^1^1^53^0|Texas:43370695^Arial^8.25^2^0^0^1^1^53^0|Utah:40353749^Arial^8.25^2^0^0^1^1^53^0|Vermont:36399338^Arial^8.25^2^0^0^1^1^53^0|Virginia:46653502^Arial^8.25^2^0^0^1^1^53^0|Washington:39159585^Arial^8.25^2^0^0^1^1^53^0|West Virginia:45236025^Arial^8.25^2^0^0^1^1^53^0|Wisconsin:38073397^Arial^8.25^2^0^0^1^1^53^0|Wyoming:46584563^Arial^8.25^2^0^0^1^1^53^0
REMOUTLINE=0
VISIBLE=0
SCALEFACTORS=0^0
MAPTIPFIELD=
ADDMATCH=^0^^^^^^^^^^^^^
[MAPLAYER1]
WORKSPACE=/
BASE=0^STATES.SHP^STATES1
SYMBOL=38618521^Arial^8.25^2^0^0^0^1^53^0
RENDERERTYPE=0
RENDERERFIELD=STATE_NAME
RENDERER=
REMOUTLINE=0
VISIBLE=1
SCALEFACTORS=0^0
MAPTIPFIELD=
ADDMATCH=^0^^^^^^^^^^^^^
[MAPLAYER0]
WORKSPACE=/
BASE=0^LAKES.SHP^LAKES
SYMBOL=4227327^Arial^8.25^2^0^0^1^1^53^0
RENDERERTYPE=0
RENDERERFIELD=STATE_NAME//渲染用的字段
RENDERER=
REMOUTLINE=0
VISIBLE=0
SCALEFACTORS=0^0
MAPTIPFIELD=
ADDMATCH=^0^^^^^^^^^^^^^
//其他辅助定义
[SCALEBAR]
MAPUNITS=0
SCREENUNITS=1
SCALEUNITS=3
[AEWEB]
AEWEBCOUNT=0
其实我们最关心的只是[MAPLAYER*]中的BASE。