lizongbo at 618119.com 工作,生活,Android,前端,Linode,Ubuntu,nginx,java,apache,tomcat,Resin,mina,Hessian,XMPP,RPC

2008年01月25日

用JavaScript为OpenLayers.Marker的加上单击显示详细信息的功能

Filed under: Java — 标签:, , — lizongbo @ 09:09

 代码实现的效果为:

用于显示时,在地图上标记出对应的坐标,单击该标注时显示详细信息,再单击标注,隐藏详细信息,

/*
标记地区
参数 deleteEnable 是否允许删除
adminCode 行政区号,6位长
alarmLevel 图标级别

alarmMsg 消息
*/
function lzbmarkArea(deleteEnable, adminCode,alarmLevel,alarmMsg){
var isSelected=0;
var lonLatx=112;
var lonLaty=22.5;
var adminName=””;
if(!alarmMsg){alarmMsg=””};
for(var i=0;i<=gdareainfo.length;i++){
if(gdareainfo[i]==adminCode){
lonLatx=gdareainfo[i-2];
lonLaty=gdareainfo[i-1]+0.5;
adminName=gdareainfo[i+1];
}
}
if(adminName==””) {
//alert(‘no info ‘);
return;
};

for(var j = markers.markers.length-1; j >=0 ; j–){
if(adminCode == markers.markers[j].adminCode)
{
markers.removeMarker(markers.markers[j]);
}
}
var size = new OpenLayers.Size(50,50);
var calculateOffset = function(size) {
return new OpenLayers.Pixel(-(size.w/2), -size.h);
};
var icon = new OpenLayers.Icon(getAlarmLevelImg(alarmLevel),
null,null,null);
// size, null, calculateOffset);
//var marker =new OpenLayers.Marker(map.getLonLatFromPixel(e.xy), icon);//显示到当前点中的坐标
var marker =new OpenLayers.Marker(new OpenLayers.LonLat(lonLatx, lonLaty), icon);//显示到县市的中心点
marker.adminCode=adminCode;
marker.adminName=adminName;
marker.showLabel=true;
marker.labelStr=””;
//显示文本标签信息。
marker.text = marker.adminName+”(“+marker.adminCode+”)”;
if(alarmMsg!=””)
{
marker.text= marker.text+” ” + alarmMsg;
}
//alert(marker.text);
if(marker.text != “”){
marker.icon.imageDiv.style.fontSize = “14px”;
marker.icon.imageDiv.style.color = “blue”;
//marker.icon.imageDiv.style.backgroundColor = “rgb(255, 255, 215)”;
marker.icon.imageDiv.style.whiteSpace = “nowrap”;
//marker.icon.imageDiv.style.width=”100%”;
//marker.icon.imageDiv.style.height=”30″;
var str = “”;
str+= “<img src='”+marker.icon.url+”‘ alt='”+marker.text+”‘”+”‘ title='”+marker.text+”‘>”;
marker.icon.imageDiv.innerHTML = str;//imageDivStr + str;
}
this.labelStr=marker.icon.imageDiv.innerHTML;
if (deleteEnable) {
marker.events.register(‘click’, marker, function(evt) {
markers.removeMarker(this);
OpenLayers.Event.stop(evt);
});
}else{
marker.events.register(‘click’, marker, function(evt) {
//alert(” 当前状态 “+this.showLabel);
//alert(this.icon.imageDiv.innerHTML);
if(this.showLabel){
var str = “”;
this.showLabel=false;
str+= “<table border=\”0\” bordercolor=\”#FF0000\”>”;
str+= “<tr><td bgcolor=\”rgb(255, 255, 215)\” style=\”white-space:nowrap\”>”;
str+= “<img src='”+marker.icon.url
+”‘ ‘ height=20px width=20px alt='”+marker.text+”‘”+”‘ title='”+marker.text+”‘ ”
+” />”;
str+= this.text.replace(new RegExp(“\n”,”gm”),'<br/>’);
str+= “</td></tr>”;
str+= “</table>”;

this.icon.imageDiv.innerHTML = str;//imageDivStr + str;
}else{
var str = “”;
str+= “<img src='”+marker.icon.url
+”‘ height=20px width=20px ”
+”‘ alt='”+marker.text+”‘”+”‘ title='”+marker.text+”‘ ”
+” style=\”FILTER: progid:DXImageTransform.Microsoft.Alpha(opacity=0);WIDTH: 20px; POSITION: relative; HEIGHT: 20px\” /><br/>”;
//alert(‘不显示label’);
this.showLabel=true;
this.icon.imageDiv.innerHTML = str;//imageDivStr + str;
}
//alert(this.icon.imageDiv.innerHTML);
OpenLayers.Event.stop(evt);
});
}
markers.addMarker(marker);

}

function getAlarmLevelImg(level) {
var imgName = “”;
if (level == 1) {
imgName = “alarm_red.png”;
} else if (level == 2) {
imgName = “alarm_orange.png”;
} else if (level == 3) {
imgName = “alarm_yellow.png”;
} else if (level == 4) {
imgName = “alarm_blue.png”;
} else {
imgName = “alarm_other.png”;
}
return “/was/images/weather/” + imgName;
}

用于标注的的代码为:

if (deleteEnable) {
map.events.register(‘click’, map, function (e) {
//alert(map.getLonLatFromPixel(e.xy));
//document.getElementById(‘nodelist’).innerHTML = “正在载入… 请稍后…”;
var url =  map.layers[0].getFullRequestString(
{
REQUEST: “GetFeatureInfo”,
EXCEPTIONS: “application/vnd.ogc.se_xml”,
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: ‘text/xml’,
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 50,
srs: ‘EPSG:4326’,
layers: ‘gdmap:Dguangdong_region’,
styles: ”,
WIDTH: map.size.w,
HEIGHT: map.size.h
},
gisctx+ “/wms”
);

var selectPoint = function(varresponse){
var rs=varresponse.responseText;
rs=rs.replace(“‘”,””);
// alert(rs);
if(rs.indexOf(“ADMINCODE = “)<1){// alert(“no info”);
return ;}
rs=rs.substr(rs.indexOf(“ADMINCODE = “)+12);
rs=rs.substr(0,6);
var adminCode=rs;
rs=varresponse.responseText;
rs=rs.substr(rs.indexOf(“ADMINNAME = “)+12);
rs=rs.substr(0,rs.indexOf(“\n”));
var adminName=rs;
var alarmLevel =”1″;
alarmLevel = document.getElementById(“alarmLevel”).value;

lzbmarkArea(deleteEnable, adminCode,alarmLevel);
}

OpenLayers.loadURL(url, ”, this, selectPoint, setHTML);
OpenLayers.Event.stop(e);

});

};

2008年01月17日

在geoserver和Mapinfo中过滤重复显示的标注

Filed under: Java — 标签:, , , — lizongbo @ 13:06

在geoserver和Mapinfo中过滤重复显示的标注
由于国家地理中心提供的地图的问题,在Mapinfo和geoserver中,都会显示重复的地名,
比如显示出多个“广东省”,“台湾省”。“海南省”。

解决方法如下:

在mapinfo中,
主菜单–>地图–>图层控制–>,选中图层的标注,点“标注”,将“允许文本重复”的钩去掉。

在geoserver中,在为地图定义的style里,加上
<sld:VendorOption name=”group”>yes</sld:VendorOption>

修改后片段如下:

[code]

<sld:TextSymbolizer>
<sld:Label>
<ogc:PropertyName>NAME</ogc:PropertyName>
</sld:Label>
<sld:Font>
<sld:CssParameter name=”font-size”>
<ogc:Literal>12.0</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”font-style”>
<ogc:Literal>normal</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”font-weight”>
<ogc:Literal>normal</ogc:Literal>
</sld:CssParameter>
</sld:Font>
<sld:LabelPlacement>
<sld:PointPlacement>
<sld:AnchorPoint>
<sld:AnchorPointX>
<ogc:Literal>0.5</ogc:Literal>
</sld:AnchorPointX>
<sld:AnchorPointY>
<ogc:Literal>0.5</ogc:Literal>
</sld:AnchorPointY>
</sld:AnchorPoint>
<sld:Displacement>
<sld:DisplacementX>
<ogc:Literal>0</ogc:Literal>
</sld:DisplacementX>
<sld:DisplacementY>
<ogc:Literal>0</ogc:Literal>
</sld:DisplacementY>
</sld:Displacement>
<sld:Rotation>
<ogc:Literal>0.0</ogc:Literal>
</sld:Rotation>
</sld:PointPlacement>
</sld:LabelPlacement>
<sld:Fill>
<sld:CssParameter name=”fill”>
<ogc:Literal>#000000</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name=”fill-opacity”>
<ogc:Literal>1.0</ogc:Literal>
</sld:CssParameter>
</sld:Fill>
<sld:VendorOption name=”spaceAround”>2</sld:VendorOption>
<sld:VendorOption name=”group”>yes</sld:VendorOption>
</sld:TextSymbolizer>
[/code]

我在google是用 “TextSymbolizer duplicate  label”来找到解决这个问题的帖子的。

参考: http://osdir.com/ml/gis.geoserver.user/2006-12/msg00013.html
http://osdir.com/ml/gis.geoserver.user/2006-12/msg00008.html
http://postgis.refractions.net/pipermail/postgis-users/2007-November/017846.html

sld的 schema文件在:  http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd

本地目录在: \geoserver\schemas\sld\StyledLayerDescriptor.xsd

补记一下,geoserver-1.6.0-RC2-war.zip中自带的OpenLayers.js貌似版本要低些,

在使用LonLat时有出错信息,
例如:             map.setCenter(new OpenLayers.LonLat(114, 22.54), 4);

于是我直接用OpenLayers-2.5.zip 中的OpenLayers替换geoserver\openlayers下面的文件,就不再出错了。

2008年01月15日

获取公开的中国地图信息和使用MapBasic提取MapInfo地图资源信息

Filed under: Java — 标签:, , , , , — lizongbo @ 13:15

Mapinfo 自带了一份中国地图,有一定量的数据,足够学习使用,
数据文件在 \MAPINFO\DATA\MAP_DATA\ASIA\CHINA
表文件有:
CAP2_ZHE.TAB
CAP4_ZHE.TAB
CAPITALS.TAB
CHCTY_2K.TAB
CHCTY_5K.TAB
CHINA.TAB
CHINAHWY.TAB
CHINCAPS.TAB
CNTY_ZHE.TAB
PREF_ZHE.TAB
PROVINCE.TAB

国家基础地理信息中心也提供了中国地图下载,内容更加详细,只是数据实在太老,也只能仅供学习使用。
国家基础地理信息系统数据下载服务
来源 :http://nfgis.nsdi.gov.cn/nfgis/chinese/c_xz.htm

国界:bou1_4m.zip
国界与省界:bou2_4m.zip
首都和省级行政中心:res1_4m.zip
地市级以上居民地:res2_4m.zip
一级河流:hyd1_4m.zip
三级以上河流:hyd2_4m.zip
主要公路:roa_4m.zip
主要铁路:rai_4m.zip
地级行政界线:bou3_4m.zip
县级行政界线:bou4_4m.zip
县级居民地:res4_4m.zip
四级河流:hyd4_4m.zip
五级河流:hyd5_4m.zip

ESRI Shape File 格式地图下载地址:

http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/hyd5_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/hyd4_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/res4_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/bou4_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/bou3_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/rai_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/hyd2_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/roa_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/hyd1_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/res2_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/res1_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/bou2_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/shp/bou1_4m.zip
mapinfo的 mif格式地图下载地址:

http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/hyd5_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/hyd4_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/res4_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/bou4_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/bou3_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/rai_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/hyd2_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/roa_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/hyd1_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/res2_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/res1_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/bou2_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/mif/bou1_4m.zip

ARC/INFO的E00格式地图下载地址:
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/hyd5_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/hyd4_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/res4_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/bou4_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/bou3_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/rai_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/hyd2_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/roa_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/hyd1_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/res2_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/res1_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/bou2_4m.zip
http://nfgis.nsdi.gov.cn/mapdata/nfgis_4m/downloaddata/e00/bou1_4m.zip

mapinfo 中可以用 Centroidx和Centroidy函数来选择区域的中心坐标。
partly within用来表示位于指定区域

针对国家基础地理信息的中国地提,使用下面的Mapbasic提取广东省所有县的中心坐标及行整区划代码,

//提取县,需要先打开,bou2_4p.tab和XianCh.tab,然后鼠标选择广东省这个区域
dim k as object
k=selection.obj
select Centroidx(obj),Centroidy(obj),adcode93,name from xianch where obj partly within k into seltab
//提取市,需要先打开,bou2_4p.tab和res2_4p.tab,然后鼠标选择广东省这个区域
dim k as object
k=selection.obj
select Centroidx(obj),Centroidy(obj),adcode99,name from res2_4p where obj partly within k into seltab

国家基础地理信息的数据实在是老得掉牙:
//javascript变量定义

var oldguangdongareainfo=[
110.854,21.9192,440922,”高州县”,
110.625,21.654,440924,”化州县”,
110.283,21.6132,440822,”廉江县”,
111.002,21.5111,440923,”电白县”,
110.779,21.4465,440821,”吴川县”,
110.251,21.383,440823,”遂溪县”,
110.088,20.902,440824,”海康县”,
110.163,20.3297,440825,”徐闻县”,
110.939,22.3635,440921,”信宜县”,
112.378,24.7797,441824,”连县”,
112.283,24.7188,441826,”连南瑶族自治县”,
112.073,24.5693,441825,”连山壮族瑶族自治县”,
112.179,23.9122,441224,”怀集县”,
112.431,23.6427,441223,”广宁县”,
111.508,23.4451,441225,”封开县”,
111.521,23.2422,441229,”郁南县”,
111.771,23.1468,441226,”德庆县”,
112.453,23.0569,441201,”高要县”,
112.04,22.9332,441227,”云浮县”,
111.57,22.7669,441230,”罗定县”,
112.225,22.7029,441228,”新兴县”,
112.307,22.1919,440723,”恩平县”,
111.791,22.1759,441722,”阳春县”,
111.627,21.7504,441721,”阳西县”,
113.038,22.5266,440721,”新会县”,
113.347,25.1349,440225,”乐昌县”,
113.269,24.7842,440232,”乳源瑶族自治县”,
112.638,24.485,441823,”阳山县”,
113.402,24.1729,441822,”英德县”,
113.531,23.8719,441821,”佛冈县”,
113.203,23.3768,440121,”花县”,
112.695,23.3487,441222,”四会县”,
112.886,23.1659,440621,”三水县”,
113.366,22.9438,440126,”番禺县”,
112.848,22.889,440624,”高明县”,
113.254,22.8479,440623,”顺德县”,
112.958,22.7659,440725,”鹤山县”,
112.692,22.3754,440724,”开平县”,
112.794,22.2514,440722,”台山县”,
113.287,22.2124,440421,”斗门县”,
113.876,22.5767,440321,”宝安县”,
114.302,25.1188,440223,”南雄县”,
113.743,25.0901,440224,”仁化县”,
114.063,24.9458,440222,”始兴县”,
113.596,24.6839,440221,”曲江县”,
114.482,24.3577,441623,”连平县”,
114.132,24.3445,440229,”翁源县”,
114.202,24.0625,440233,”新丰县”,
114.243,23.7393,441324,”龙门县”,
113.581,23.5554,440122,”从化县”,
113.829,23.2926,440125,”增城县”,
114.274,23.1722,441322,”博罗县”,
114.712,22.9878,441323,”惠东县”,
114.463,22.7993,441321,”惠阳县”,
114.932,24.4397,441624,”和平县”,
115.89,24.5659,441426,”平远县”,
116.109,24.3075,441401,”梅县”,
115.727,24.1387,441425,”兴宁县”,
115.256,24.0997,441622,”龙川县”,
115.763,23.9322,441424,”五华县”,
116.17,23.7672,441423,”丰顺县”,
115.173,23.6431,441621,”紫金县”,
115.836,23.4346,440526,”揭西县”,
115.651,23.3109,441523,”陆河县”,
116.168,23.3002,440527,”普宁县”,
115.335,22.9757,441521,”海丰县”,
115.641,22.9485,441522,”陆丰县”,
116.17,24.6514,441427,”蕉岭县”,
116.689,24.3545,441422,”大埔县”,
116.637,23.6677,440581,”潮州市”,
116.35,23.543,440525,”揭阳县”,
116.768,23.4632,440521,”澄海县”,
116.594,23.261,440524,”潮阳县”,
116.289,23.0391,440528,”惠来县”,
117.004,23.6761,440522,”饶平县”,
113.021,23.7196,441801,”清远”,
113.261,23.1189,440101,”广州”,
113.115,23.0349,440601,”佛山”,
113.568,22.2726,440401,”珠海”,
113.085,22.5912,440701,”江门”,
112.451,23.0579,441201,”肇庆”,
113.371,22.5269,442001,”中山”,
110.399,21.195,440801,”湛江”,
110.889,21.6707,440901,”茂名”,
113.605,24.8088,440201,”韶关”,
111.958,21.8452,441701,”阳江”,
113.55,22.2008,820000,”澳门”,
115.364,22.7787,441501,”汕尾”,
114.392,23.088,441301,”惠州”,
114.111,22.5564,440301,”深圳”,
114.694,23.7348,441601,”河源”,
113.749,23.0485,441901,”东莞”,
116.684,23.3627,440501,”汕头”,
116.108,24.3145,441401,”梅州”];

下面是从另外一份比较新的广东地图中查询广东省各县市的中心坐标,
mapbasic语句为:

Select Centroidx(obj),Centroidy(obj), AdminCode,AdminName from Dguangdong into Selection
Browse * From Selection

查询结果为:
//javascript变量定义,方便 Openlayers直接使用
//广东省县市坐标与行政区划代码信息
//经纬度,行政区划代码,县市名称
var gdareainfo=[
113.218,25.2289,”440281″,”乐昌市”,
113.78,25.1449,”440224″,”仁化县”,
114.339,25.1839,”440282″,”南雄市”,
112.453,24.9054,”441882″,”连州市”,
114.143,24.8319,”440222″,”始兴县”,
113.174,24.8006,”440232″,”乳源瑶族自治县”,
113.546,24.7746,”440200″,”韶关市”,
115.928,24.6671,”441426″,”平远县”,
112.697,24.447,”441823″,”阳山县”,
112.268,24.6136,”441826″,”连南瑶族自治县”,
116.22,24.6517,”441427″,”蕉岭县”,
112.046,24.5154,”441825″,”连山壮族瑶族自治县”,
116.171,24.3575,”441421″,”梅县”,
115.326,24.3137,”441622″,”龙川县”,
114.982,24.4322,”441624″,”和平县”,
116.626,24.3437,”441422″,”大埔县”,
113.988,24.3988,”440229″,”翁源县”,
115.759,24.2475,”441481″,”兴宁市”,
114.589,24.3425,”441623″,”连平县”,
113.338,24.1964,”441881″,”英德市”,
116.102,24.2744,”441400″,”梅州市”,
112.195,23.9327,”441224″,”怀集县”,
112.962,23.9307,”441827″,”清新县”,
114.16,24.0795,”440233″,”新丰县”,
114.853,23.9629,”441625″,”东源县”,
116.943,23.8531,”445122″,”饶平县”,
116.275,23.9175,”441423″,”丰顺县”,
115.669,23.7808,”441424″,”五华县”,
113.552,23.8888,”441821″,”佛冈县”,
116.759,23.7127,”445121″,”潮安县”,
111.694,23.5962,”441225″,”封开县”,
112.397,23.6702,”441223″,”广宁县”,
114.118,23.6462,”441324″,”龙门县”,
113.669,23.6487,”440184″,”从化市”,
114.652,23.6922,”441600″,”河源市”,
113.131,23.6177,”441800″,”清远市”,
115.062,23.4701,”441621″,”紫金县”,
116.554,23.5765,”445221″,”揭东县”,
116.668,23.6934,”445100″,”潮州市”,
114.271,23.3763,”441322″,”博罗县”,
112.643,23.4495,”441284″,”四会市”,
115.901,23.4851,”445222″,”揭西县”,
116.583,23.3388,”440500″,”汕头市”,
113.744,23.3502,”440183″,”增城市”,
113.217,23.4307,”440114″,”花都区”,
116.37,23.5214,”445200″,”揭阳市”,
112.891,23.108,”440600″,”佛山市”,
117.13,23.3702,”440523″,”南澳县”,
116.042,23.3122,”445281″,”普宁市”,
111.902,23.288,”441226″,”德庆县”,
115.624,23.2917,”441523″,”陆河县”,
112.756,23.1015,”441283″,”高要市”,
113.368,23.2701,”440111″,”白云区”,
111.632,23.0586,”445322″,”郁南县”,
112.592,23.1663,”441200″,”肇庆市”,
113.36,23.1718,”440106″,”天河区”,
115.281,22.9641,”441521″,”海丰县”,
116.271,23.0153,”445224″,”惠来县”,
113.484,23.0953,”440112″,”黄埔区”,
115.853,22.9271,”441581″,”陆丰市”,
113.24,23.1299,”440103″,”荔湾区”,
113.26,23.1294,”440104″,”越秀区”,
113.3,23.1272,”440102″,”东山区”,
113.885,22.898,”441900″,”东莞市”,
111.951,22.8497,”445323″,”云安县”,
112.146,22.9655,”445300″,”云浮市”,
113.227,23.0818,”440107″,”芳村区”,
113.331,23.0788,”440105″,”海珠区”,
113.495,22.7965,”440113″,”番禺区”,
111.47,22.6894,”445381″,”罗定市”,
115.418,22.7619,”441500″,”汕尾市”,
112.763,22.662,”440784″,”鹤山市”,
112.244,22.6087,”445321″,”新兴县”,
113.03,22.4386,”440700″,”江门市”,
113.425,22.4764,”442000″,”中山市”,
111.184,22.4464,”440983″,”信宜市”,
111.722,22.2597,”441781″,”阳春市”,
112.526,22.311,”440783″,”开平市”,
112.266,22.2027,”440785″,”恩平市”,
112.679,21.9944,”440781″,”台山市”,
111.001,22.0079,”440981″,”高州市”,
112.041,21.9699,”441723″,”阳东县”,
110.54,21.8416,”440982″,”化州市”,
111.215,21.6637,”440923″,”电白县”,
112.003,21.7329,”441700″,”阳江市”,
110.13,21.6612,”440881″,”廉江市”,
111.599,21.6869,”441721″,”阳西县”,
110.977,21.5809,”440900″,”茂名市”,
110.781,21.4186,”440883″,”吴川市”,
110.03,21.2508,”440823″,”遂溪县”,
110.417,21.1434,”440800″,”湛江市”,
110.054,20.796,”440882″,”雷州市”,
116.824,20.7034,”446000″,”东沙群岛”,
110.209,20.4242,”440825″,”徐闻县”,
114.458,22.8943,”441300″,”惠州市”,
114.989,22.9424,”441323″,”惠东县”,
114.545,22.5429,”440300″,”深圳市”,
113.735,22.1174,”440400″,”珠海市”
];

一个从Mapinfo 广东地图 中切出 深圳地图 和 珠海地图 的MapBasic例子:

[code]

Include “MAPBASIC.DEF”

declare sub openbasetables
declare sub main
declare sub cut_back
declare sub cut_land
declare sub cut_poi
declare sub cut_road

define sourcepath “E:\gis\gisdata\data\gdditu”
define targetpath “E:\gis\gisdata\data\gdditu2”
define cityname “guangdong”
define basedname targetpath+”\Dist\”+”d”+cityname+”.tab”

sub openbasetables
dim dname as string
dim sel_d as string

dname=sourcepath+”\Dist\”+”d”+cityname+”.tab”
sel_d=targetpath+”\Dist\”+”sel_d”+cityname+”.tab”

close all
open table dname as d
select * from d where adminname in(“深圳市”,”珠海市”) into seltab noselect
commit table seltab as sel_d
close all

open table sel_d as seltab
select * from seltab
Objects Combine
‘//尾部
commit table seltab as basedname
close all

end sub

sub cut_back
dim bname as string
dim tbname as string
dim k as object

bname=sourcepath+”\Back\”+”b”+cityname+”.tab”
tbname=targetpath+”\Back\”+”b”+cityname+”.tab”

open table basedname as d
open table bname as b

select * from d
k=selection.obj
select * from b where obj partly within k into seltab noselect
commit table seltab as tbname
close all

end sub

sub cut_land
dim tname as string
dim ttname as string
dim k as object

tname=sourcepath+”\land\”+”t”+cityname+”.tab”
ttname=targetpath+”\land\”+”t”+cityname+”.tab”

open table basedname as d
open table tname as t

select * from d
k=selection.obj
select * from t where obj partly within k into seltab noselect
commit table seltab as ttname
close all

end sub

sub cut_poi
dim aname as string
dim taname as string
dim acname as string
dim tacname as string
dim pname as string
dim tpname as string
dim zname as string
dim tzname as string
dim k as object

aname=sourcepath+”\Poi\”+”a”+cityname+”.tab”
taname=targetpath+”\Poi\”+”a”+cityname+”.tab”
acname=sourcepath+”\Poi\”+”ac”+cityname+”.tab”
tacname=targetpath+”\Poi\”+”ac”+cityname+”.tab”
pname=sourcepath+”\Poi\”+”p”+cityname+”.tab”
tpname=targetpath+”\Poi\”+”p”+cityname+”.tab”
zname=sourcepath+”\Poi\”+”z”+cityname+”.tab”
tzname=targetpath+”\Poi\”+”z”+cityname+”.tab”

open table basedname as d
open table aname as a
open table acname as ac
open table pname as p
open table zname as z

select * from d
k=selection.obj
select * from a where obj partly within k into seltab noselect
commit table seltab as taname
select * from d
k=selection.obj
select * from ac where obj partly within k into seltab noselect
commit table seltab as tacname
select * from d
k=selection.obj
select * from p where obj partly within k into seltab noselect
commit table seltab as tpname
select * from d
k=selection.obj
select * from z where obj partly within k into seltab noselect
commit table seltab as tzname

close all

end sub

sub cut_Road
” dim brname as string
” dim tbrname as string

dim cname as string
dim tcname as string

” dim dmname as string
” dim tdmname as string

” dim drname as string
” dim tdrname as string

” dim icname as string
” dim ticname as string

dim nname as string
dim tnname as string

dim rname as string
dim trname as string

dim k as object

” brname=sourcepath+”\Road\”+”br”+cityname+”.tab”
” tbrname=targetpath+”\Road\”+”br”+cityname+”.tab”

cname=sourcepath+”\Road\”+”c”+cityname+”.tab”
tcname=targetpath+”\Road\”+”c”+cityname+”.tab”

” dmname=sourcepath+”\Road\”+”dm”+cityname+”.tab”
” tdmname=targetpath+”\Road\”+”dm”+cityname+”.tab”

” drname=sourcepath+”\Road\”+”dr”+cityname+”.tab”
” tdrname=targetpath+”\Road\”+”dr”+cityname+”.tab”

” icname=sourcepath+”\Road\”+”ic”+cityname+”.tab”
” ticname=targetpath+”\Road\”+”ic”+cityname+”.tab”

nname=sourcepath+”\Road\”+”n”+cityname+”.tab”
tnname=targetpath+”\Road\”+”n”+cityname+”.tab”

rname=sourcepath+”\Road\”+”r”+cityname+”.tab”
trname=targetpath+”\Road\”+”r”+cityname+”.tab”

open table basedname as d
” open table brname as br
open table cname as c
” open table dmname as dm
” open table drname as dr
” open table icname as ic
open table nname as n
open table rname as r

” select * from d
” k=selection.obj
” select * from br where obj partly within k into seltab noselect
” commit table seltab as tbrname
select * from d
k=selection.obj
select * from c where obj partly within k into seltab noselect
commit table seltab as tcname
” select * from d
” k=selection.obj
” select * from dm where obj partly within k into seltab noselect
” commit table seltab as tdmname
” select * from d
” k=selection.obj
” select * from dr where obj partly within k into seltab noselect
” commit table seltab as tdrname
” select * from d
” k=selection.obj
” select * from ic where obj partly within k into seltab noselect
” commit table seltab as ticname
select * from d
k=selection.obj
select * from n where obj partly within k into seltab noselect
commit table seltab as tnname
select * from d
k=selection.obj
select * from r where obj partly within k into seltab noselect
select * from seltab order by mapid,id into sel_seltab noselect
commit table sel_seltab as trname

close all

end sub

sub main
call openbasetables
call cut_back
call cut_land
call cut_poi
call cut_Road
end sub

[/code]

Older Posts »

Powered by WordPress