th计算机网路编程课程设计.docx

上传人:b****0 文档编号:17644573 上传时间:2023-07-27 格式:DOCX 页数:16 大小:173.85KB
下载 相关 举报
th计算机网路编程课程设计.docx_第1页
第1页 / 共16页
th计算机网路编程课程设计.docx_第2页
第2页 / 共16页
th计算机网路编程课程设计.docx_第3页
第3页 / 共16页
th计算机网路编程课程设计.docx_第4页
第4页 / 共16页
th计算机网路编程课程设计.docx_第5页
第5页 / 共16页
th计算机网路编程课程设计.docx_第6页
第6页 / 共16页
th计算机网路编程课程设计.docx_第7页
第7页 / 共16页
th计算机网路编程课程设计.docx_第8页
第8页 / 共16页
th计算机网路编程课程设计.docx_第9页
第9页 / 共16页
th计算机网路编程课程设计.docx_第10页
第10页 / 共16页
th计算机网路编程课程设计.docx_第11页
第11页 / 共16页
th计算机网路编程课程设计.docx_第12页
第12页 / 共16页
th计算机网路编程课程设计.docx_第13页
第13页 / 共16页
th计算机网路编程课程设计.docx_第14页
第14页 / 共16页
th计算机网路编程课程设计.docx_第15页
第15页 / 共16页
th计算机网路编程课程设计.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

th计算机网路编程课程设计.docx

《th计算机网路编程课程设计.docx》由会员分享,可在线阅读,更多相关《th计算机网路编程课程设计.docx(16页珍藏版)》请在冰点文库上搜索。

th计算机网路编程课程设计.docx

th计算机网路编程课程设计

一、设计内容

1、学习MapXtreme电子地图。

2、利用C#+MapXtreme实现电子地图网站的开发。

二、实验要求

1、编程实现图元添加显示功能;

2、实现图元查找功能;

3、实现图元移动功能;

4、实现图元删除功能

三、软件安装

1、安装IIS

A、解压IIS_XPSP3.rar

B、点击控制面板——>点击添加删除程序——>点击“添加/删除windows组件”——>在弹出的对话框中选择“Internet信息服务”——>点击下一步。

C、需要选择文件时选择刚才解压的文件。

2、安装VS2005:

按默认选项安装。

3、安装MapXtreme

A、双击MapXtreme20086.8中文破解版目录中的MapXtremeTRIALCHS.exe文件。

B、将MapXtreme20086.8中文破解版\6.8破解\mapxtreme680.lic文件拷贝到"C:

\ProgramFiles\CommonFiles\MapInfo\MapXtreme\6.8.0"目录

四、程序设计

1、打开VS,打开给定的工程FireControlGIS.sln。

2、打开Web.Config,找到

/DocumentsandSettings/Administrator/桌面/Web/路线/ditu.mws”/>将路径改为相应的目录。

3、将resicharfont.ttf文件拷到C:

\WINDOWS\Fonts目录下。

4、建立人员结构类。

打开clsUserType.cs文件,在类文件中填入如下代码:

publicclassclsUserType

{

privatestringstrBMID;

privatestringpersonID;

privatestringpersonName;

privateMapInfo.Geometry.DPointDPoint;

privatestringstrUserType()

{

this.strBMID="电子信0901";

this.personID="0111";

this.personName="++";

this.DPoint=newMapInfo.Geometry.DPoint(1,1);

this.strFileName=@"LITE2-32.BMP";

}

publicvoidsetstrBMID(stringstrBMID)

{

this.strBMID=strBMID;

}

publicvoidsetpersonID(stringpersonID)

{

this.personID=personID;

}

publicvoidsetpersonName(stringpersonName)

{

this.personName=personName;

}

publicvoidsetDPoint(MapInfo.Geometry.DPointDPoint)

{

this.DPoint=DPoint;

}

publicvoidsetstrFIleName(stringstrFIleName)

{

this.strFIleName=strFIleName;

}

publicstringgetstrBMID()

{

returnthis.strBMID;

}

publicstringgetpersonID()

{

returnthis.personID;

}

publicstringgetpersonName()

{

returnthis.personName;

}

publicMapInfo.Geometry.DPointgetDPoint()

{

returnthis.DPoint;

}

publicstringgetstrFIleName()

{

returnthis.strFIleName;

}

}

5、建立取得屏幕坐标点的类文件。

打开WebInfoGetXY.cs类并输入下图所示代码。

publicclassWebInfoGetXY:

MapInfo.WebControls.MapBaseCommand

