PageSourceSearch

https://www.speakupaustin.org/Scripts/polygonCentering.js

js speakupaustin.org collected 2026-10-01 13:54:51 UTC 1,162 bytes, 46 lines download raw bytes

1var PolygonCenteringHelper = function (paths) {
2    this.paths = paths;
3    this._init();
4};
5
6PolygonCenteringHelper.prototype._init = function () {
7    this.A = 0;
8    this.Gx = 0;
9    this.Gy = 0;
10};
11
12function GetX(obj) {
13    if (obj.lat) {
14        return obj.lat();
15    }
16    else {
17        return obj.x;
18    }
19}
20
21function GetY(obj) {
22    if (obj.lng) {
23        return obj.lng();
24    }
25    else {
26        return obj.y;
27    }
28}
29
30PolygonCenteringHelper.prototype._calculateCenter = function () {
31    for (j = 0; j < this.paths.length - 1; j++) {
32        this._calculatePoint(GetX(this.paths[j]), GetY(this.paths[j]), GetX(this.paths[j + 1]), GetY(this.paths[j + 1]));
33    }
34    this._calculatePoint(GetX(this.paths[this.paths.length - 1]), GetY(this.paths[this.paths.length - 1]), GetX(this.paths[0]), GetY(this.paths[0]));
35    return {
36        x: this.Gx / (3 * this.A),
37        y: this.Gy / (3 * this.A)
38    }
39};
40
41PolygonCenteringHelper.prototype._calculatePoint = function (x0, y0, x1, y1) {
42    var tmp = x0 * y1 - x1 * y0;
43    this.A += tmp;
44    this.Gx += (x0 + x1) * tmp;
45    this.Gy += (y0 + y1) * tmp;
46};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.