When we do GIS spatial analysis, we often need to compute a certain point of the buffer, then we need to take this point as the center, draw a circle. How to achieve it?
The buffer approach has a corresponding API in the ArcIMS, but our approach now is to throw out the IMS API and only draw a circle in the foreground. It uses VML to draw a circle.
Using VML technology to draw a circle is relatively simple, where it is more difficult to solve the problem of how much distance per pixel represents the field, knowing that this value can be used to draw the radius of the buffer to get exactly how many pixels to use VML to draw.
The most important thing in the concept is to find out the meaning of "pixel". We often know what it means, but think about it: why do we use pixels when we write programs? Instead of the length of meters such as units, and if the resolution is different, the pixel value is unchanged, what will affect the results? Wait a minute. Also, we say "how much distance per pixel represents the field" is not the "scale" that we are learning in cartography. The scale is the field distance divided by the distance (1 cm), and for the electronic map, the scale does not make sense, because in the electronic map, the "How many distances per pixel" is the denominator of the pixel value, not the length value. We return in IMS the MBR's four values Xmin,ymin,xmax,ymax and Width,height, where width and Height are pixel values, which need to be clarified.
We set up a map object to store the status of the maps returned in IMS: four values for MBR Xmin,ymin,xmax,ymax and map length width (pixel values) and height (pixel values). They can get some of our most common and important functions: screen coordinates and geographical coordinates of the transformation function, input screen coordinates to get the distance function (ranging), to determine whether the input longitude and latitude point in the map range (if not in the words do not load in) function. As follows:
JS Code
function Map ()
{
This. xmin = 0;
This. ymin = 0;
This. xmax = 0;
This. ymax = 0;
This. Width = 0;
This. Height = 0;
This. ImageURL = ';
This.getxdistance = function () {
return this. Xmax-this. xmin;
}
This.getydistance = function () {
return this. Ymax-this. ymin;
}
This.getpixelx = function () {
Return This.getxdistance ()/this. Width;
}
this.getpixely = function () {
Return This.getydistance ()/this. Height;
}
This.toscreenx = function (x) {
Return (X-this. xmin)/this.getpixelx ();
}
This.toscreeny = function (y) {
Return (this. ymax-y)/this.getpixely ();
}
This.togeox = function (x) {
return this. Xmin + X*THIS.GETPIXELX ();
}
This.togeoy = function (y) {
return this. Ymax-y*this.getpixely ();
}
This.distance = function (x1, y1, x2, y2) {
var num1 = math.pi/180;
var num2 = 1/num1;
X1 = This.togeox (x1) * NUM1;
Y1 = This.togeoy (y1) * NUM1;
x2 = This.togeox (x2) * NUM1;
y2 = This.togeoy (y2) * NUM1;
Return ((111120 * num2) * Math.acos (Math.sin (y1) * Math.sin (y2)) + ((Math.Cos (y1) * Math.Cos (y2)) * Math.Cos (X2-X1)));
}
This.include = function (x, y) {
Return (X>this. Xmin && X<this. Xmax && Y>this. Ymin && Y<this. YMAX);
}
}