{

publicWebInfoGetXY()

{

base.Name="GetXY";

}

publicoverridevoidProcess()

{

MapControlModelmodel=MapControlModel.GetModelFromSession();

MapInfo.Mapping.Mapmap=model.GetMapObj(MapAlias);

System.Drawing.Point[]points=ExtractPoints(DataString);

MapInfo.Geometry.DPointdpoint=newMapInfo.Geomtry.Dpoint();

map.DisplayTransform.FromDisplay(points[0],outdpoint);

stringoutText="屏幕xy:

"+points[0].X+","+points[0].Y;

outText+="
经纬度xy:

"+dpoint.x","+dpoint.y;

HttpContext.Current.Response.Write(outText);

}

}

6、建立地图操作命令类。

clsMapCommand.cs并输入下图代码。

publicclassclsMapCommand:

MapInfo.WebControls.MapBaseCommand

{

privateMapControlModelmodel;

privateMapInfo.Mapping.Mapmap;

publicclsMapCommand()

{

bass.Name="MapCommand":

}

publicoverridevoidProcess()

{

stringCommad_type=Convert.ToString(HttpContext.Current.Request["Commad_type"]);

stringLayerTable_name=Convert.ToString(HttpContext.Current.Request["LayerTable_name"]);

stringfeature_name=Convert.ToString(HttpContext.Current.Request["feature_name"]);

stringfeature_kind=Convert.ToString(HttpContext.Current.Request["feature+kind"]);

Doublepoint_x=Convert.ToString(HttpContext.Current.Request["point_x"]);

Doublepoint_y=Convert.ToString(HttpContext.Current.Request["point_y"]);

CommonUserGisFuncyion_CommonUserGisFunction=newCommonUserGisFunction();

model=MapControlModel.GetModelFromSession();

map=model.GetMapObj(MapAlias);

if(LayerTable_name==nill)LayerTable_name="newLayer";

switch(Commad_type)

{

case"Select":

_CommonUserGisFunction.SearchWithSearch(map,LayerTable_name,feature_name,feature_kind);

break;

case"Move":

_CommonUserGisFunction.MoveObject(map,LayerTable_name,feature_name,

feature_kind,newMapInfo.Geometry.DPoint(point_x,point_y));

break;

case"ClearAllObject":

_CommonUserGisFunction.clear_feature(map,LayerTable_name);

break;

case"ClearObject":

_CommonUserGisFunction.clear_feature(map,LayerTable_name,feature_name,feature_kind;

break;

case"Refresh":

_CommonUserGisFunction.Update_Person_Position(map,LayerTable_name);

break;

default:

break;

}

}

}

7、在main.aspx.cs文件的pageLoad函数中输入添加图层人员的代码。

#region

if(myMap!

=null)

{

if(myMap.Layers["newLayer"]!

=null)

{

myMap.Layers.Remove("newLayer");

}

if(myMap.Layers["roadLayer"]!

=null)

{

myMap.Layers.Remove("roadLayer");

}

}

CommonUserGisFunction_CommonUserGisFunction=newCommonUserGisFunction()

MapInfo.Mapping.IMapLayerly=_CommonUserGisFunction.CreatNewLayer(myMap,"newLayer","mewLayer");

myMap.Layers.Insert(2,ly);

clsUserType_clsUserType=newclsUserType();

_clsUserType.setDPoint(newMapInfo.Geometry.DPoint(2,2));

_clsUserType.setpersonName("自定义点");

_clsUserType.setpersonID("0000");

CommonUserGisFunction.AddPointToLayer(myMap,"newLayer","newLayer",_clsUserType);

FontPointStylefStyle=newFontPontPointStyle();

fStyle.Code=76;

fStyle.PointSize=24;

fStyle.Color=System.Drawing.Color.Red;

fStyle..Font.Name="residentevilcharacters";

fStyle.Font.FontWeight=MapInfo.Styles.FontWeight.Bold;

fStyle.Angle=400;

_clsUserType.setDPoint(newMapInfo.Geometry.DPoint(1.6,1.6));

_clsUserType.setpersonID("0111");

_clsUserType.setpersonName("佟环");

CommonUserGisFunction.AddPointToLayer(myMap,"newLayer","newLayer",_clsUserType,fStyle);

SimpleVectorPointStylevStyle=newSimpleVectorPointStyle();

vStyle.Code=67;

vStyle.Color=System.Drawing.Color.Red;

vStyle.PointSize=Convert.ToInt16(24);

vStyle.Attributes=StyleAttributes.PointAttributes.BaseAll;

vStyle.SetApplyAll();

_clsUserType.setDPoint(newMapInfo.Geometry.DPoint(1,1));

CommonUserGisFunction.AddPointToLayer(myMap,"newLayer","newLayer",_clsUserType,vStyle);

#endregion

完成上面步骤后运行程序可以实现地图显示功能,在显示的地图中出现三个位图点。

8、图元查找、移动、删除功能实现。

在main.aspx文件中填入如下代码。

A、在

位置填入下列代码。



属性名称

属性值

B、在

位置添加如下图所示的SelectObject()函数。

functionSelectObject()

{

varmapImage=document.getElementById("MapControl1_Image");

varfeature_name=document.forms[0].feature_name.value;

varfeature_value=document.forms[0].feature_value.value;

varurl="MapController.ashx?

Command=MapCommand&Width="+mapImage.width+"&Height="+mapImage.height+"&ExportFormat="+mapImage.exportFormat+"&Ran="+Math.random()+"&Commad_type=Select&feature_name="+feature_name+"&feature_kind="佟环"";

if(mapImage.mapAlias)

url+="&MapAlias="+mapImage.mapAlias;

varxmlHttp=null;

if(BrowserType()==IE)

{

xmlHttp=newActiveXObject("Microsoft.XMLHTTP");

}

elseif(BrowserType()==NS)

{

xmlHttp=newXMLHttpRequest();

}

xmlHttp.open("GET",url,false);

xmlHttp.send(null);

varresult=xmlHttp.responseText;

alert(result);

UpdateMap();

ShowMapArea();

}

C、在

位置输入如下所示的移动图元代码。

functionMoveObject()

{

varmapImage=document.getElementById("MapControl1_Image");

varfeature_name=document.forms[0].feature_name.value;

varfeature_value=document.forms[0].feature_value.value;

varurl="MapController.ashx?

Command=MapCommand&Width="+mapImage.width+"&Height="+mapImage.height+"&ExportFormat="+mapImage.exportFormat+"&Ran="+Math.random()+"&Commad_type=Move&feature_name="+feature_name+"&feature_kind="佟环"&point_x=2.2&point_y=2.2";

varxmlHttp=null;

if(BrowserType()==IE)

{

xmlHttp=newActiveXObject("Microsoft.XMLHTTP");

}

elseif(BrowserType()==NS)

{

xmlHttp=newXMLHttpRequest();

}

xmlHttp.open("GET",url,false);

xmlHttp.send(null);

varresult=xmlHttp.responseText;

alert(result);

UpdateMap();

ShowMapArea();

}

D、在

位置输入如下删除所有图元代码。

functionClearAllObject()

{

varmapImage=document.getElementById("MapControl1_Image");

varurl="MapController.ashx?

Command=MapCommand&Width="+mapImage.width+"&Height="+mapImage.height+"&ExportFormat="+mapImage.exportFormat+"&Ran="+Math.random()+"&Commad_type=ClearAllObject";

varxmlHttp=null;

if(BrowserType()==IE)

{

xmlHttp=newActiveXObject("Microsoft.XMLHTTP");

}

elseif(BrowserType()==NS)

{

xmlHttp=newXMLHttpRequest();

}

xmlHttp.open("GET",url,false);

xmlHttp.send(null);

varresult=xmlHttp.responseText;

alert(result);

UpdateMap();

ShowMapArea();

}

E、在

位置输入删除图元代码。

functionClearObject()

{

varmapImage=document.getElementById("MapControl1_Image");

varfeature_name=document.forms[0].feature_name.value;

varfeature_value=document.forms[0].feature_value.value;

varurl="MapController.ashx?

Command=MapCommand&Width="+mapImage.width+"&Height="+mapImage.height+"&ExportFormat="+mapImage.exportFormat+"&Ran="+Math.random()+"&Commad_type=ClearObject&feature_name="+feature_name+"&feature_kind="佟环"";

varxmlHttp=null;

if(BrowserType()==IE)

{

xmlHttp=newActiveXObject("Microsoft.XMLHTTP");

}

elseif(BrowserType()==NS)

{

xmlHttp=newXMLHttpRequest();

}

xmlHttp.open("GET",url,false);

xmlHttp.send(null);

varresult=xmlHttp.responseText;

alert(result);

UpdateMap();

ShowMapArea();

}

9、参照步骤步骤6添加班级其他同学,并显示。

10、实现按文本框中的内容查找、删除图元功能:

参照下列代码修改main.aspx文件中的SelectObject()、MoveObject()、ClearObject()函数,在函数中添加下列代码

并将url中的Name和XXX改为下图所示的形式。

functionSelectObject()

{

varmapImage=document.getElementById("MapControl1_Image");

varfeature_name=document.forms[0].feature_name.value;

varfeature_value=document.forms[0].feature_value.value;

varurl="MapController.ashx?

Command=MapCommand&Width="+mapImage.width+"&Height="+mapImage.height+"&ExportFormat="+mapImage.exportFormat+"&Ran="+Math.random()+"&Commad_type=Select&feature_name="+feature_name+"&feature_kind="+feature_value+"";

if(mapImage.mapAlias)

url+="&MapAlias="+mapImage.mapAlias;

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2