WEBGIS纯客户端计算面积及长度Word文件下载.docx
《WEBGIS纯客户端计算面积及长度Word文件下载.docx》由会员分享,可在线阅读,更多相关《WEBGIS纯客户端计算面积及长度Word文件下载.docx(19页珍藏版)》请在冰豆网上搜索。
sourceinstanceofwindow.Event;
if(!
sourceIsEvt&
source.hasOwnProperty&
source.hasOwnProperty('
toString'
)){
destination.toString=source.toString;
returndestination;
};
GISUtil.getDistanceInEarth=function(point1,point2){
vard=newNumber(0);
//1度等于0.0174532925199432957692222222222弧度
//varradPerDegree=0.0174532925199432957692222222222;
varradPerDegree=Math.PI/180.0;
if(GIS.Measure.map.spatialReference.wkid=="
4326"
){
varlatLength1=Math.abs(this.translateLonLatToDistance({x:
point1.x,y:
point2.y}).x-this.translateLonLatToDistance({x:
point2.x,y:
point2.y}).x);
varlatLength2=Math.abs(this.translateLonLatToDistance({x:
point1.y}).x-this.translateLonLatToDistance({x:
point1.y}).x);
varlonLength=Math.abs(this.translateLonLatToDistance({x:
point2.y}).y-this.translateLonLatToDistance({x:
point1.y}).y);
d=Math.sqrt(Math.pow(lonLength,2)-Math.pow(Math.abs(latLength1-latLength2)/2,2)+Math.pow(Math.abs(latLength1-latLength2)/2+Math.min(latLength1,latLength2),2));
else{
varlen_prj=Math.pow((point2.x-point1.x),2)+Math.pow((point2.y-point1.y),2);
d=Math.sqrt(len_prj);
d=Math.ceil(d);
returnd;
GISUtil.translateLonLatToDistance=function(point){
//1度等于0.0174532925199432957692222222222弧度varradPerDegree=0.0174532925199432957692222222222;
varequatorialCircumference=Math.PI*2*6378137;
return{
x:
Math.cos(point.y*radPerDegree)*equatorialCircumference*Math.abs(point.x/360),
y:
equatorialCircumference*Math.abs(point.y/360)
};
//******求三角形面积****
GISUtil.getTriangleArea=function(point1,point2,point3){
vararea=0;
point1||!
point2||!
point3){
return0;
point1=this.translateLonLatToDistance(point1);
point2=this.translateLonLatToDistance(point2);
point3=this.translateLonLatToDistance(point3);
area=((point1.x*point2.y-point2.x*point1.y)+(point2.x*point3.y-point3.x*point2.y)+(point3.x*point1.y-point1.x*point3.y))/2;
returnarea;
GISMapAction={
ZOOMIN:
"
action_zoomin"
ZOOMOUT:
action_zoomout"
PAN:
action_pan"
DISTANCE:
action_distance"
AREA:
action_area"
GISMeatureType={
distance"
area"
GISMeatureUnit={
HECTARE:
HECTARE"
SMETER:
SMETER"
SKILOMETER:
SKILOMETER"
ACRES:
ACRES"
DObject=function(){
varClass=function(){
if(arguments&
arguments[0]!
=null){
this.construct.apply(this,arguments);
varextended={};
varparent;
for(vari=0,len=arguments.length;
i<
len;
++i){
if(typeofarguments[i]=="
parent=arguments[i].prototype;
}else{
parent=arguments[i];
GISUtil.extend(extended,parent);
Class.prototype=extended;
returnClass;
if(typeofGIS=="
undefined"
){varGIS={};
GIS.Measure={
/**
*全局变量
*/
map:
null,//地图对象
meatureTool:
null,
onDrawEnd:
drawToolbar:
markerSymbol:
lineSymbol:
fillSymbol:
*初始化加载部分
Init:
function(map){
GIS.Measure.map=map;
this.markerSymbol=newesri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE,8,newesri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,newdojo.Color([255,69,0]),2),newdojo.Color([255,255,255,1]));
this.lineSymbol=newesri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,newdojo.Color([255,160,122]),2);
this.fillSymbol=newesri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,newesri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,newdojo.Color([255,160,122]),2),newdojo.Color([255,255,255,0.5]));
GIS.Measure._initDrawTool();
GIS.Measure.meatureTool=newGISMeature(map);
},
_initDrawTool:
function(){
varT=this;
this.drawToolbar=newesri.toolbars.Draw(GIS.Measure.map,{showTooltips:
false});
this.drawToolbar.markerSymbol=this.markerSymbol;
this.drawToolbar.lineSymbol=this.lineSymbol;
this.drawToolbar.fillSymbol=this.fillSymbol;
dojo.connect(this.drawToolbar,"
onDrawEnd"
function(geometry){
if(T.onDrawEnd){
T.onDrawEnd(geometry);
});
//动态测距
measureDistance:
this.setMapCursor("
url('
../Widget/style/cursor/draw.cur'
),auto"
);
this.meatureTool.activate(GISMeatureType.DISTANCE);