You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2659 lines
151 KiB
2659 lines
151 KiB
12 months ago
|
(function (global, factory) {
|
||
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||
|
(factory((global.mapv = global.mapv || {})));
|
||
|
}(this, (function (exports) { 'use strict';
|
||
|
|
||
|
var conf = {
|
||
|
longitudeLatitudeScale: 100
|
||
|
};
|
||
|
|
||
|
var Camera = function Camera(gl) {
|
||
|
|
||
|
this.gl = gl;
|
||
|
// this.radius = 100;
|
||
|
// this.lon = 0;
|
||
|
// this.lat = 0;
|
||
|
|
||
|
this.radius = 4000;
|
||
|
this.lon = 90;
|
||
|
this.lat = 45;
|
||
|
|
||
|
this.transX = 100 * conf.longitudeLatitudeScale;
|
||
|
this.transY = 30 * conf.longitudeLatitudeScale;
|
||
|
|
||
|
var canvas = gl.canvas;
|
||
|
|
||
|
gl.viewport(0, 0, canvas.width, canvas.height);
|
||
|
var pMatrix = mat4.create();
|
||
|
mat4.perspective(pMatrix, 45, canvas.width / canvas.height, 1, 100000.0);
|
||
|
gl.uniformMatrix4fv(gl.uPMatrix, false, pMatrix);
|
||
|
|
||
|
this.computerXYZ();
|
||
|
this.render();
|
||
|
this.init();
|
||
|
};
|
||
|
|
||
|
Camera.prototype.init = function () {
|
||
|
this.drag();
|
||
|
};
|
||
|
|
||
|
Camera.prototype.render = function () {
|
||
|
var mvMatrix = mat4.create();
|
||
|
mat4.lookAt(mvMatrix, [this.x, this.y, this.z], [0, 0, 0], [0, 0, 1]);
|
||
|
this.mvMatrix = mat4.translate(mat4.create(), mvMatrix, [-this.transX, -this.transY, 0]);
|
||
|
};
|
||
|
|
||
|
Camera.prototype.drag = function () {
|
||
|
var self = this;
|
||
|
var canvas = this.gl.canvas;
|
||
|
|
||
|
var startX = 0;
|
||
|
var startY = 0;
|
||
|
var which = 1;
|
||
|
var startLon = 0;
|
||
|
var startTransX = 0;
|
||
|
var startTransY = 0;
|
||
|
var startLat = 0;
|
||
|
var canDrag = false;
|
||
|
|
||
|
canvas.addEventListener('mousewheel', function (e) {
|
||
|
self.radius -= event.deltaY;
|
||
|
self.radius = Math.max(10, self.radius);
|
||
|
self.radius = Math.min(100000, self.radius);
|
||
|
self.computerXYZ();
|
||
|
self.render();
|
||
|
});
|
||
|
|
||
|
canvas.addEventListener('mousedown', function (e) {
|
||
|
startX = e.offsetX;
|
||
|
startY = e.offsetY;
|
||
|
startLon = self.lon;
|
||
|
startLat = self.lat;
|
||
|
which = e.which;
|
||
|
startTransX = self.transX;
|
||
|
startTransY = self.transY;
|
||
|
canDrag = true;
|
||
|
window.event.returnValue = false;
|
||
|
return false;
|
||
|
});
|
||
|
|
||
|
canvas.addEventListener('contextmenu', function () {
|
||
|
window.event.returnValue = false;
|
||
|
return false;
|
||
|
});
|
||
|
|
||
|
window.addEventListener('mousemove', function (e) {
|
||
|
if (canDrag) {
|
||
|
var dX = e.offsetX - startX;
|
||
|
var dY = e.offsetY - startY;
|
||
|
if (e.which === 1) {
|
||
|
var dLon = dX / 1;
|
||
|
var dLat = dY / 1;
|
||
|
self.lon = (startLon + dLon) % 360;
|
||
|
self.lat = startLat + dLat;
|
||
|
self.lat = Math.min(90, self.lat);
|
||
|
self.lat = Math.max(-90, self.lat);
|
||
|
self.lat = Math.max(10, self.lat);
|
||
|
} else {
|
||
|
self.transX = startTransX - dX * conf.longitudeLatitudeScale / 10;
|
||
|
self.transY = startTransY + dY * conf.longitudeLatitudeScale / 10;
|
||
|
}
|
||
|
self.computerXYZ();
|
||
|
self.render();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
window.addEventListener('mouseup', function (e) {
|
||
|
startX = 0;
|
||
|
startY = 0;
|
||
|
canDrag = false;
|
||
|
});
|
||
|
};
|
||
|
|
||
|
Camera.prototype.computerXYZ = function () {
|
||
|
var self = this;
|
||
|
self.z = self.radius * Math.sin(self.lat * Math.PI / 180);
|
||
|
var smallRadius = self.radius * Math.cos(self.lat * Math.PI / 180);
|
||
|
self.x = smallRadius * Math.cos(self.lon * Math.PI / 180);
|
||
|
self.y = -smallRadius * Math.sin(self.lon * Math.PI / 180);
|
||
|
};
|
||
|
|
||
|
//get the context
|
||
|
function getWebGLContext(canvas, err) {
|
||
|
// bind err
|
||
|
if (canvas.addEventListener) {
|
||
|
canvas.addEventListener("webglcontextcreationerror", function (event) {
|
||
|
console.log(event.statusMessage);
|
||
|
}, false);
|
||
|
}
|
||
|
//create context
|
||
|
var names = ["webgl", "experimental-webgl", "webkit-3d", "moz-webgl"];
|
||
|
var context = null;
|
||
|
for (var ii = 0; ii < names.length; ++ii) {
|
||
|
try {
|
||
|
context = canvas.getContext(names[ii], err);
|
||
|
} catch (e) {}
|
||
|
if (context) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return context;
|
||
|
}
|
||
|
|
||
|
//init shader
|
||
|
function initShaders(gl, vshader, fshader) {
|
||
|
var program = createProgram(gl, vshader, fshader);
|
||
|
if (!program) {
|
||
|
console.log('Failed to create program');
|
||
|
return false;
|
||
|
}
|
||
|
gl.useProgram(program);
|
||
|
gl.program = program;
|
||
|
|
||
|
// init shader variable
|
||
|
gl.uPMatrix = gl.getUniformLocation(program, "uPMatrix");
|
||
|
gl.uMVMatrix = gl.getUniformLocation(program, "uMVMatrix");
|
||
|
|
||
|
gl.aPosition = gl.getAttribLocation(gl.program, 'aPosition');
|
||
|
gl.aColor = gl.getAttribLocation(gl.program, 'aColor');
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
//create program
|
||
|
function createProgram(gl, vshader, fshader) {
|
||
|
console.log('create');
|
||
|
// Create shader object
|
||
|
var vertexShader = loadShader(gl, gl.VERTEX_SHADER, vshader);
|
||
|
var fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fshader);
|
||
|
if (!vertexShader || !fragmentShader) {
|
||
|
return null;
|
||
|
}
|
||
|
// Create a program object
|
||
|
var program = gl.createProgram();
|
||
|
if (!program) {
|
||
|
return null;
|
||
|
}
|
||
|
// Attach the shader objects
|
||
|
gl.attachShader(program, vertexShader);
|
||
|
gl.attachShader(program, fragmentShader);
|
||
|
// Link the program object
|
||
|
gl.linkProgram(program);
|
||
|
// Check the result of linking
|
||
|
var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
|
||
|
if (!linked) {
|
||
|
var error = gl.getProgramInfoLog(program);
|
||
|
console.log('Failed to link program: ' + error);
|
||
|
gl.deleteProgram(program);
|
||
|
gl.deleteShader(fragmentShader);
|
||
|
gl.deleteShader(vertexShader);
|
||
|
return null;
|
||
|
}
|
||
|
return program;
|
||
|
}
|
||
|
|
||
|
//loadShader
|
||
|
function loadShader(gl, type, source) {
|
||
|
// Create shader object
|
||
|
var shader = gl.createShader(type);
|
||
|
if (shader == null) {
|
||
|
console.log('unable to create shader');
|
||
|
return null;
|
||
|
}
|
||
|
// Set the shader program
|
||
|
gl.shaderSource(shader, source);
|
||
|
// Compile the shader
|
||
|
gl.compileShader(shader);
|
||
|
// Check the result of compilation
|
||
|
var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
|
||
|
if (!compiled) {
|
||
|
var error = gl.getShaderInfoLog(shader);
|
||
|
console.log('Failed to compile shader: ' + error);
|
||
|
gl.deleteShader(shader);
|
||
|
return null;
|
||
|
}
|
||
|
return shader;
|
||
|
}
|
||
|
|
||
|
function colorTransform(colorStr) {
|
||
|
var color = [0, 0, 0];
|
||
|
if (typeof colorStr == 'string') {
|
||
|
if (colorStr.indexOf('#') !== -1) {
|
||
|
var _color = colorStr.substring(1);
|
||
|
if (_color.length == 3) {
|
||
|
color = [];
|
||
|
for (var i = 0; i < _color.length; i++) {
|
||
|
var key = _color.charAt(i);
|
||
|
color.push(parseInt(key + key, 16) / 255);
|
||
|
}
|
||
|
} else if (_color.length == 6) {
|
||
|
color = [];
|
||
|
for (var i = 0; i < _color.length; i += 2) {
|
||
|
var key = _color.charAt(i);
|
||
|
var key2 = _color.charAt(i + 1);
|
||
|
color.push(parseInt(key + key2, 16) / 255);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return color;
|
||
|
}
|
||
|
|
||
|
var classCallCheck = function (instance, Constructor) {
|
||
|
if (!(instance instanceof Constructor)) {
|
||
|
throw new TypeError("Cannot call a class as a function");
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var createClass = function () {
|
||
|
function defineProperties(target, props) {
|
||
|
for (var i = 0; i < props.length; i++) {
|
||
|
var descriptor = props[i];
|
||
|
descriptor.enumerable = descriptor.enumerable || false;
|
||
|
descriptor.configurable = true;
|
||
|
if ("value" in descriptor) descriptor.writable = true;
|
||
|
Object.defineProperty(target, descriptor.key, descriptor);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return function (Constructor, protoProps, staticProps) {
|
||
|
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||
|
if (staticProps) defineProperties(Constructor, staticProps);
|
||
|
return Constructor;
|
||
|
};
|
||
|
}();
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
var inherits = function (subClass, superClass) {
|
||
|
if (typeof superClass !== "function" && superClass !== null) {
|
||
|
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
||
|
}
|
||
|
|
||
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||
|
constructor: {
|
||
|
value: subClass,
|
||
|
enumerable: false,
|
||
|
writable: true,
|
||
|
configurable: true
|
||
|
}
|
||
|
});
|
||
|
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
var possibleConstructorReturn = function (self, call) {
|
||
|
if (!self) {
|
||
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||
|
}
|
||
|
|
||
|
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
||
|
};
|
||
|
|
||
|
var OBJ = function () {
|
||
|
function OBJ(GL, obj) {
|
||
|
classCallCheck(this, OBJ);
|
||
|
|
||
|
this.GL = GL;
|
||
|
this.gl = GL.gl;
|
||
|
this.obj = obj = obj || {};
|
||
|
this.operate = [];
|
||
|
this.opearteID = 0;
|
||
|
this.opearteBuild = {};
|
||
|
this.color = colorTransform(obj.color || '#FFF');
|
||
|
}
|
||
|
|
||
|
createClass(OBJ, [{
|
||
|
key: 'translate',
|
||
|
value: function translate(x, y, z) {
|
||
|
var id = this.opearteID = this.opearteID;
|
||
|
this.operate.push({
|
||
|
id: id++,
|
||
|
name: 'translate',
|
||
|
value: [x || 0, y || 0, z || 0]
|
||
|
});
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
// useage
|
||
|
// rotate(30,'x')
|
||
|
// rotate(30,'y')
|
||
|
// rotate(30,'z')
|
||
|
// rotate(30,[1,1,0])
|
||
|
|
||
|
}, {
|
||
|
key: 'rotate',
|
||
|
value: function rotate(rad, axis) {
|
||
|
var _axis = null;
|
||
|
if (axis instanceof Array && axis.length == 3) {
|
||
|
_axis = axis;
|
||
|
} else {
|
||
|
switch (axis) {
|
||
|
case 'x':
|
||
|
_axis = [1, 0, 0];
|
||
|
break;
|
||
|
case 'y':
|
||
|
_axis = [0, 1, 0];
|
||
|
break;
|
||
|
case 'z':
|
||
|
_axis = [0, 0, 1];
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (_axis) {
|
||
|
var id = this.opearteID = this.opearteID;
|
||
|
this.operate.push({
|
||
|
id: id++,
|
||
|
name: 'rotate',
|
||
|
value: [rad, _axis]
|
||
|
});
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
}, {
|
||
|
key: 'scale',
|
||
|
value: function scale(x, y, z) {
|
||
|
var id = this.opearteID = this.opearteID;
|
||
|
this.operate.push({
|
||
|
id: id++,
|
||
|
name: 'scale',
|
||
|
value: [x || 1, y || 1, z || 1]
|
||
|
});
|
||
|
return this;
|
||
|
}
|
||
|
}, {
|
||
|
key: 'updateOpearte',
|
||
|
value: function updateOpearte() {
|
||
|
var mvMatrix = this.GL.camera.mvMatrix;
|
||
|
if (this.opearteBuild.ID === this.opearteID && this.opearteBuild.start === mvMatrix.toString()) {
|
||
|
mvMatrix = this.opearteBuild.result;
|
||
|
} else {
|
||
|
var start = mvMatrix.toString();
|
||
|
for (var i in this.operate) {
|
||
|
var type = this.operate[i].name;
|
||
|
var value = this.operate[i].value;
|
||
|
switch (type) {
|
||
|
case 'translate':
|
||
|
var mvNMatrix = mat4.create();
|
||
|
mat4.translate(mvNMatrix, mvMatrix, value);
|
||
|
mvMatrix = mvNMatrix;
|
||
|
break;
|
||
|
case 'rotate':
|
||
|
var mvNMatrix = mat4.create();
|
||
|
mat4.rotate(mvNMatrix, mvMatrix, value[0], value[1]);
|
||
|
mvMatrix = mvNMatrix;
|
||
|
break;
|
||
|
case 'scale':
|
||
|
var mvNMatrix = mat4.create();
|
||
|
mat4.scale(mvNMatrix, mvMatrix, value);
|
||
|
mvMatrix = mvNMatrix;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
this.opearteBuild = {
|
||
|
ID: this.opearteID,
|
||
|
result: mvMatrix,
|
||
|
start: start
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
}]);
|
||
|
return OBJ;
|
||
|
}();
|
||
|
|
||
|
var Plane = function (_Obj) {
|
||
|
inherits(Plane, _Obj);
|
||
|
|
||
|
function Plane(GL, obj) {
|
||
|
classCallCheck(this, Plane);
|
||
|
|
||
|
var _this = possibleConstructorReturn(this, (Plane.__proto__ || Object.getPrototypeOf(Plane)).call(this, GL, obj));
|
||
|
|
||
|
_this.width = obj.width || 10.0;
|
||
|
_this.height = obj.height || 10.0;
|
||
|
|
||
|
var color = _this.color;
|
||
|
|
||
|
_this.verticesColors = new Float32Array([-_this.width / 2, +_this.height / 2, 0.0, color[0], color[1], color[2], +_this.width / 2, +_this.height / 2, 0.0, color[0], color[1], color[2], +_this.width / 2, -_this.height / 2, 0.0, color[0], color[1], color[2], -_this.width / 2, -_this.height / 2, 0.0, color[0], color[1], color[2]]);
|
||
|
|
||
|
_this.indices = new Uint8Array([0, 1, 2, 0, 2, 3]);
|
||
|
return _this;
|
||
|
}
|
||
|
|
||
|
createClass(Plane, [{
|
||
|
key: 'render',
|
||
|
value: function render() {
|
||
|
var gl = this.gl;
|
||
|
var mvMatrix = this.GL.camera.mvMatrix;
|
||
|
|
||
|
// 顶点/颜色缓冲区操作
|
||
|
var vertexColorBuffer = this.gl.ubuffer || gl.createBuffer();
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, vertexColorBuffer);
|
||
|
gl.bufferData(gl.ARRAY_BUFFER, this.verticesColors, gl.STATIC_DRAW);
|
||
|
//
|
||
|
var FSIZE = this.verticesColors.BYTES_PER_ELEMENT;
|
||
|
//
|
||
|
gl.vertexAttribPointer(gl.aPosition, 3, gl.FLOAT, false, FSIZE * 6, 0);
|
||
|
gl.enableVertexAttribArray(gl.aPosition);
|
||
|
//
|
||
|
gl.vertexAttribPointer(gl.aColor, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3);
|
||
|
gl.enableVertexAttribArray(gl.aColor);
|
||
|
|
||
|
// 顶点索引缓冲区
|
||
|
var indexBuffer = gl.createBuffer();
|
||
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
||
|
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW);
|
||
|
|
||
|
// set mv
|
||
|
this.updateOpearte();
|
||
|
//
|
||
|
gl.uniformMatrix4fv(this.gl.uMVMatrix, false, this.opearteBuild.result);
|
||
|
gl.drawElements(gl.TRIANGLES, this.indices.length, gl.UNSIGNED_BYTE, 0);
|
||
|
}
|
||
|
}]);
|
||
|
return Plane;
|
||
|
}(OBJ);
|
||
|
|
||
|
var Wall = function () {
|
||
|
function Wall(GL, obj) {
|
||
|
classCallCheck(this, Wall);
|
||
|
|
||
|
this.GL = GL;
|
||
|
this.gl = GL.gl;
|
||
|
this.obj = obj = obj || {};
|
||
|
this.width = obj.thickness || 0.20;
|
||
|
this.height = obj.height || 3.0;
|
||
|
|
||
|
this.operate = [];
|
||
|
this.opearteID = 0;
|
||
|
this.opearteBuild = {};
|
||
|
var color = this.color = colorTransform(obj.color);
|
||
|
|
||
|
this.verticesColors = new Float32Array([-this.width / 2, +this.height / 2, 0.10, color[0], color[1], color[2], +this.width / 2, +this.height / 2, 0.10, color[0], color[1], color[2], +this.width / 2, -this.height / 2, 0.10, color[0], color[1], color[2], -this.width / 2, -this.height / 2, 0.10, color[0], color[1], color[2]]);
|
||
|
|
||
|
this.indices = new Uint8Array([0, 1, 2, 0, 2, 3]);
|
||
|
|
||
|
for (var i = 0; i < obj.path.length; i += 2) {
|
||
|
if (i === 0) {}
|
||
|
console.log(i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
createClass(Wall, [{
|
||
|
key: 'render',
|
||
|
value: function render() {
|
||
|
var gl = this.gl;
|
||
|
var mvMatrix = this.GL.camera.mvMatrix;
|
||
|
|
||
|
// 顶点/颜色缓冲区操作
|
||
|
var vertexColorBuffer = gl.createBuffer();
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, vertexColorBuffer);
|
||
|
gl.bufferData(gl.ARRAY_BUFFER, this.verticesColors, gl.STATIC_DRAW);
|
||
|
//
|
||
|
var FSIZE = this.verticesColors.BYTES_PER_ELEMENT;
|
||
|
//
|
||
|
gl.vertexAttribPointer(gl.aPosition, 3, gl.FLOAT, false, FSIZE * 6, 0);
|
||
|
gl.enableVertexAttribArray(gl.aPosition);
|
||
|
//
|
||
|
gl.vertexAttribPointer(gl.aColor, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3);
|
||
|
gl.enableVertexAttribArray(gl.aColor);
|
||
|
|
||
|
// 顶点索引缓冲区
|
||
|
var indexBuffer = gl.createBuffer();
|
||
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
||
|
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW);
|
||
|
|
||
|
gl.uniformMatrix4fv(this.gl.uMVMatrix, false, mvMatrix);
|
||
|
|
||
|
gl.drawElements(gl.TRIANGLES, this.indices.length, gl.UNSIGNED_BYTE, 0);
|
||
|
}
|
||
|
}]);
|
||
|
return Wall;
|
||
|
}();
|
||
|
|
||
|
var Path = function (_Obj) {
|
||
|
inherits(Path, _Obj);
|
||
|
|
||
|
function Path(GL, obj) {
|
||
|
classCallCheck(this, Path);
|
||
|
|
||
|
var _this = possibleConstructorReturn(this, (Path.__proto__ || Object.getPrototypeOf(Path)).call(this, GL, obj));
|
||
|
|
||
|
_this.width = obj.width || 10.0;
|
||
|
_this.height = obj.height || 10.0;
|
||
|
|
||
|
var color = _this.color;
|
||
|
var paths = obj.path;
|
||
|
_this.verticesColors = [];
|
||
|
paths.forEach(function (point) {
|
||
|
_this.verticesColors = _this.verticesColors.concat(point.concat(color));
|
||
|
});
|
||
|
_this.verticesColors = new Float32Array(_this.verticesColors);
|
||
|
return _this;
|
||
|
}
|
||
|
|
||
|
createClass(Path, [{
|
||
|
key: 'render',
|
||
|
value: function render() {
|
||
|
var gl = this.gl;
|
||
|
var mvMatrix = this.GL.camera.mvMatrix;
|
||
|
|
||
|
// 顶点/颜色缓冲区操作
|
||
|
var vertexColorBuffer = this.gl.ubuffer || gl.createBuffer();
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, vertexColorBuffer);
|
||
|
gl.bufferData(gl.ARRAY_BUFFER, this.verticesColors, gl.STATIC_DRAW);
|
||
|
//
|
||
|
var FSIZE = this.verticesColors.BYTES_PER_ELEMENT;
|
||
|
//
|
||
|
gl.vertexAttribPointer(gl.aPosition, 3, gl.FLOAT, false, FSIZE * 6, 0);
|
||
|
gl.enableVertexAttribArray(gl.aPosition);
|
||
|
//
|
||
|
gl.vertexAttribPointer(gl.aColor, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3);
|
||
|
gl.enableVertexAttribArray(gl.aColor);
|
||
|
vertexColorBuffer = null;
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, vertexColorBuffer);
|
||
|
|
||
|
// set mv
|
||
|
this.updateOpearte();
|
||
|
//
|
||
|
|
||
|
gl.uniformMatrix4fv(this.gl.uMVMatrix, false, this.opearteBuild.result);
|
||
|
gl.drawArrays(gl.LINE_STRIP, 0, this.verticesColors.length / 6);
|
||
|
}
|
||
|
}]);
|
||
|
return Path;
|
||
|
}(OBJ);
|
||
|
|
||
|
var Path$1 = function (_Obj) {
|
||
|
inherits(Path, _Obj);
|
||
|
|
||
|
function Path(GL, obj) {
|
||
|
classCallCheck(this, Path);
|
||
|
|
||
|
var _this = possibleConstructorReturn(this, (Path.__proto__ || Object.getPrototypeOf(Path)).call(this, GL, obj));
|
||
|
|
||
|
var width = _this.width = obj.size.width || 10.0;
|
||
|
var height = _this.height = obj.size.height || 10.0;
|
||
|
|
||
|
var paths = obj.path;
|
||
|
|
||
|
var posX = obj.pos[0];
|
||
|
var posY = obj.pos[1];
|
||
|
var length = obj.size.length;
|
||
|
var color = _this.color = colorTransform(obj.color);
|
||
|
_this.verticesColors = new Float32Array([posX - width / 2, posY - height / 2, 0, color[0], color[1], color[2], posX + width / 2, posY - height / 2, 0, color[0], color[1], color[2], posX + width / 2, posY + height / 2, 0, color[0], color[1], color[2], posX - width / 2, posY + height / 2, 0, color[0], color[1], color[2], posX - width / 2, posY - height / 2, length, color[0], color[1], color[2], posX + width / 2, posY - height / 2, length, color[0], color[1], color[2], posX + width / 2, posY + height / 2, length, color[0], color[1], color[2], posX - width / 2, posY + height / 2, length, color[0], color[1], color[2]]);
|
||
|
_this.indices = new Uint8Array([3, 0, 2, 1, 5, 6, 4, 7, 0, 3, 2, 7, 6, 4, 5, 0, 1]);
|
||
|
|
||
|
// this.verticesColors = new Float32Array([-this.width / 2, +this.height / 2, 0.0, color[0], color[1], color[2], +this.width / 2, +this.height / 2, 0.0, color[0], color[1], color[2], +this.width / 2, -this.height / 2, 0.0, color[0], color[1], color[2], -this.width / 2, -this.height / 2, 0.0, color[0], color[1], color[2]]);
|
||
|
|
||
|
// this.indices = new Uint8Array([
|
||
|
// 0, 1, 2, 0, 2, 3,
|
||
|
// ]);
|
||
|
return _this;
|
||
|
}
|
||
|
|
||
|
createClass(Path, [{
|
||
|
key: 'render',
|
||
|
value: function render() {
|
||
|
var gl = this.gl;
|
||
|
var mvMatrix = this.GL.camera.mvMatrix;
|
||
|
|
||
|
// 顶点/颜色缓冲区操作
|
||
|
var vertexColorBuffer = this.gl.ubuffer;
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, vertexColorBuffer);
|
||
|
gl.bufferData(gl.ARRAY_BUFFER, this.verticesColors, gl.STATIC_DRAW);
|
||
|
|
||
|
//
|
||
|
var FSIZE = this.verticesColors.BYTES_PER_ELEMENT;
|
||
|
//
|
||
|
gl.vertexAttribPointer(gl.aPosition, 3, gl.FLOAT, false, FSIZE * 6, 0);
|
||
|
gl.enableVertexAttribArray(gl.aPosition);
|
||
|
//
|
||
|
gl.vertexAttribPointer(gl.aColor, 3, gl.FLOAT, false, FSIZE * 6, FSIZE * 3);
|
||
|
gl.enableVertexAttribArray(gl.aColor);
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
||
|
// 顶点索引缓冲区
|
||
|
var indexBuffer = this.gl.ibuffer;
|
||
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
|
||
|
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW);
|
||
|
|
||
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
||
|
|
||
|
// set mv
|
||
|
this.updateOpearte();
|
||
|
//
|
||
|
gl.uniformMatrix4fv(this.gl.uMVMatrix, false, this.opearteBuild.result);
|
||
|
gl.drawElements(gl.TRIANGLE_STRIP, this.indices.length, gl.UNSIGNED_BYTE, 0);
|
||
|
}
|
||
|
}]);
|
||
|
return Path;
|
||
|
}(OBJ);
|
||
|
|
||
|
var VSHADER_SOURCE = 'attribute vec4 aPosition;\n' + 'attribute vec4 aColor;\n' + 'uniform mat4 uMVMatrix;\n' + 'uniform mat4 uPMatrix;\n' + 'varying vec4 vColor;\n' + 'void main() {\n' + ' gl_Position = uPMatrix * uMVMatrix * aPosition;\n' + ' vColor = aColor;\n' + '}\n';
|
||
|
|
||
|
var FSHADER_SOURCE = '#ifdef GL_ES\n' + 'precision mediump float;\n' + '#endif\n' + 'varying vec4 vColor;\n' + 'void main() {\n' + ' gl_FragColor = vColor;\n' + '}\n';
|
||
|
|
||
|
var GL = function () {
|
||
|
function GL(dom) {
|
||
|
classCallCheck(this, GL);
|
||
|
|
||
|
var self = this;
|
||
|
|
||
|
var renderList = this.renderList = [];
|
||
|
|
||
|
var Dom = document.getElementById(dom);
|
||
|
var DomSty = getComputedStyle(Dom);
|
||
|
|
||
|
var canvas = document.createElement('canvas');
|
||
|
canvas.height = parseInt(DomSty.height);
|
||
|
canvas.width = parseInt(DomSty.width);
|
||
|
Dom.appendChild(canvas);
|
||
|
|
||
|
var gl = this.gl = getWebGLContext(canvas);
|
||
|
|
||
|
initShaders(gl, VSHADER_SOURCE, FSHADER_SOURCE);
|
||
|
this.gl.ubuffer = gl.createBuffer();
|
||
|
this.gl.ibuffer = gl.createBuffer();
|
||
|
|
||
|
gl.enable(gl.DEPTH_TEST);
|
||
|
gl.clearColor(0, 0, 0, 1.0);
|
||
|
|
||
|
//init camear
|
||
|
self.camera = new Camera(this.gl);
|
||
|
|
||
|
function draw() {
|
||
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||
|
// console.time('draw')
|
||
|
for (var i in renderList) {
|
||
|
renderList[i].render();
|
||
|
}
|
||
|
// console.timeEnd('draw')
|
||
|
requestAnimationFrame(draw);
|
||
|
}
|
||
|
|
||
|
requestAnimationFrame(draw);
|
||
|
}
|
||
|
|
||
|
createClass(GL, [{
|
||
|
key: 'Plane',
|
||
|
value: function Plane$$1(obj) {
|
||
|
var plane = new Plane(this, obj);
|
||
|
this.renderList.push(plane);
|
||
|
return plane;
|
||
|
}
|
||
|
}, {
|
||
|
key: 'Wall',
|
||
|
value: function Wall$$1(obj) {
|
||
|
var wall = new Wall(this, obj);
|
||
|
this.renderList.push(wall);
|
||
|
return wall;
|
||
|
}
|
||
|
}, {
|
||
|
key: 'Path',
|
||
|
value: function Path$$1(obj) {
|
||
|
var path = new Path(this, obj);
|
||
|
this.renderList.push(path);
|
||
|
return path;
|
||
|
}
|
||
|
}, {
|
||
|
key: 'Cuboid',
|
||
|
value: function Cuboid(obj) {
|
||
|
var cuboid = new Path$1(this, obj);
|
||
|
this.renderList.push(cuboid);
|
||
|
return cuboid;
|
||
|
}
|
||
|
}]);
|
||
|
return GL;
|
||
|
}();
|
||
|
|
||
|
var china = {
|
||
|
"type": "FeatureCollection",
|
||
|
"features": [{
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "65",
|
||
|
"name": "新疆",
|
||
|
"cp": [84.9023, 41.748],
|
||
|
"childNum": 18
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[96.416, 42.7588], [96.416, 42.7148], [95.9766, 42.4951], [96.0645, 42.3193], [96.2402, 42.2314], [95.9766, 41.9238], [95.2734, 41.6162], [95.1855, 41.792], [94.5703, 41.4844], [94.043, 41.0889], [93.8672, 40.6934], [93.0762, 40.6494], [92.6367, 39.6387], [92.373, 39.3311], [92.373, 39.1113], [92.373, 39.0234], [90.1758, 38.4961], [90.3516, 38.2324], [90.6152, 38.3203], [90.5273, 37.8369], [91.0547, 37.4414], [91.3184, 37.0898], [90.7031, 36.7822], [90.791, 36.6064], [91.0547, 36.5186], [91.0547, 36.0791], [90.8789, 36.0352], [90, 36.2549], [89.9121, 36.0791], [89.7363, 36.0791], [89.209, 36.2988], [88.7695, 36.3428], [88.5938, 36.4746], [87.3633, 36.4307], [86.2207, 36.167], [86.1328, 35.8594], [85.6055, 35.6836], [85.0781, 35.7275], [84.1992, 35.376], [83.1445, 35.4199], [82.8809, 35.6836], [82.4414, 35.7275], [82.002, 35.332], [81.6504, 35.2441], [80.4199, 35.4199], [80.2441, 35.2881], [80.332, 35.1563], [80.2441, 35.2002], [79.8926, 34.8047], [79.8047, 34.4971], [79.1016, 34.4531], [79.0137, 34.3213], [78.2227, 34.7168], [78.0469, 35.2441], [78.0469, 35.5078], [77.4316, 35.4639], [76.8164, 35.6396], [76.5527, 35.8594], [76.2012, 35.8154], [75.9375, 36.0352], [76.0254, 36.4746], [75.8496, 36.6943], [75.498, 36.7383], [75.4102, 36.958], [75.0586, 37.002], [74.8828, 36.9141], [74.7949, 37.0459], [74.5313, 37.0898], [74.5313, 37.2217], [74.8828, 37.2217], [75.1465, 37.4414], [74.8828, 37.5732], [74.9707, 37.749], [74.8828, 38.4521], [74.3555, 38.6719], [74.1797, 38.6719], [74.0918, 38.54], [73.8281, 38.584], [73.7402, 38.8477], [73.8281, 38.9795], [73.4766, 39.375], [73.916, 39.5068], [73.916, 39.6826], [73.8281, 39.7705], [74.0039, 40.0342], [74.8828, 40.3418], [74.7949, 40.5176], [75.2344, 40.4297], [75.5859, 40.6494], [75.7617, 40.2979], [76.377, 40.3857], [76.9043, 41.001], [77.6074, 41.001], [78.1348, 41.2207], [78.1348, 41.3965], [80.1563, 42.0557], [80.2441, 42.2754], [80.1563, 42.627], [80.2441, 42.8467], [80.5078, 42.8906], [80.4199, 43.0664], [80.7715, 43.1982], [80.4199, 44.165], [80.4199, 44.6045], [79.9805, 44.8242], [79.9805, 44.9561], [81.7383, 45.3955], [82.0898, 45.2197], [82.5293, 45.2197], [82.2656, 45.6592], [83.0566, 47.2412], [83.6719, 47.0215], [84.7266, 47.0215], [84.9023, 46.8896], [85.5176, 47.0654], [85.6934, 47.2852], [85.5176, 48.1201], [85.7813, 48.4277], [86.5723, 48.5596], [86.8359, 48.8232], [86.748, 48.9551], [86.8359, 49.1309], [87.8027, 49.1748], [87.8906, 48.999], [87.7148, 48.9111], [88.0664, 48.7354], [87.9785, 48.6035], [88.5059, 48.3838], [88.6816, 48.1641], [89.1211, 47.9883], [89.5605, 48.0322], [89.7363, 47.8564], [90.0879, 47.8564], [90.3516, 47.6807], [90.5273, 47.2412], [90.8789, 46.9775], [91.0547, 46.582], [90.8789, 46.3184], [91.0547, 46.0107], [90.7031, 45.7471], [90.7031, 45.5273], [90.8789, 45.2197], [91.582, 45.0879], [93.5156, 44.9561], [94.7461, 44.3408], [95.3613, 44.2969], [95.3613, 44.0332], [95.5371, 43.9014], [95.8887, 43.2422], [96.3281, 42.9346], [96.416, 42.7588]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "54",
|
||
|
"name": "西藏",
|
||
|
"cp": [88.7695, 31.6846],
|
||
|
"childNum": 7
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[79.0137, 34.3213], [79.1016, 34.4531], [79.8047, 34.4971], [79.8926, 34.8047], [80.2441, 35.2002], [80.332, 35.1563], [80.2441, 35.2881], [80.4199, 35.4199], [81.6504, 35.2441], [82.002, 35.332], [82.4414, 35.7275], [82.8809, 35.6836], [83.1445, 35.4199], [84.1992, 35.376], [85.0781, 35.7275], [85.6055, 35.6836], [86.1328, 35.8594], [86.2207, 36.167], [87.3633, 36.4307], [88.5938, 36.4746], [88.7695, 36.3428], [89.209, 36.2988], [89.7363, 36.0791], [89.3848, 36.0352], [89.4727, 35.9033], [89.7363, 35.7715], [89.7363, 35.4199], [89.4727, 35.376], [89.4727, 35.2441], [89.5605, 34.8926], [89.8242, 34.8486], [89.7363, 34.6729], [89.8242, 34.3652], [89.6484, 34.0137], [90.0879, 33.4863], [90.7031, 33.1348], [91.4063, 33.1348], [91.9336, 32.8271], [92.1973, 32.8271], [92.2852, 32.7393], [92.9883, 32.7393], [93.5156, 32.4756], [93.7793, 32.5635], [94.1309, 32.4316], [94.6582, 32.6074], [95.1855, 32.4316], [95.0098, 32.2998], [95.1855, 32.3438], [95.2734, 32.2119], [95.3613, 32.168], [95.3613, 31.9922], [95.4492, 31.8164], [95.8008, 31.6846], [95.9766, 31.8164], [96.1523, 31.5967], [96.2402, 31.9482], [96.5039, 31.7285], [96.8555, 31.6846], [96.7676, 31.9922], [97.2949, 32.0801], [97.3828, 32.5635], [97.7344, 32.5195], [98.1738, 32.3438], [98.4375, 31.8604], [98.877, 31.4209], [98.6133, 31.2012], [98.9648, 30.7617], [99.1406, 29.2676], [98.9648, 29.1357], [98.9648, 28.8281], [98.7891, 28.8721], [98.7891, 29.0039], [98.7012, 28.916], [98.6133, 28.5205], [98.7891, 28.3447], [98.7012, 28.2129], [98.3496, 28.125], [98.2617, 28.3887], [98.1738, 28.125], [97.5586, 28.5205], [97.2949, 28.0811], [97.3828, 27.9053], [97.0313, 27.7295], [96.5039, 28.125], [95.7129, 28.2568], [95.3613, 28.125], [95.2734, 27.9492], [94.2188, 27.5537], [93.8672, 27.0264], [93.6035, 26.9385], [92.1094, 26.8506], [92.0215, 27.4658], [91.582, 27.5537], [91.582, 27.9053], [91.4063, 28.0371], [91.0547, 27.8613], [90.7031, 28.0811], [89.8242, 28.2129], [89.6484, 28.1689], [89.1211, 27.5977], [89.1211, 27.334], [89.0332, 27.2021], [88.7695, 27.4219], [88.8574, 27.9932], [88.6816, 28.125], [88.1543, 27.9053], [87.8906, 27.9492], [87.7148, 27.8174], [87.0996, 27.8174], [86.748, 28.125], [86.5723, 28.125], [86.4844, 27.9053], [86.1328, 28.125], [86.0449, 27.9053], [85.6934, 28.3447], [85.6055, 28.2568], [85.166, 28.3447], [85.166, 28.6523], [84.9023, 28.5645], [84.4629, 28.7402], [84.2871, 28.8721], [84.1992, 29.2236], [84.1113, 29.2676], [83.584, 29.1797], [83.2324, 29.5752], [82.1777, 30.0586], [82.0898, 30.3223], [81.3867, 30.3662], [81.2109, 30.0146], [81.0352, 30.2344], [80.0684, 30.5859], [79.7168, 30.9375], [79.0137, 31.0693], [78.75, 31.333], [78.8379, 31.5967], [78.6621, 31.8164], [78.75, 31.9043], [78.4863, 32.124], [78.3984, 32.5195], [78.75, 32.6953], [78.9258, 32.3438], [79.2773, 32.5635], [79.1016, 33.1787], [78.6621, 33.6621], [78.6621, 34.1016], [78.9258, 34.1455], [79.0137, 34.3213]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "15",
|
||
|
"name": "内蒙古",
|
||
|
"cp": [117.5977, 44.3408],
|
||
|
"childNum": 12
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[97.207, 42.8027], [99.4922, 42.583], [100.8105, 42.6709], [101.7773, 42.4951], [102.041, 42.2314], [102.7441, 42.1436], [103.3594, 41.8799], [103.8867, 41.792], [104.502, 41.8799], [104.502, 41.6602], [105.0293, 41.5723], [105.7324, 41.9238], [107.4023, 42.4512], [109.4238, 42.4512], [110.3906, 42.7588], [111.0059, 43.3301], [111.9727, 43.6816], [111.9727, 43.8135], [111.4453, 44.3848], [111.7969, 45], [111.9727, 45.0879], [113.6426, 44.7363], [114.1699, 44.9561], [114.5215, 45.3955], [115.6641, 45.4395], [116.1914, 45.7031], [116.2793, 45.9668], [116.543, 46.2744], [117.334, 46.3623], [117.4219, 46.582], [117.7734, 46.5381], [118.3008, 46.7578], [118.7402, 46.7139], [118.916, 46.7578], [119.0918, 46.6699], [119.707, 46.626], [119.9707, 46.7139], [119.707, 47.1973], [118.4766, 47.9883], [117.8613, 48.0322], [117.334, 47.6807], [116.8066, 47.9004], [116.1914, 47.8564], [115.9277, 47.6807], [115.5762, 47.9004], [115.4883, 48.1641], [115.8398, 48.252], [115.8398, 48.5596], [116.7188, 49.834], [117.7734, 49.5264], [118.5645, 49.9219], [119.2676, 50.0977], [119.3555, 50.3174], [119.1797, 50.3613], [119.5313, 50.7568], [119.5313, 50.8887], [119.707, 51.0645], [120.1465, 51.6797], [120.6738, 51.9434], [120.7617, 52.1191], [120.7617, 52.251], [120.5859, 52.3389], [120.6738, 52.5146], [120.4102, 52.6465], [120.0586, 52.6025], [120.0586, 52.7344], [120.8496, 53.2617], [121.4648, 53.3496], [121.8164, 53.042], [121.2012, 52.5586], [121.6406, 52.4268], [121.7285, 52.2949], [121.9922, 52.2949], [122.168, 52.5146], [122.6953, 52.251], [122.6074, 52.0752], [122.959, 51.3281], [123.3105, 51.2402], [123.6621, 51.3721], [124.3652, 51.2842], [124.541, 51.3721], [124.8926, 51.3721], [125.0684, 51.6357], [125.332, 51.6357], [126.0352, 51.0205], [125.7715, 50.7568], [125.7715, 50.5371], [125.332, 50.1416], [125.1563, 49.834], [125.2441, 49.1748], [124.8047, 49.1309], [124.4531, 48.1201], [124.2773, 48.5156], [122.4316, 47.373], [123.0469, 46.7139], [123.3984, 46.8896], [123.3984, 46.9775], [123.4863, 46.9775], [123.5742, 46.8457], [123.5742, 46.8896], [123.5742, 46.6699], [123.0469, 46.582], [123.2227, 46.2305], [122.7832, 46.0107], [122.6953, 45.7031], [122.4316, 45.8789], [122.2559, 45.791], [121.8164, 46.0107], [121.7285, 45.7471], [121.9043, 45.7031], [122.2559, 45.2637], [122.0801, 44.8682], [122.3438, 44.2529], [123.1348, 44.4727], [123.4863, 43.7256], [123.3105, 43.5059], [123.6621, 43.374], [123.5742, 43.0225], [123.3105, 42.9785], [123.1348, 42.8027], [122.7832, 42.7148], [122.3438, 42.8467], [122.3438, 42.6709], [121.9922, 42.7148], [121.7285, 42.4512], [121.4648, 42.4951], [120.498, 42.0996], [120.1465, 41.7041], [119.8828, 42.1875], [119.5313, 42.3633], [119.3555, 42.2754], [119.2676, 41.7041], [119.4434, 41.6162], [119.2676, 41.3086], [118.3887, 41.3086], [118.125, 41.748], [118.3008, 41.792], [118.3008, 42.0996], [118.125, 42.0557], [117.9492, 42.2314], [118.0371, 42.4072], [117.7734, 42.627], [117.5098, 42.583], [117.334, 42.4512], [116.8945, 42.4072], [116.8066, 42.0117], [116.2793, 42.0117], [116.0156, 41.792], [115.9277, 41.9238], [115.2246, 41.5723], [114.9609, 41.6162], [114.873, 42.0996], [114.5215, 42.1436], [114.1699, 41.792], [114.2578, 41.5723], [113.9063, 41.4404], [113.9941, 41.2207], [113.9063, 41.1328], [114.082, 40.7373], [114.082, 40.5176], [113.8184, 40.5176], [113.5547, 40.3418], [113.2031, 40.3857], [112.7637, 40.166], [112.3242, 40.2539], [111.9727, 39.5947], [111.4453, 39.6387], [111.3574, 39.4189], [111.0938, 39.375], [111.0938, 39.5947], [110.6543, 39.2871], [110.127, 39.4629], [110.2148, 39.2871], [109.8633, 39.2432], [109.9512, 39.1553], [108.9844, 38.3203], [109.0723, 38.0127], [108.8965, 37.9688], [108.8086, 38.0127], [108.7207, 37.7051], [108.1934, 37.6172], [107.666, 37.8809], [107.3145, 38.1006], [106.7871, 38.1885], [106.5234, 38.3203], [106.9629, 38.9795], [106.7871, 39.375], [106.3477, 39.2871], [105.9082, 38.7158], [105.8203, 37.793], [104.3262, 37.4414], [103.4473, 37.8369], [103.3594, 38.0127], [103.5352, 38.1445], [103.4473, 38.3643], [104.2383, 38.9795], [104.0
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "63",
|
||
|
"name": "青海",
|
||
|
"cp": [96.2402, 35.4199],
|
||
|
"childNum": 8
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[89.7363, 36.0791], [89.9121, 36.0791], [90, 36.2549], [90.8789, 36.0352], [91.0547, 36.0791], [91.0547, 36.5186], [90.791, 36.6064], [90.7031, 36.7822], [91.3184, 37.0898], [91.0547, 37.4414], [90.5273, 37.8369], [90.6152, 38.3203], [90.3516, 38.2324], [90.1758, 38.4961], [92.373, 39.0234], [92.373, 39.1113], [93.1641, 39.1992], [93.1641, 38.9795], [93.6914, 38.9355], [93.8672, 38.7158], [94.3066, 38.7598], [94.5703, 38.3643], [95.0098, 38.4082], [95.4492, 38.2764], [95.7129, 38.3643], [96.2402, 38.1006], [96.416, 38.2324], [96.6797, 38.1885], [96.6797, 38.4521], [97.1191, 38.584], [97.0313, 39.1992], [98.1738, 38.8037], [98.3496, 39.0234], [98.6133, 38.9355], [98.7891, 39.0674], [99.1406, 38.9355], [99.8438, 38.3643], [100.1953, 38.2764], [100.0195, 38.4521], [100.1074, 38.4961], [100.459, 38.2764], [100.7227, 38.2324], [101.1621, 37.8369], [101.5137, 37.8809], [101.7773, 37.6172], [101.9531, 37.7051], [102.1289, 37.4414], [102.5684, 37.1777], [102.4805, 36.958], [102.6563, 36.8262], [102.5684, 36.7383], [102.832, 36.3428], [103.0078, 36.2549], [102.9199, 36.0791], [102.9199, 35.9033], [102.6563, 35.7715], [102.832, 35.5957], [102.4805, 35.5957], [102.3047, 35.4199], [102.3926, 35.2002], [101.9531, 34.8486], [101.9531, 34.6289], [102.2168, 34.4092], [102.1289, 34.2773], [101.6895, 34.1016], [100.9863, 34.3652], [100.8105, 34.2773], [101.25, 33.6621], [101.5137, 33.7061], [101.6016, 33.5303], [101.7773, 33.5303], [101.6895, 33.3105], [101.7773, 33.2227], [101.6016, 33.1348], [101.1621, 33.2227], [101.25, 32.6953], [100.7227, 32.6514], [100.7227, 32.5195], [100.3711, 32.7393], [100.1074, 32.6514], [100.1074, 32.8711], [99.8438, 33.0029], [99.7559, 32.7393], [99.2285, 32.915], [99.2285, 33.0469], [98.877, 33.1787], [98.4375, 34.0576], [97.8223, 34.1895], [97.6465, 34.1016], [97.7344, 33.9258], [97.3828, 33.8818], [97.4707, 33.5742], [97.7344, 33.3984], [97.3828, 32.8711], [97.4707, 32.6953], [97.7344, 32.5195], [97.3828, 32.5635], [97.2949, 32.0801], [96.7676, 31.9922], [96.8555, 31.6846], [96.5039, 31.7285], [96.2402, 31.9482], [96.1523, 31.5967], [95.9766, 31.8164], [95.8008, 31.6846], [95.4492, 31.8164], [95.3613, 31.9922], [95.3613, 32.168], [95.2734, 32.2119], [95.1855, 32.3438], [95.0098, 32.2998], [95.1855, 32.4316], [94.6582, 32.6074], [94.1309, 32.4316], [93.7793, 32.5635], [93.5156, 32.4756], [92.9883, 32.7393], [92.2852, 32.7393], [92.1973, 32.8271], [91.9336, 32.8271], [91.4063, 33.1348], [90.7031, 33.1348], [90.0879, 33.4863], [89.6484, 34.0137], [89.8242, 34.3652], [89.7363, 34.6729], [89.8242, 34.8486], [89.5605, 34.8926], [89.4727, 35.2441], [89.4727, 35.376], [89.7363, 35.4199], [89.7363, 35.7715], [89.4727, 35.9033], [89.3848, 36.0352], [89.7363, 36.0791]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "51",
|
||
|
"name": "四川",
|
||
|
"cp": [102.9199, 30.1904],
|
||
|
"childNum": 21
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[101.7773, 33.5303], [101.8652, 33.5742], [101.9531, 33.4424], [101.8652, 33.0908], [102.4805, 33.4424], [102.2168, 33.9258], [102.9199, 34.3213], [103.0957, 34.1895], [103.1836, 33.7939], [104.1504, 33.6182], [104.2383, 33.3984], [104.4141, 33.3105], [104.3262, 33.2227], [104.4141, 33.0469], [104.3262, 32.8711], [104.4141, 32.7393], [105.2051, 32.6074], [105.3809, 32.7393], [105.3809, 32.8711], [105.4688, 32.915], [105.5566, 32.7393], [106.084, 32.8711], [106.084, 32.7393], [106.3477, 32.6514], [107.0508, 32.6953], [107.1387, 32.4756], [107.2266, 32.4316], [107.4023, 32.5195], [108.0176, 32.168], [108.2813, 32.2559], [108.5449, 32.2119], [108.3691, 32.168], [108.2813, 31.9043], [108.5449, 31.6846], [108.1934, 31.5088], [107.9297, 30.8496], [107.4902, 30.8496], [107.4023, 30.7617], [107.4902, 30.6299], [107.0508, 30.0146], [106.7871, 30.0146], [106.6113, 30.3223], [106.2598, 30.1904], [105.8203, 30.4541], [105.6445, 30.2783], [105.5566, 30.1025], [105.7324, 29.8828], [105.293, 29.5313], [105.4688, 29.3115], [105.7324, 29.2676], [105.8203, 28.96], [106.2598, 28.8721], [106.3477, 28.5205], [105.9961, 28.7402], [105.6445, 28.4326], [105.9082, 28.125], [106.1719, 28.125], [106.3477, 27.8174], [105.6445, 27.6416], [105.5566, 27.7734], [105.293, 27.7295], [105.2051, 27.9932], [105.0293, 28.0811], [104.8535, 27.9053], [104.4141, 27.9492], [104.3262, 28.0371], [104.4141, 28.125], [104.4141, 28.2568], [104.2383, 28.4326], [104.4141, 28.6084], [103.8867, 28.6523], [103.7988, 28.3008], [103.4473, 28.125], [103.4473, 27.7734], [102.9199, 27.29], [103.0078, 26.3672], [102.6563, 26.1914], [102.5684, 26.3672], [102.1289, 26.1035], [101.8652, 26.0596], [101.6016, 26.2354], [101.6895, 26.3672], [101.4258, 26.5869], [101.4258, 26.8066], [101.4258, 26.7188], [101.1621, 27.0264], [101.1621, 27.1582], [100.7227, 27.8613], [100.3711, 27.8174], [100.2832, 27.7295], [100.0195, 28.125], [100.1953, 28.3447], [99.668, 28.8281], [99.4043, 28.5205], [99.4043, 28.1689], [99.2285, 28.3008], [99.1406, 29.2676], [98.9648, 30.7617], [98.6133, 31.2012], [98.877, 31.4209], [98.4375, 31.8604], [98.1738, 32.3438], [97.7344, 32.5195], [97.4707, 32.6953], [97.3828, 32.8711], [97.7344, 33.3984], [97.4707, 33.5742], [97.3828, 33.8818], [97.7344, 33.9258], [97.6465, 34.1016], [97.8223, 34.1895], [98.4375, 34.0576], [98.877, 33.1787], [99.2285, 33.0469], [99.2285, 32.915], [99.7559, 32.7393], [99.8438, 33.0029], [100.1074, 32.8711], [100.1074, 32.6514], [100.3711, 32.7393], [100.7227, 32.5195], [100.7227, 32.6514], [101.25, 32.6953], [101.1621, 33.2227], [101.6016, 33.1348], [101.7773, 33.2227], [101.6895, 33.3105], [101.7773, 33.5303]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "23",
|
||
|
"name": "黑龙江",
|
||
|
"cp": [128.1445, 48.5156],
|
||
|
"childNum": 13
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[121.4648, 53.3496], [123.6621, 53.5693], [124.8926, 53.0859], [125.0684, 53.2178], [125.5957, 53.0859], [125.6836, 52.9102], [126.123, 52.7783], [126.0352, 52.6025], [126.2109, 52.5146], [126.3867, 52.2949], [126.3867, 52.207], [126.5625, 52.1631], [126.4746, 51.9434], [126.9141, 51.3721], [126.8262, 51.2842], [127.002, 51.3281], [126.9141, 51.1084], [127.2656, 50.7568], [127.3535, 50.2734], [127.6172, 50.2295], [127.5293, 49.8779], [127.793, 49.6143], [128.7598, 49.5703], [129.1113, 49.3506], [129.4629, 49.4385], [130.2539, 48.8672], [130.6934, 48.8672], [130.5176, 48.6475], [130.8691, 48.2959], [130.6934, 48.1201], [131.0449, 47.6807], [132.5391, 47.7246], [132.627, 47.9443], [133.0664, 48.1201], [133.5059, 48.1201], [134.209, 48.3838], [135.0879, 48.4277], [134.7363, 48.252], [134.5605, 47.9883], [134.7363, 47.6807], [134.5605, 47.4609], [134.3848, 47.4609], [134.209, 47.2852], [134.209, 47.1533], [133.8574, 46.5381], [133.9453, 46.2744], [133.5059, 45.835], [133.418, 45.5713], [133.2422, 45.5273], [133.0664, 45.1318], [132.8906, 45.0439], [131.9238, 45.3516], [131.5723, 45.0439], [131.0449, 44.8682], [131.3086, 44.0771], [131.2207, 43.7256], [131.3086, 43.4619], [130.8691, 43.418], [130.5176, 43.6377], [130.3418, 43.9893], [129.9902, 43.8574], [129.9023, 44.0332], [129.8145, 43.9014], [129.2871, 43.8135], [129.1992, 43.5938], [128.8477, 43.5498], [128.4961, 44.165], [128.4082, 44.4727], [128.0566, 44.3408], [128.0566, 44.1211], [127.7051, 44.1211], [127.5293, 44.6045], [127.0898, 44.6045], [127.002, 44.7803], [127.0898, 45], [126.9141, 45.1318], [126.5625, 45.2637], [126.0352, 45.1758], [125.7715, 45.3076], [125.6836, 45.5273], [125.0684, 45.3955], [124.8926, 45.5273], [124.3652, 45.4395], [124.0137, 45.7471], [123.9258, 46.2305], [123.2227, 46.2305], [123.0469, 46.582], [123.5742, 46.6699], [123.5742, 46.8896], [123.5742, 46.8457], [123.4863, 46.9775], [123.3984, 46.9775], [123.3984, 46.8896], [123.0469, 46.7139], [122.4316, 47.373], [124.2773, 48.5156], [124.4531, 48.1201], [124.8047, 49.1309], [125.2441, 49.1748], [125.1563, 49.834], [125.332, 50.1416], [125.7715, 50.5371], [125.7715, 50.7568], [126.0352, 51.0205], [125.332, 51.6357], [125.0684, 51.6357], [124.8926, 51.3721], [124.541, 51.3721], [124.3652, 51.2842], [123.6621, 51.3721], [123.3105, 51.2402], [122.959, 51.3281], [122.6074, 52.0752], [122.6953, 52.251], [122.168, 52.5146], [121.9922, 52.2949], [121.7285, 52.2949], [121.6406, 52.4268], [121.2012, 52.5586], [121.8164, 53.042], [121.4648, 53.3496]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "62",
|
||
|
"name": "甘肃",
|
||
|
"cp": [95.7129, 40.166],
|
||
|
"childNum": 14
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[96.416, 42.7148], [97.207, 42.8027], [97.8223, 41.748], [97.8223, 41.6162], [97.4707, 41.4844], [98.3496, 40.9131], [98.3496, 40.5615], [98.6133, 40.6494], [98.5254, 40.7373], [98.7891, 40.6055], [98.9648, 40.7813], [99.0527, 40.6934], [99.2285, 40.8691], [99.9316, 41.001], [100.1953, 40.6494], [100.1074, 40.2539], [99.4922, 39.8584], [100.0195, 39.7705], [100.5469, 39.4189], [100.8105, 39.4189], [100.9863, 38.9355], [101.25, 39.0234], [101.3379, 38.7598], [101.7773, 38.6719], [102.041, 38.8916], [101.8652, 39.1113], [102.4805, 39.2432], [103.0078, 39.1113], [103.3594, 39.3311], [104.0625, 39.4189], [104.2383, 38.9795], [103.4473, 38.3643], [103.5352, 38.1445], [103.3594, 38.0127], [103.4473, 37.8369], [104.3262, 37.4414], [104.5898, 37.4414], [104.5898, 37.2217], [104.8535, 37.2217], [105.293, 36.8262], [105.2051, 36.6943], [105.4688, 36.123], [105.293, 35.9912], [105.3809, 35.7715], [105.7324, 35.7275], [105.8203, 35.5518], [105.9961, 35.4639], [105.9082, 35.4199], [105.9961, 35.4199], [106.084, 35.376], [106.2598, 35.4199], [106.3477, 35.2441], [106.5234, 35.332], [106.4355, 35.6836], [106.6992, 35.6836], [106.9629, 35.8154], [106.875, 36.123], [106.5234, 36.2549], [106.5234, 36.4746], [106.4355, 36.5625], [106.6113, 36.7822], [106.6113, 37.0898], [107.3145, 37.0898], [107.3145, 36.9141], [108.7207, 36.3428], [108.6328, 35.9912], [108.5449, 35.8594], [108.6328, 35.5518], [108.5449, 35.2881], [107.7539, 35.2881], [107.7539, 35.1123], [107.8418, 35.0244], [107.666, 34.9365], [107.2266, 34.8926], [106.9629, 35.0684], [106.6113, 35.0684], [106.5234, 34.7607], [106.3477, 34.585], [106.6992, 34.3213], [106.5234, 34.2773], [106.6113, 34.1455], [106.4355, 33.9258], [106.5234, 33.5303], [105.9961, 33.6182], [105.7324, 33.3984], [105.9961, 33.1787], [105.9082, 33.0029], [105.4688, 32.915], [105.3809, 32.8711], [105.3809, 32.7393], [105.2051, 32.6074], [104.4141, 32.7393], [104.3262, 32.8711], [104.4141, 33.0469], [104.3262, 33.2227], [104.4141, 33.3105], [104.2383, 33.3984], [104.1504, 33.6182], [103.1836, 33.7939], [103.0957, 34.1895], [102.9199, 34.3213], [102.2168, 33.9258], [102.4805, 33.4424], [101.8652, 33.0908], [101.9531, 33.4424], [101.8652, 33.5742], [101.7773, 33.5303], [101.6016, 33.5303], [101.5137, 33.7061], [101.25, 33.6621], [100.8105, 34.2773], [100.9863, 34.3652], [101.6895, 34.1016], [102.1289, 34.2773], [102.2168, 34.4092], [101.9531, 34.6289], [101.9531, 34.8486], [102.3926, 35.2002], [102.3047, 35.4199], [102.4805, 35.5957], [102.832, 35.5957], [102.6563, 35.7715], [102.9199, 35.9033], [102.9199, 36.0791], [103.0078, 36.2549], [102.832, 36.3428], [102.5684, 36.7383], [102.6563, 36.8262], [102.4805, 36.958], [102.5684, 37.1777], [102.1289, 37.4414], [101.9531, 37.7051], [101.7773, 37.6172], [101.5137, 37.8809], [101.1621, 37.8369], [100.7227, 38.2324], [100.459, 38.2764], [100.1074, 38.4961], [100.0195, 38.4521], [100.1953, 38.2764], [99.8438, 38.3643], [99.1406, 38.9355], [98.7891, 39.0674], [98.6133, 38.9355], [98.3496, 39.0234], [98.1738, 38.8037], [97.0313, 39.1992], [97.1191, 38.584], [96.6797, 38.4521], [96.6797, 38.1885], [96.416, 38.2324], [96.2402, 38.1006], [95.7129, 38.3643], [95.4492, 38.2764], [95.0098, 38.4082], [94.5703, 38.3643], [94.3066, 38.7598], [93.8672, 38.7158], [93.6914, 38.9355], [93.1641, 38.9795], [93.1641, 39.1992], [92.373, 39.1113], [92.373, 39.3311], [92.6367, 39.6387], [93.0762, 40.6494], [93.8672, 40.6934], [94.043, 41.0889], [94.5703, 41.4844], [95.1855, 41.792], [95.2734, 41.6162], [95.9766, 41.9238], [96.2402, 42.2314], [96.0645, 42.3193], [95.9766, 42.4951], [96.416, 42.7148]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "53",
|
||
|
"name": "云南",
|
||
|
"cp": [101.8652, 25.1807],
|
||
|
"childNum": 16
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[98.1738, 28.125], [98.2617, 28.3887], [98.3496, 28.125], [98.7012, 28.2129], [98.7891, 28.3447], [98.6133, 28.5205], [98.7012, 28.916], [98.7891, 29.0039], [98.7891, 28.8721], [98.9648, 28.8281], [98.9648, 29.1357], [99.1406, 29.2676], [99.2285, 28.3008], [99.4043, 28.1689], [99.4043, 28.5205], [99.668, 28.8281], [100.1953, 28.3447], [100.0195, 28.125], [100.2832, 27.7295], [100.3711, 27.8174], [100.7227, 27.8613], [101.1621, 27.1582], [101.1621, 27.0264], [101.4258, 26.7188], [101.4258, 26.8066], [101.4258, 26.5869], [101.6895, 26.3672], [101.6016, 26.2354], [101.8652, 26.0596], [102.1289, 26.1035], [102.5684, 26.3672], [102.6563, 26.1914], [103.0078, 26.3672], [102.9199, 27.29], [103.4473, 27.7734], [103.4473, 28.125], [103.7988, 28.3008], [103.8867, 28.6523], [104.4141, 28.6084], [104.2383, 28.4326], [104.4141, 28.2568], [104.4141, 28.125], [104.3262, 28.0371], [104.4141, 27.9492], [104.8535, 27.9053], [105.0293, 28.0811], [105.2051, 27.9932], [105.293, 27.7295], [105.2051, 27.3779], [104.5898, 27.334], [104.4141, 27.4658], [104.1504, 27.2461], [103.8867, 27.4219], [103.623, 27.0264], [103.7109, 26.9824], [103.7109, 26.7627], [103.8867, 26.543], [104.4141, 26.6748], [104.6777, 26.4111], [104.3262, 25.708], [104.8535, 25.2246], [104.5898, 25.0488], [104.6777, 24.9609], [104.502, 24.7412], [104.6777, 24.3457], [104.7656, 24.4775], [105.0293, 24.4336], [105.2051, 24.082], [105.4688, 24.0381], [105.5566, 24.126], [105.9961, 24.126], [106.1719, 23.8184], [106.1719, 23.5547], [105.6445, 23.4229], [105.5566, 23.2031], [105.293, 23.3789], [104.8535, 23.1592], [104.7656, 22.8516], [104.3262, 22.6758], [104.1504, 22.8076], [103.9746, 22.5439], [103.623, 22.7637], [103.5352, 22.5879], [103.3594, 22.8076], [103.0957, 22.4561], [102.4805, 22.7637], [102.3047, 22.4121], [101.8652, 22.3682], [101.7773, 22.5], [101.6016, 22.1924], [101.8652, 21.6211], [101.7773, 21.1377], [101.6016, 21.2256], [101.25, 21.1816], [101.1621, 21.7529], [100.6348, 21.4453], [100.1074, 21.4893], [99.9316, 22.0605], [99.2285, 22.1484], [99.4043, 22.5879], [99.3164, 22.7197], [99.4922, 23.0713], [98.877, 23.2031], [98.7012, 23.9502], [98.877, 24.126], [98.1738, 24.082], [97.7344, 23.8623], [97.5586, 23.9063], [97.7344, 24.126], [97.6465, 24.4336], [97.5586, 24.4336], [97.5586, 24.7412], [97.7344, 24.8291], [97.8223, 25.2686], [98.1738, 25.4004], [98.1738, 25.6201], [98.3496, 25.5762], [98.5254, 25.8398], [98.7012, 25.8838], [98.6133, 26.0596], [98.7012, 26.1475], [98.7891, 26.5869], [98.7012, 27.5098], [98.5254, 27.6416], [98.3496, 27.5098], [98.1738, 28.125]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "45",
|
||
|
"name": "广西",
|
||
|
"cp": [108.2813, 23.6426],
|
||
|
"childNum": 14
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[104.502, 24.7412], [104.6777, 24.6094], [105.2051, 24.9609], [105.9961, 24.6533], [106.1719, 24.7852], [106.1719, 24.9609], [106.875, 25.1807], [107.0508, 25.2686], [106.9629, 25.4883], [107.2266, 25.6201], [107.4902, 25.2246], [107.7539, 25.2246], [107.8418, 25.1367], [108.1055, 25.2246], [108.1934, 25.4443], [108.3691, 25.5322], [108.6328, 25.3125], [108.6328, 25.5762], [109.0723, 25.5322], [108.9844, 25.752], [109.3359, 25.708], [109.5117, 26.0156], [109.7754, 25.8838], [109.9512, 26.1914], [110.2148, 25.9717], [110.5664, 26.3232], [111.1816, 26.3232], [111.2695, 26.2354], [111.2695, 25.8838], [111.4453, 25.8398], [111.0059, 25.0049], [111.0938, 24.9609], [111.3574, 25.1367], [111.5332, 24.6533], [111.709, 24.7852], [112.0605, 24.7412], [111.8848, 24.6533], [112.0605, 24.3457], [111.8848, 24.2139], [111.8848, 23.9941], [111.7969, 23.8184], [111.6211, 23.8184], [111.6211, 23.6865], [111.3574, 23.4668], [111.4453, 23.0273], [111.2695, 22.8076], [110.7422, 22.5439], [110.7422, 22.2803], [110.6543, 22.1484], [110.3027, 22.1484], [110.3027, 21.8848], [109.9512, 21.8408], [109.8633, 21.665], [109.7754, 21.6211], [109.7754, 21.4014], [109.5996, 21.4453], [109.1602, 21.3574], [109.248, 20.874], [109.0723, 20.9619], [109.0723, 21.5332], [108.7207, 21.5332], [108.6328, 21.665], [108.2813, 21.4893], [107.8418, 21.6211], [107.4023, 21.6211], [107.0508, 21.7969], [107.0508, 21.9287], [106.6992, 22.0166], [106.6113, 22.4121], [106.7871, 22.7637], [106.6992, 22.8955], [105.9082, 22.9395], [105.5566, 23.0713], [105.5566, 23.2031], [105.6445, 23.4229], [106.1719, 23.5547], [106.1719, 23.8184], [105.9961, 24.126], [105.5566, 24.126], [105.4688, 24.0381], [105.2051, 24.082], [105.0293, 24.4336], [104.7656, 24.4775], [104.6777, 24.3457], [104.502, 24.7412]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "43",
|
||
|
"name": "湖南",
|
||
|
"cp": [111.5332, 27.3779],
|
||
|
"childNum": 14
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[109.248, 28.4766], [109.248, 29.1357], [109.5117, 29.6191], [109.6875, 29.6191], [109.7754, 29.751], [110.4785, 29.6631], [110.6543, 29.751], [110.4785, 30.0146], [110.8301, 30.1465], [111.7969, 29.9268], [112.2363, 29.5313], [112.5, 29.6191], [112.6758, 29.5752], [112.9395, 29.7949], [113.0273, 29.751], [112.9395, 29.4873], [113.0273, 29.4434], [113.5547, 29.8389], [113.5547, 29.707], [113.7305, 29.5752], [113.6426, 29.3115], [113.7305, 29.0918], [113.9063, 29.0479], [114.1699, 28.8281], [114.082, 28.5645], [114.2578, 28.3447], [113.7305, 27.9492], [113.6426, 27.5977], [113.6426, 27.3779], [113.8184, 27.29], [113.7305, 27.1143], [113.9063, 26.9385], [113.9063, 26.6309], [114.082, 26.5869], [113.9941, 26.1914], [114.2578, 26.1475], [113.9941, 26.0596], [113.9063, 25.4443], [113.6426, 25.3125], [113.2031, 25.5322], [112.8516, 25.3564], [113.0273, 25.2246], [113.0273, 24.9609], [112.8516, 24.917], [112.5879, 25.1367], [112.2363, 25.1807], [112.1484, 24.873], [112.0605, 24.7412], [111.709, 24.7852], [111.5332, 24.6533], [111.3574, 25.1367], [111.0938, 24.9609], [111.0059, 25.0049], [111.4453, 25.8398], [111.2695, 25.8838], [111.2695, 26.2354], [111.1816, 26.3232], [110.5664, 26.3232], [110.2148, 25.9717], [109.9512, 26.1914], [109.7754, 25.8838], [109.5117, 26.0156], [109.4238, 26.2793], [109.248, 26.3232], [109.4238, 26.5869], [109.3359, 26.7188], [109.5117, 26.8066], [109.5117, 27.0264], [109.3359, 27.1582], [108.8965, 27.0264], [108.8086, 27.1143], [109.4238, 27.5977], [109.3359, 27.9053], [109.3359, 28.2568], [109.248, 28.4766]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "61",
|
||
|
"name": "陕西",
|
||
|
"cp": [109.5996, 35.6396],
|
||
|
"childNum": 10
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[105.4688, 32.915], [105.9082, 33.0029], [105.9961, 33.1787], [105.7324, 33.3984], [105.9961, 33.6182], [106.5234, 33.5303], [106.4355, 33.9258], [106.6113, 34.1455], [106.5234, 34.2773], [106.6992, 34.3213], [106.3477, 34.585], [106.5234, 34.7607], [106.6113, 35.0684], [106.9629, 35.0684], [107.2266, 34.8926], [107.666, 34.9365], [107.8418, 35.0244], [107.7539, 35.1123], [107.7539, 35.2881], [108.5449, 35.2881], [108.6328, 35.5518], [108.5449, 35.8594], [108.6328, 35.9912], [108.7207, 36.3428], [107.3145, 36.9141], [107.3145, 37.0898], [107.3145, 37.6172], [107.666, 37.8809], [108.1934, 37.6172], [108.7207, 37.7051], [108.8086, 38.0127], [108.8965, 37.9688], [109.0723, 38.0127], [108.9844, 38.3203], [109.9512, 39.1553], [109.8633, 39.2432], [110.2148, 39.2871], [110.127, 39.4629], [110.6543, 39.2871], [111.0938, 39.5947], [111.0938, 39.375], [111.1816, 39.2432], [110.918, 38.7158], [110.8301, 38.4961], [110.4785, 38.1885], [110.4785, 37.9688], [110.8301, 37.6611], [110.3906, 37.002], [110.4785, 36.123], [110.5664, 35.6396], [110.2148, 34.8926], [110.2148, 34.6729], [110.3906, 34.585], [110.4785, 34.2334], [110.6543, 34.1455], [110.6543, 33.8379], [111.0059, 33.5303], [111.0059, 33.2666], [110.7422, 33.1348], [110.5664, 33.2666], [110.3027, 33.1787], [109.5996, 33.2666], [109.4238, 33.1348], [109.7754, 33.0469], [109.7754, 32.915], [110.127, 32.7393], [110.127, 32.6074], [109.6875, 32.6074], [109.5117, 32.4316], [109.5996, 31.7285], [109.248, 31.7285], [109.0723, 31.9482], [108.5449, 32.2119], [108.2813, 32.2559], [108.0176, 32.168], [107.4023, 32.5195], [107.2266, 32.4316], [107.1387, 32.4756], [107.0508, 32.6953], [106.3477, 32.6514], [106.084, 32.7393], [106.084, 32.8711], [105.5566, 32.7393], [105.4688, 32.915]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "44",
|
||
|
"name": "广东",
|
||
|
"cp": [113.4668, 22.8076],
|
||
|
"childNum": 21
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[109.7754, 21.4014], [109.7754, 21.6211], [109.8633, 21.665], [109.9512, 21.8408], [110.3027, 21.8848], [110.3027, 22.1484], [110.6543, 22.1484], [110.7422, 22.2803], [110.7422, 22.5439], [111.2695, 22.8076], [111.4453, 23.0273], [111.3574, 23.4668], [111.6211, 23.6865], [111.6211, 23.8184], [111.7969, 23.8184], [111.8848, 23.9941], [111.8848, 24.2139], [112.0605, 24.3457], [111.8848, 24.6533], [112.0605, 24.7412], [112.1484, 24.873], [112.2363, 25.1807], [112.5879, 25.1367], [112.8516, 24.917], [113.0273, 24.9609], [113.0273, 25.2246], [112.8516, 25.3564], [113.2031, 25.5322], [113.6426, 25.3125], [113.9063, 25.4443], [113.9941, 25.2686], [114.6094, 25.4004], [114.7852, 25.2686], [114.6973, 25.1367], [114.4336, 24.9609], [114.1699, 24.6973], [114.4336, 24.5215], [115.4004, 24.7852], [115.8398, 24.5654], [115.752, 24.7852], [115.9277, 24.917], [116.2793, 24.7852], [116.3672, 24.873], [116.543, 24.6094], [116.7188, 24.6533], [116.9824, 24.1699], [116.9824, 23.9063], [117.1582, 23.5547], [117.334, 23.2471], [116.8945, 23.3789], [116.6309, 23.1152], [116.543, 22.8516], [115.9277, 22.7197], [115.6641, 22.7637], [115.5762, 22.6318], [115.0488, 22.6758], [114.6094, 22.3682], [114.3457, 22.5439], [113.9941, 22.5], [113.8184, 22.1924], [114.3457, 22.1484], [114.4336, 22.0166], [114.082, 21.9287], [113.9941, 21.7969], [113.5547, 22.0166], [113.1152, 21.8408], [112.9395, 21.5771], [112.4121, 21.4453], [112.2363, 21.5332], [111.5332, 21.4893], [111.2695, 21.3574], [110.7422, 21.3574], [110.6543, 21.2256], [110.7422, 20.918], [110.4785, 20.874], [110.6543, 20.2588], [110.5664, 20.2588], [110.3906, 20.127], [110.0391, 20.127], [109.8633, 20.127], [109.8633, 20.3027], [109.5996, 20.918], [109.7754, 21.4014], [109.7754, 21.4014]], [[113.5986, 22.1649], [113.6096, 22.1265], [113.5547, 22.11], [113.5437, 22.2034], [113.5767, 22.2034], [113.5986, 22.1649]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "22",
|
||
|
"name": "吉林",
|
||
|
"cp": [126.4746, 43.5938],
|
||
|
"childNum": 9
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[123.2227, 46.2305], [123.9258, 46.2305], [124.0137, 45.7471], [124.3652, 45.4395], [124.8926, 45.5273], [125.0684, 45.3955], [125.6836, 45.5273], [125.7715, 45.3076], [126.0352, 45.1758], [126.5625, 45.2637], [126.9141, 45.1318], [127.0898, 45], [127.002, 44.7803], [127.0898, 44.6045], [127.5293, 44.6045], [127.7051, 44.1211], [128.0566, 44.1211], [128.0566, 44.3408], [128.4082, 44.4727], [128.4961, 44.165], [128.8477, 43.5498], [129.1992, 43.5938], [129.2871, 43.8135], [129.8145, 43.9014], [129.9023, 44.0332], [129.9902, 43.8574], [130.3418, 43.9893], [130.5176, 43.6377], [130.8691, 43.418], [131.3086, 43.4619], [131.3086, 43.3301], [131.1328, 42.9346], [130.4297, 42.7148], [130.6055, 42.6709], [130.6055, 42.4512], [130.2539, 42.7588], [130.2539, 42.8906], [130.166, 42.9785], [129.9023, 43.0225], [129.7266, 42.4951], [129.375, 42.4512], [128.9355, 42.0117], [128.0566, 42.0117], [128.3203, 41.5723], [128.1445, 41.3525], [127.0898, 41.5283], [127.1777, 41.5723], [126.9141, 41.792], [126.6504, 41.6602], [126.4746, 41.3965], [126.123, 40.957], [125.6836, 40.8691], [125.5957, 40.9131], [125.7715, 41.2207], [125.332, 41.6602], [125.332, 41.9678], [125.4199, 42.0996], [125.332, 42.1436], [124.8926, 42.8027], [124.8926, 43.0664], [124.7168, 43.0664], [124.4531, 42.8467], [124.2773, 43.2422], [123.8379, 43.4619], [123.6621, 43.374], [123.3105, 43.5059], [123.4863, 43.7256], [123.1348, 44.4727], [122.3438, 44.2529], [122.0801, 44.8682], [122.2559, 45.2637], [121.9043, 45.7031], [121.7285, 45.7471], [121.8164, 46.0107], [122.2559, 45.791], [122.4316, 45.8789], [122.6953, 45.7031], [122.7832, 46.0107], [123.2227, 46.2305]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "13",
|
||
|
"name": "河北",
|
||
|
"cp": [115.4004, 37.9688],
|
||
|
"childNum": 11
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "MultiPolygon",
|
||
|
"coordinates": [[[[114.5215, 39.5068], [114.3457, 39.8584], [113.9941, 39.9902], [114.5215, 40.3418], [114.3457, 40.3857], [114.2578, 40.6055], [114.082, 40.7373], [113.9063, 41.1328], [113.9941, 41.2207], [113.9063, 41.4404], [114.2578, 41.5723], [114.1699, 41.792], [114.5215, 42.1436], [114.873, 42.0996], [114.9609, 41.6162], [115.2246, 41.5723], [115.9277, 41.9238], [116.0156, 41.792], [116.2793, 42.0117], [116.8066, 42.0117], [116.8945, 42.4072], [117.334, 42.4512], [117.5098, 42.583], [117.7734, 42.627], [118.0371, 42.4072], [117.9492, 42.2314], [118.125, 42.0557], [118.3008, 42.0996], [118.3008, 41.792], [118.125, 41.748], [118.3887, 41.3086], [119.2676, 41.3086], [118.8281, 40.8252], [119.2676, 40.5176], [119.5313, 40.5615], [119.707, 40.1221], [119.8828, 39.9463], [119.5313, 39.6826], [119.4434, 39.4189], [118.916, 39.0674], [118.4766, 38.9355], [118.125, 39.0234], [118.0371, 39.1992], [118.0371, 39.2432], [117.8613, 39.4189], [117.9492, 39.5947], [117.6855, 39.5947], [117.5098, 39.7705], [117.5098, 39.9902], [117.6855, 39.9902], [117.6855, 40.0781], [117.4219, 40.21], [117.2461, 40.5176], [117.4219, 40.6494], [116.9824, 40.6934], [116.6309, 41.0449], [116.3672, 40.9131], [116.4551, 40.7813], [116.1914, 40.7813], [116.1035, 40.6055], [115.752, 40.5615], [115.9277, 40.2539], [115.4004, 39.9463], [115.4883, 39.6387], [115.752, 39.5068], [116.1914, 39.5947], [116.3672, 39.4629], [116.543, 39.5947], [116.8066, 39.5947], [116.8945, 39.1113], [116.7188, 38.9355], [116.7188, 38.8037], [117.2461, 38.54], [117.5977, 38.6279], [117.9492, 38.3203], [117.4219, 37.8369], [116.8066, 37.8369], [116.4551, 37.4854], [116.2793, 37.5732], [116.2793, 37.3535], [116.0156, 37.3535], [115.752, 36.9141], [115.3125, 36.5186], [115.4883, 36.167], [115.3125, 36.0791], [115.1367, 36.2109], [114.9609, 36.0791], [114.873, 36.123], [113.7305, 36.3428], [113.4668, 36.6504], [113.7305, 36.8701], [113.7305, 37.1338], [114.1699, 37.6611], [113.9941, 37.7051], [113.8184, 38.1445], [113.5547, 38.2764], [113.5547, 38.54], [113.8184, 38.8037], [113.8184, 38.9355], [113.9063, 39.0234], [114.3457, 39.0674], [114.5215, 39.5068]]], [[[117.2461, 40.0781], [117.1582, 39.8145], [117.1582, 39.6387], [116.8945, 39.6826], [116.8945, 39.8145], [116.8066, 39.9902], [117.2461, 40.0781]]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "42",
|
||
|
"name": "湖北",
|
||
|
"cp": [112.2363, 31.1572],
|
||
|
"childNum": 17
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[110.2148, 31.1572], [110.127, 31.377], [109.6875, 31.5527], [109.7754, 31.6846], [109.5996, 31.7285], [109.5117, 32.4316], [109.6875, 32.6074], [110.127, 32.6074], [110.127, 32.7393], [109.7754, 32.915], [109.7754, 33.0469], [109.4238, 33.1348], [109.5996, 33.2666], [110.3027, 33.1787], [110.5664, 33.2666], [110.7422, 33.1348], [111.0059, 33.2666], [111.5332, 32.6074], [112.3242, 32.3438], [113.2031, 32.4316], [113.4668, 32.2998], [113.7305, 32.4316], [113.8184, 31.8604], [113.9941, 31.7725], [114.1699, 31.8604], [114.5215, 31.7725], [114.6094, 31.5527], [114.7852, 31.4648], [115.1367, 31.5967], [115.2246, 31.4209], [115.4004, 31.4209], [115.5762, 31.2012], [116.0156, 31.0254], [115.752, 30.6738], [116.1035, 30.1904], [116.1035, 29.8389], [115.9277, 29.707], [115.4883, 29.7949], [114.873, 29.3994], [114.2578, 29.3555], [113.9063, 29.0479], [113.7305, 29.0918], [113.6426, 29.3115], [113.7305, 29.5752], [113.5547, 29.707], [113.5547, 29.8389], [113.0273, 29.4434], [112.9395, 29.4873], [113.0273, 29.751], [112.9395, 29.7949], [112.6758, 29.5752], [112.5, 29.6191], [112.2363, 29.5313], [111.7969, 29.9268], [110.8301, 30.1465], [110.4785, 30.0146], [110.6543, 29.751], [110.4785, 29.6631], [109.7754, 29.751], [109.6875, 29.6191], [109.5117, 29.6191], [109.248, 29.1357], [109.0723, 29.3555], [108.9844, 29.3115], [108.6328, 29.8389], [108.457, 29.7949], [108.5449, 30.2344], [108.457, 30.4102], [108.6328, 30.5859], [108.8086, 30.498], [109.0723, 30.6299], [109.1602, 30.542], [109.248, 30.6299], [109.4238, 30.542], [109.8633, 30.8936], [110.0391, 30.8057], [110.2148, 31.1572]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "52",
|
||
|
"name": "贵州",
|
||
|
"cp": [106.6113, 26.9385],
|
||
|
"childNum": 9
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[104.1504, 27.2461], [104.4141, 27.4658], [104.5898, 27.334], [105.2051, 27.3779], [105.293, 27.7295], [105.5566, 27.7734], [105.6445, 27.6416], [106.3477, 27.8174], [106.1719, 28.125], [105.9082, 28.125], [105.6445, 28.4326], [105.9961, 28.7402], [106.3477, 28.5205], [106.5234, 28.5645], [106.4355, 28.7842], [106.5234, 28.7842], [106.6113, 28.6523], [106.6113, 28.5205], [106.6992, 28.4766], [106.875, 28.7842], [107.4023, 28.8721], [107.4023, 29.1797], [107.5781, 29.2236], [107.8418, 29.1357], [107.8418, 29.0039], [108.2813, 29.0918], [108.3691, 28.6523], [108.5449, 28.6523], [108.5449, 28.3887], [108.7207, 28.4766], [108.7207, 28.2129], [109.0723, 28.2129], [109.248, 28.4766], [109.3359, 28.2568], [109.3359, 27.9053], [109.4238, 27.5977], [108.8086, 27.1143], [108.8965, 27.0264], [109.3359, 27.1582], [109.5117, 27.0264], [109.5117, 26.8066], [109.3359, 26.7188], [109.4238, 26.5869], [109.248, 26.3232], [109.4238, 26.2793], [109.5117, 26.0156], [109.3359, 25.708], [108.9844, 25.752], [109.0723, 25.5322], [108.6328, 25.5762], [108.6328, 25.3125], [108.3691, 25.5322], [108.1934, 25.4443], [108.1055, 25.2246], [107.8418, 25.1367], [107.7539, 25.2246], [107.4902, 25.2246], [107.2266, 25.6201], [106.9629, 25.4883], [107.0508, 25.2686], [106.875, 25.1807], [106.1719, 24.9609], [106.1719, 24.7852], [105.9961, 24.6533], [105.2051, 24.9609], [104.6777, 24.6094], [104.502, 24.7412], [104.6777, 24.9609], [104.5898, 25.0488], [104.8535, 25.2246], [104.3262, 25.708], [104.6777, 26.4111], [104.4141, 26.6748], [103.8867, 26.543], [103.7109, 26.7627], [103.7109, 26.9824], [103.623, 27.0264], [103.8867, 27.4219], [104.1504, 27.2461]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "37",
|
||
|
"name": "山东",
|
||
|
"cp": [118.7402, 36.4307],
|
||
|
"childNum": 17
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[115.4883, 36.167], [115.3125, 36.5186], [115.752, 36.9141], [116.0156, 37.3535], [116.2793, 37.3535], [116.2793, 37.5732], [116.4551, 37.4854], [116.8066, 37.8369], [117.4219, 37.8369], [117.9492, 38.3203], [118.125, 38.1445], [118.916, 38.1445], [119.3555, 37.6611], [119.0039, 37.5293], [119.0039, 37.3535], [119.3555, 37.1338], [119.707, 37.1338], [119.8828, 37.3975], [120.498, 37.8369], [120.5859, 38.1445], [120.9375, 38.4521], [121.0254, 37.8369], [121.2012, 37.6611], [121.9043, 37.4854], [122.168, 37.6172], [122.2559, 37.4854], [122.6074, 37.4854], [122.6953, 37.3535], [122.6074, 36.9141], [122.4316, 36.7822], [121.8164, 36.8701], [121.7285, 36.6943], [121.1133, 36.6064], [121.1133, 36.4307], [121.377, 36.2549], [120.7617, 36.167], [120.9375, 35.8594], [120.6738, 36.0352], [119.707, 35.4639], [119.9707, 34.9805], [119.3555, 35.0244], [119.2676, 35.1123], [118.916, 35.0244], [118.7402, 34.7168], [118.4766, 34.6729], [118.3887, 34.4092], [118.2129, 34.4092], [118.125, 34.6289], [117.9492, 34.6729], [117.5977, 34.4531], [117.334, 34.585], [117.2461, 34.4531], [116.8066, 34.9365], [116.4551, 34.8926], [116.3672, 34.6289], [116.1914, 34.585], [115.5762, 34.585], [115.4004, 34.8486], [114.7852, 35.0684], [115.0488, 35.376], [115.2246, 35.4199], [115.4883, 35.7275], [116.1035, 36.0791], [115.3125, 35.8154], [115.4883, 36.167]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "36",
|
||
|
"name": "江西",
|
||
|
"cp": [116.0156, 27.29],
|
||
|
"childNum": 11
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[114.2578, 28.3447], [114.082, 28.5645], [114.1699, 28.8281], [113.9063, 29.0479], [114.2578, 29.3555], [114.873, 29.3994], [115.4883, 29.7949], [115.9277, 29.707], [116.1035, 29.8389], [116.2793, 29.7949], [116.7188, 30.0586], [116.8945, 29.9268], [116.7188, 29.751], [116.7188, 29.6191], [117.1582, 29.707], [117.0703, 29.8389], [117.1582, 29.9268], [117.5098, 29.6191], [118.0371, 29.5752], [118.2129, 29.3994], [118.0371, 29.1797], [118.0371, 29.0479], [118.3887, 28.7842], [118.4766, 28.3447], [118.4766, 28.3008], [118.3008, 28.0811], [117.7734, 27.8174], [117.5098, 27.9932], [116.9824, 27.6416], [117.1582, 27.29], [117.0703, 27.1143], [116.543, 26.8066], [116.6309, 26.4551], [116.3672, 26.2354], [116.4551, 26.1035], [116.1914, 25.8838], [116.0156, 25.2686], [115.8398, 25.2246], [115.9277, 24.917], [115.752, 24.7852], [115.8398, 24.5654], [115.4004, 24.7852], [114.4336, 24.5215], [114.1699, 24.6973], [114.4336, 24.9609], [114.6973, 25.1367], [114.7852, 25.2686], [114.6094, 25.4004], [113.9941, 25.2686], [113.9063, 25.4443], [113.9941, 26.0596], [114.2578, 26.1475], [113.9941, 26.1914], [114.082, 26.5869], [113.9063, 26.6309], [113.9063, 26.9385], [113.7305, 27.1143], [113.8184, 27.29], [113.6426, 27.3779], [113.6426, 27.5977], [113.7305, 27.9492], [114.2578, 28.3447]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "41",
|
||
|
"name": "河南",
|
||
|
"cp": [113.4668, 33.8818],
|
||
|
"childNum": 17
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[110.3906, 34.585], [110.8301, 34.6289], [111.1816, 34.8047], [111.5332, 34.8486], [111.7969, 35.0684], [112.0605, 35.0684], [112.0605, 35.2881], [112.7637, 35.2002], [113.1152, 35.332], [113.6426, 35.6836], [113.7305, 36.3428], [114.873, 36.123], [114.9609, 36.0791], [115.1367, 36.2109], [115.3125, 36.0791], [115.4883, 36.167], [115.3125, 35.8154], [116.1035, 36.0791], [115.4883, 35.7275], [115.2246, 35.4199], [115.0488, 35.376], [114.7852, 35.0684], [115.4004, 34.8486], [115.5762, 34.585], [116.1914, 34.585], [116.1914, 34.4092], [116.543, 34.2773], [116.6309, 33.9258], [116.1914, 33.7061], [116.0156, 33.9697], [115.6641, 34.0576], [115.5762, 33.9258], [115.5762, 33.6621], [115.4004, 33.5303], [115.3125, 33.1787], [114.873, 33.1348], [114.873, 33.0029], [115.1367, 32.8711], [115.2246, 32.6074], [115.5762, 32.4316], [115.8398, 32.5195], [115.9277, 31.7725], [115.4883, 31.6846], [115.4004, 31.4209], [115.2246, 31.4209], [115.1367, 31.5967], [114.7852, 31.4648], [114.6094, 31.5527], [114.5215, 31.7725], [114.1699, 31.8604], [113.9941, 31.7725], [113.8184, 31.8604], [113.7305, 32.4316], [113.4668, 32.2998], [113.2031, 32.4316], [112.3242, 32.3438], [111.5332, 32.6074], [111.0059, 33.2666], [111.0059, 33.5303], [110.6543, 33.8379], [110.6543, 34.1455], [110.4785, 34.2334], [110.3906, 34.585]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "21",
|
||
|
"name": "辽宁",
|
||
|
"cp": [122.3438, 41.0889],
|
||
|
"childNum": 14
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[119.2676, 41.3086], [119.4434, 41.6162], [119.2676, 41.7041], [119.3555, 42.2754], [119.5313, 42.3633], [119.8828, 42.1875], [120.1465, 41.7041], [120.498, 42.0996], [121.4648, 42.4951], [121.7285, 42.4512], [121.9922, 42.7148], [122.3438, 42.6709], [122.3438, 42.8467], [122.7832, 42.7148], [123.1348, 42.8027], [123.3105, 42.9785], [123.5742, 43.0225], [123.6621, 43.374], [123.8379, 43.4619], [124.2773, 43.2422], [124.4531, 42.8467], [124.7168, 43.0664], [124.8926, 43.0664], [124.8926, 42.8027], [125.332, 42.1436], [125.4199, 42.0996], [125.332, 41.9678], [125.332, 41.6602], [125.7715, 41.2207], [125.5957, 40.9131], [125.6836, 40.8691], [124.541, 40.21], [124.1016, 39.6826], [123.3984, 39.6826], [123.1348, 39.4189], [123.1348, 39.0234], [122.0801, 39.0234], [121.5527, 38.7158], [121.1133, 38.6719], [120.9375, 38.9795], [121.377, 39.1992], [121.2012, 39.5508], [122.0801, 40.3857], [121.9922, 40.6934], [121.7285, 40.8252], [121.2012, 40.8252], [120.5859, 40.21], [119.8828, 39.9463], [119.707, 40.1221], [119.5313, 40.5615], [119.2676, 40.5176], [118.8281, 40.8252], [119.2676, 41.3086]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "14",
|
||
|
"name": "山西",
|
||
|
"cp": [112.4121, 37.6611],
|
||
|
"childNum": 11
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[110.918, 38.7158], [111.1816, 39.2432], [111.0938, 39.375], [111.3574, 39.4189], [111.4453, 39.6387], [111.9727, 39.5947], [112.3242, 40.2539], [112.7637, 40.166], [113.2031, 40.3857], [113.5547, 40.3418], [113.8184, 40.5176], [114.082, 40.5176], [114.082, 40.7373], [114.2578, 40.6055], [114.3457, 40.3857], [114.5215, 40.3418], [113.9941, 39.9902], [114.3457, 39.8584], [114.5215, 39.5068], [114.3457, 39.0674], [113.9063, 39.0234], [113.8184, 38.9355], [113.8184, 38.8037], [113.5547, 38.54], [113.5547, 38.2764], [113.8184, 38.1445], [113.9941, 37.7051], [114.1699, 37.6611], [113.7305, 37.1338], [113.7305, 36.8701], [113.4668, 36.6504], [113.7305, 36.3428], [113.6426, 35.6836], [113.1152, 35.332], [112.7637, 35.2002], [112.0605, 35.2881], [112.0605, 35.0684], [111.7969, 35.0684], [111.5332, 34.8486], [111.1816, 34.8047], [110.8301, 34.6289], [110.3906, 34.585], [110.2148, 34.6729], [110.2148, 34.8926], [110.5664, 35.6396], [110.4785, 36.123], [110.3906, 37.002], [110.8301, 37.6611], [110.4785, 37.9688], [110.4785, 38.1885], [110.8301, 38.4961], [110.918, 38.7158]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "34",
|
||
|
"name": "安徽",
|
||
|
"cp": [117.2461, 32.0361],
|
||
|
"childNum": 17
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[116.6309, 33.9258], [116.543, 34.2773], [116.1914, 34.4092], [116.1914, 34.585], [116.3672, 34.6289], [116.8945, 34.4092], [117.1582, 34.0576], [117.5977, 34.0137], [117.7734, 33.7061], [118.125, 33.75], [117.9492, 33.2227], [118.0371, 33.1348], [118.2129, 33.2227], [118.3008, 32.7832], [118.7402, 32.7393], [118.916, 32.959], [119.1797, 32.8271], [119.1797, 32.4756], [118.5645, 32.5635], [118.6523, 32.2119], [118.4766, 32.168], [118.3887, 31.9482], [118.916, 31.5527], [118.7402, 31.377], [118.8281, 31.2451], [119.3555, 31.2891], [119.4434, 31.1572], [119.6191, 31.1133], [119.6191, 31.0693], [119.4434, 30.6738], [119.2676, 30.6299], [119.3555, 30.4102], [118.916, 30.3223], [118.916, 29.9707], [118.7402, 29.707], [118.2129, 29.3994], [118.0371, 29.5752], [117.5098, 29.6191], [117.1582, 29.9268], [117.0703, 29.8389], [117.1582, 29.707], [116.7188, 29.6191], [116.7188, 29.751], [116.8945, 29.9268], [116.7188, 30.0586], [116.2793, 29.7949], [116.1035, 29.8389], [116.1035, 30.1904], [115.752, 30.6738], [116.0156, 31.0254], [115.5762, 31.2012], [115.4004, 31.4209], [115.4883, 31.6846], [115.9277, 31.7725], [115.8398, 32.5195], [115.5762, 32.4316], [115.2246, 32.6074], [115.1367, 32.8711], [114.873, 33.0029], [114.873, 33.1348], [115.3125, 33.1787], [115.4004, 33.5303], [115.5762, 33.6621], [115.5762, 33.9258], [115.6641, 34.0576], [116.0156, 33.9697], [116.1914, 33.7061], [116.6309, 33.9258]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "35",
|
||
|
"name": "福建",
|
||
|
"cp": [118.3008, 25.9277],
|
||
|
"childNum": 9
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[118.4766, 28.3008], [118.8281, 28.2568], [118.7402, 28.0371], [118.916, 27.4658], [119.2676, 27.4219], [119.6191, 27.6855], [119.7949, 27.29], [120.2344, 27.4219], [120.4102, 27.1582], [120.7617, 27.0264], [120.6738, 26.8945], [120.2344, 26.8506], [120.2344, 26.7188], [120.4102, 26.6748], [120.498, 26.3672], [120.2344, 26.2793], [120.4102, 26.1475], [120.0586, 26.1914], [119.9707, 25.9277], [119.7949, 25.9277], [119.9707, 25.4004], [119.7949, 25.2686], [119.5313, 25.1367], [119.4434, 25.0049], [119.2676, 25.0928], [118.916, 24.8291], [118.6523, 24.5215], [118.4766, 24.5215], [118.4766, 24.4336], [118.2129, 24.3457], [118.2129, 24.1699], [117.8613, 23.9941], [117.7734, 23.7744], [117.5098, 23.5986], [117.1582, 23.5547], [116.9824, 23.9063], [116.9824, 24.1699], [116.7188, 24.6533], [116.543, 24.6094], [116.3672, 24.873], [116.2793, 24.7852], [115.9277, 24.917], [115.8398, 25.2246], [116.0156, 25.2686], [116.1914, 25.8838], [116.4551, 26.1035], [116.3672, 26.2354], [116.6309, 26.4551], [116.543, 26.8066], [117.0703, 27.1143], [117.1582, 27.29], [116.9824, 27.6416], [117.5098, 27.9932], [117.7734, 27.8174], [118.3008, 28.0811], [118.4766, 28.3008]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "33",
|
||
|
"name": "浙江",
|
||
|
"cp": [120.498, 29.0918],
|
||
|
"childNum": 11
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[118.2129, 29.3994], [118.7402, 29.707], [118.916, 29.9707], [118.916, 30.3223], [119.3555, 30.4102], [119.2676, 30.6299], [119.4434, 30.6738], [119.6191, 31.0693], [119.6191, 31.1133], [119.9707, 31.1572], [120.498, 30.8057], [120.9375, 31.0254], [121.2891, 30.6738], [121.9922, 30.8057], [122.6953, 30.8936], [122.8711, 30.7178], [122.959, 30.1465], [122.6074, 30.1025], [122.6074, 29.9268], [122.168, 29.5313], [122.3438, 28.8721], [121.9922, 28.8721], [121.9922, 28.4326], [121.7285, 28.3447], [121.7285, 28.2129], [121.4648, 28.2129], [121.5527, 28.0371], [121.2891, 27.9492], [121.1133, 27.4219], [120.6738, 27.334], [120.6738, 27.1582], [120.9375, 27.0264], [120.7617, 27.0264], [120.4102, 27.1582], [120.2344, 27.4219], [119.7949, 27.29], [119.6191, 27.6855], [119.2676, 27.4219], [118.916, 27.4658], [118.7402, 28.0371], [118.8281, 28.2568], [118.4766, 28.3008], [118.4766, 28.3447], [118.3887, 28.7842], [118.0371, 29.0479], [118.0371, 29.1797], [118.2129, 29.3994]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "32",
|
||
|
"name": "江苏",
|
||
|
"cp": [120.0586, 32.915],
|
||
|
"childNum": 13
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[116.3672, 34.6289], [116.4551, 34.8926], [116.8066, 34.9365], [117.2461, 34.4531], [117.334, 34.585], [117.5977, 34.4531], [117.9492, 34.6729], [118.125, 34.6289], [118.2129, 34.4092], [118.3887, 34.4092], [118.4766, 34.6729], [118.7402, 34.7168], [118.916, 35.0244], [119.2676, 35.1123], [119.3555, 35.0244], [119.3555, 34.8486], [119.707, 34.585], [120.3223, 34.3652], [120.9375, 33.0469], [121.0254, 32.6514], [121.377, 32.4756], [121.4648, 32.168], [121.9043, 31.9922], [121.9922, 31.6846], [121.9922, 31.5967], [121.2012, 31.8604], [121.1133, 31.7285], [121.377, 31.5088], [121.2012, 31.4648], [120.9375, 31.0254], [120.498, 30.8057], [119.9707, 31.1572], [119.6191, 31.1133], [119.4434, 31.1572], [119.3555, 31.2891], [118.8281, 31.2451], [118.7402, 31.377], [118.916, 31.5527], [118.3887, 31.9482], [118.4766, 32.168], [118.6523, 32.2119], [118.5645, 32.5635], [119.1797, 32.4756], [119.1797, 32.8271], [118.916, 32.959], [118.7402, 32.7393], [118.3008, 32.7832], [118.2129, 33.2227], [118.0371, 33.1348], [117.9492, 33.2227], [118.125, 33.75], [117.7734, 33.7061], [117.5977, 34.0137], [117.1582, 34.0576], [116.8945, 34.4092], [116.3672, 34.6289]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "50",
|
||
|
"name": "重庆",
|
||
|
"cp": [107.7539, 30.1904],
|
||
|
"childNum": 40
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[108.5449, 31.6846], [108.2813, 31.9043], [108.3691, 32.168], [108.5449, 32.2119], [109.0723, 31.9482], [109.248, 31.7285], [109.5996, 31.7285], [109.7754, 31.6846], [109.6875, 31.5527], [110.127, 31.377], [110.2148, 31.1572], [110.0391, 30.8057], [109.8633, 30.8936], [109.4238, 30.542], [109.248, 30.6299], [109.1602, 30.542], [109.0723, 30.6299], [108.8086, 30.498], [108.6328, 30.5859], [108.457, 30.4102], [108.5449, 30.2344], [108.457, 29.7949], [108.6328, 29.8389], [108.9844, 29.3115], [109.0723, 29.3555], [109.248, 29.1357], [109.248, 28.4766], [109.0723, 28.2129], [108.7207, 28.2129], [108.7207, 28.4766], [108.5449, 28.3887], [108.5449, 28.6523], [108.3691, 28.6523], [108.2813, 29.0918], [107.8418, 29.0039], [107.8418, 29.1357], [107.5781, 29.2236], [107.4023, 29.1797], [107.4023, 28.8721], [106.875, 28.7842], [106.6992, 28.4766], [106.6113, 28.5205], [106.6113, 28.6523], [106.5234, 28.7842], [106.4355, 28.7842], [106.5234, 28.5645], [106.3477, 28.5205], [106.2598, 28.8721], [105.8203, 28.96], [105.7324, 29.2676], [105.4688, 29.3115], [105.293, 29.5313], [105.7324, 29.8828], [105.5566, 30.1025], [105.6445, 30.2783], [105.8203, 30.4541], [106.2598, 30.1904], [106.6113, 30.3223], [106.7871, 30.0146], [107.0508, 30.0146], [107.4902, 30.6299], [107.4023, 30.7617], [107.4902, 30.8496], [107.9297, 30.8496], [108.1934, 31.5088], [108.5449, 31.6846]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "64",
|
||
|
"name": "宁夏",
|
||
|
"cp": [105.9961, 37.3096],
|
||
|
"childNum": 5
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[104.3262, 37.4414], [105.8203, 37.793], [105.9082, 38.7158], [106.3477, 39.2871], [106.7871, 39.375], [106.9629, 38.9795], [106.5234, 38.3203], [106.7871, 38.1885], [107.3145, 38.1006], [107.666, 37.8809], [107.3145, 37.6172], [107.3145, 37.0898], [106.6113, 37.0898], [106.6113, 36.7822], [106.4355, 36.5625], [106.5234, 36.4746], [106.5234, 36.2549], [106.875, 36.123], [106.9629, 35.8154], [106.6992, 35.6836], [106.4355, 35.6836], [106.5234, 35.332], [106.3477, 35.2441], [106.2598, 35.4199], [106.084, 35.376], [105.9961, 35.4199], [106.084, 35.4639], [105.9961, 35.4639], [105.8203, 35.5518], [105.7324, 35.7275], [105.3809, 35.7715], [105.293, 35.9912], [105.4688, 36.123], [105.2051, 36.6943], [105.293, 36.8262], [104.8535, 37.2217], [104.5898, 37.2217], [104.5898, 37.4414], [104.3262, 37.4414]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "46",
|
||
|
"name": "海南",
|
||
|
"cp": [109.9512, 19.2041],
|
||
|
"childNum": 18
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[108.6328, 19.3799], [109.0723, 19.6436], [109.248, 19.9512], [109.5996, 20.0391], [110.0391, 20.127], [110.3906, 20.127], [110.5664, 20.2588], [110.6543, 20.2588], [111.0938, 19.9512], [111.2695, 19.9951], [110.6543, 19.1602], [110.5664, 18.6768], [110.2148, 18.5889], [110.0391, 18.3691], [109.8633, 18.3691], [109.6875, 18.1055], [108.9844, 18.2813], [108.6328, 18.457], [108.6328, 19.3799]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "71",
|
||
|
"name": "台湾",
|
||
|
"cp": [121.0254, 23.5986],
|
||
|
"childNum": 1
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[121.9043, 25.0488], [121.9922, 25.0049], [121.8164, 24.7412], [121.9043, 24.5654], [121.6406, 24.0381], [121.377, 23.1152], [121.0254, 22.6758], [120.8496, 22.0605], [120.7617, 21.9287], [120.6738, 22.3242], [120.2344, 22.5879], [120.0586, 23.0713], [120.1465, 23.6865], [121.0254, 25.0488], [121.5527, 25.3125], [121.9043, 25.0488]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "11",
|
||
|
"name": "北京",
|
||
|
"cp": [116.4551, 40.2539],
|
||
|
"childNum": 19
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[117.4219, 40.21], [117.334, 40.1221], [117.2461, 40.0781], [116.8066, 39.9902], [116.8945, 39.8145], [116.8945, 39.6826], [116.8066, 39.5947], [116.543, 39.5947], [116.3672, 39.4629], [116.1914, 39.5947], [115.752, 39.5068], [115.4883, 39.6387], [115.4004, 39.9463], [115.9277, 40.2539], [115.752, 40.5615], [116.1035, 40.6055], [116.1914, 40.7813], [116.4551, 40.7813], [116.3672, 40.9131], [116.6309, 41.0449], [116.9824, 40.6934], [117.4219, 40.6494], [117.2461, 40.5176], [117.4219, 40.21]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "12",
|
||
|
"name": "天津",
|
||
|
"cp": [117.4219, 39.4189],
|
||
|
"childNum": 18
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[116.8066, 39.5947], [116.8945, 39.6826], [117.1582, 39.6387], [117.1582, 39.8145], [117.2461, 40.0781], [117.334, 40.1221], [117.4219, 40.21], [117.6855, 40.0781], [117.6855, 39.9902], [117.5098, 39.9902], [117.5098, 39.7705], [117.6855, 39.5947], [117.9492, 39.5947], [117.8613, 39.4189], [118.0371, 39.2432], [118.0371, 39.1992], [117.8613, 39.1113], [117.5977, 38.6279], [117.2461, 38.54], [116.7188, 38.8037], [116.7188, 38.9355], [116.8945, 39.1113], [116.8066, 39.5947]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "31",
|
||
|
"name": "上海",
|
||
|
"cp": [121.4648, 31.2891],
|
||
|
"childNum": 19
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[120.9375, 31.0254], [121.2012, 31.4648], [121.377, 31.5088], [121.1133, 31.7285], [121.2012, 31.8604], [121.9922, 31.5967], [121.9043, 31.1572], [121.9922, 30.8057], [121.2891, 30.6738], [120.9375, 31.0254]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "81",
|
||
|
"name": "香港",
|
||
|
"cp": [114.2578, 22.3242],
|
||
|
"childNum": 1
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[114.6094, 22.4121], [114.5215, 22.1484], [114.3457, 22.1484], [113.9063, 22.1484], [113.8184, 22.1924], [113.9063, 22.4121], [114.1699, 22.5439], [114.3457, 22.5439], [114.4336, 22.5439], [114.4336, 22.4121], [114.6094, 22.4121]]]
|
||
|
}
|
||
|
}, {
|
||
|
"type": "Feature",
|
||
|
"properties": {
|
||
|
"id": "82",
|
||
|
"name": "澳门",
|
||
|
"cp": [113.5547, 22.1484],
|
||
|
"childNum": 1
|
||
|
},
|
||
|
"geometry": {
|
||
|
"type": "Polygon",
|
||
|
"coordinates": [[[113.5986, 22.1649], [113.6096, 22.1265], [113.5547, 22.11], [113.5437, 22.2034], [113.5767, 22.2034], [113.5986, 22.1649]]]
|
||
|
}
|
||
|
}]
|
||
|
};
|
||
|
|
||
|
var China = {};
|
||
|
china.features.forEach(function (data) {
|
||
|
var name = data.properties.name;
|
||
|
var center = data.properties.cp;
|
||
|
var geomerty = data.geometry.coordinates;
|
||
|
China[name] = {
|
||
|
center: center,
|
||
|
geomerty: geomerty
|
||
|
};
|
||
|
});
|
||
|
|
||
|
var THREE$1 = function THREE(dmo) {
|
||
|
classCallCheck(this, THREE);
|
||
|
|
||
|
var gl = new GL(dmo);
|
||
|
|
||
|
Object.keys(China).map(function (province) {
|
||
|
China[province].geomerty.map(function (geo) {
|
||
|
var path = [];
|
||
|
path = path.concat(geo.map(function (point) {
|
||
|
return [point[0] * 100, point[1] * 100, 0];
|
||
|
}));
|
||
|
gl.Path({
|
||
|
path: path
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
return gl;
|
||
|
};
|
||
|
|
||
|
var X = function () {
|
||
|
function X(dom, opt) {
|
||
|
classCallCheck(this, X);
|
||
|
|
||
|
this.dom = dom;
|
||
|
this.opt = opt;
|
||
|
this.init();
|
||
|
}
|
||
|
|
||
|
createClass(X, [{
|
||
|
key: 'init',
|
||
|
value: function init() {
|
||
|
var zoom = 1;
|
||
|
|
||
|
var scene = new THREE.Scene();
|
||
|
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.01, 10e7);
|
||
|
var renderer = new THREE.WebGLRenderer();
|
||
|
|
||
|
// add controls
|
||
|
var controls = new THREE.OrbitControls(camera, renderer.domElement);
|
||
|
controls.enableDamping = true;
|
||
|
controls.dampingFactor = 0.25;
|
||
|
// controls.enableZoom = false;
|
||
|
renderer.setSize(this.dom.clientWidth, this.dom.clientHeight);
|
||
|
this.dom.appendChild(renderer.domElement);
|
||
|
|
||
|
var geometry = new THREE.PlaneGeometry(80 * zoom, 50 * zoom, 10, 10);
|
||
|
var material = new THREE.MeshBasicMaterial({
|
||
|
color: 0x585858,
|
||
|
wireframe: true
|
||
|
});
|
||
|
var cube = window.cube = new THREE.Mesh(geometry, material);
|
||
|
cube.rotateX(-Math.PI / 2);
|
||
|
scene.add(cube);
|
||
|
camera.position.y = 50 * zoom;
|
||
|
camera.position.z = 50 * zoom;
|
||
|
camera.lookAt(new THREE.Vector3(0, 0, 0));
|
||
|
|
||
|
function render() {
|
||
|
requestAnimationFrame(render);
|
||
|
renderer.render(scene, camera);
|
||
|
controls.update();
|
||
|
}
|
||
|
render();
|
||
|
|
||
|
var sizeZoom = this.opt.grid.size * zoom;
|
||
|
|
||
|
var gradeData = {};
|
||
|
var min = Infinity;
|
||
|
var max = -Infinity;
|
||
|
for (var i in data) {
|
||
|
var x = parseInt(data[i].lng * zoom / sizeZoom) * sizeZoom;
|
||
|
var y = parseInt(data[i].lat * zoom / sizeZoom) * sizeZoom;
|
||
|
gradeData[x + '_' + y] = gradeData[x + '_' + y] || 0;
|
||
|
gradeData[x + '_' + y]++;
|
||
|
max = Math.max(max, gradeData[x + '_' + y]);
|
||
|
min = Math.min(min, gradeData[x + '_' + y]);
|
||
|
}
|
||
|
|
||
|
// color~
|
||
|
var color = getColor();
|
||
|
|
||
|
var lines = new THREE.Object3D();
|
||
|
for (var i in gradeData) {
|
||
|
var colorPersent = max == min ? 0 : (gradeData[i] - min) / (max - min);
|
||
|
var colorInedx = parseInt(colorPersent * (color.length / 4)) - 1;
|
||
|
colorInedx = colorInedx < 0 ? 0 : colorInedx;
|
||
|
var r = color[colorInedx * 4].toString(16);
|
||
|
r = r.length < 2 ? '0' + r : r;
|
||
|
var g = color[colorInedx * 4 + 1].toString(16);
|
||
|
g = g.length < 2 ? '0' + g : g;
|
||
|
var b = color[colorInedx * 4 + 2].toString(16);
|
||
|
b = b.length < 2 ? '0' + b : b;
|
||
|
|
||
|
var height = gradeData[i] * 1.5;
|
||
|
var geometry = new THREE.BoxGeometry(sizeZoom * 0.9, height, sizeZoom * 0.9);
|
||
|
var material = new THREE.MeshBasicMaterial({
|
||
|
color: '#' + r + g + b
|
||
|
});
|
||
|
var cube = new THREE.Mesh(geometry, material);
|
||
|
var pos = i.split('_');
|
||
|
cube.position.x = pos[0] - this.opt.center.lng * zoom;
|
||
|
cube.position.y = height / 2;
|
||
|
cube.position.z = this.opt.center.lat * zoom - pos[1];
|
||
|
lines.add(cube);
|
||
|
}
|
||
|
scene.add(lines);
|
||
|
}
|
||
|
}]);
|
||
|
return X;
|
||
|
}();
|
||
|
|
||
|
function getColor() {
|
||
|
var canvas = document.createElement('canvas');
|
||
|
var ctx = canvas.getContext('2d');
|
||
|
var gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
||
|
gradient.addColorStop(1, "#F00");
|
||
|
gradient.addColorStop(0.6, "#FFFC00");
|
||
|
gradient.addColorStop(0.3, "#00FF1D");
|
||
|
gradient.addColorStop(0, "#000BFF");
|
||
|
ctx.fillStyle = gradient;
|
||
|
ctx.fillRect(0, 0, 256, 1);
|
||
|
var data = ctx.getImageData(0, 0, 256, 1);
|
||
|
return data.data;
|
||
|
}
|
||
|
|
||
|
function Canvas(width, height) {
|
||
|
|
||
|
var canvas;
|
||
|
|
||
|
if (typeof document === 'undefined') {
|
||
|
|
||
|
var Canvas = require('canvas');
|
||
|
canvas = new Canvas(width, height);
|
||
|
} else {
|
||
|
|
||
|
var canvas = document.createElement('canvas');
|
||
|
|
||
|
if (width) {
|
||
|
canvas.width = width;
|
||
|
}
|
||
|
|
||
|
if (height) {
|
||
|
canvas.height = height;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return canvas;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @author kyle / http://nikai.us/
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* Category
|
||
|
* @param {Object} [options] Available options:
|
||
|
* {Object} gradient: { 0.25: "rgb(0,0,255)", 0.55: "rgb(0,255,0)", 0.85: "yellow", 1.0: "rgb(255,0,0)"}
|
||
|
*/
|
||
|
function Intensity(options) {
|
||
|
|
||
|
options = options || {};
|
||
|
this.gradient = options.gradient || {
|
||
|
0.25: "rgba(0, 0, 255, 1)",
|
||
|
0.55: "rgba(0, 255, 0, 1)",
|
||
|
0.85: "rgba(255, 255, 0, 1)",
|
||
|
1.0: "rgba(255, 0, 0, 1)"
|
||
|
};
|
||
|
this.maxSize = options.maxSize || 35;
|
||
|
this.minSize = options.minSize || 0;
|
||
|
this.max = options.max || 100;
|
||
|
this.min = options.min || 0;
|
||
|
this.initPalette();
|
||
|
}
|
||
|
|
||
|
Intensity.prototype.setMax = function (value) {
|
||
|
this.max = value || 100;
|
||
|
};
|
||
|
|
||
|
Intensity.prototype.setMin = function (value) {
|
||
|
this.min = value || 0;
|
||
|
};
|
||
|
|
||
|
Intensity.prototype.setMaxSize = function (maxSize) {
|
||
|
this.maxSize = maxSize || 35;
|
||
|
};
|
||
|
|
||
|
Intensity.prototype.setMinSize = function (minSize) {
|
||
|
this.minSize = minSize || 0;
|
||
|
};
|
||
|
|
||
|
Intensity.prototype.initPalette = function () {
|
||
|
|
||
|
var gradient = this.gradient;
|
||
|
|
||
|
var canvas = new Canvas(256, 1);
|
||
|
|
||
|
var paletteCtx = this.paletteCtx = canvas.getContext('2d');
|
||
|
|
||
|
var lineGradient = paletteCtx.createLinearGradient(0, 0, 256, 1);
|
||
|
|
||
|
for (var key in gradient) {
|
||
|
lineGradient.addColorStop(parseFloat(key), gradient[key]);
|
||
|
}
|
||
|
|
||
|
paletteCtx.fillStyle = lineGradient;
|
||
|
paletteCtx.fillRect(0, 0, 256, 1);
|
||
|
};
|
||
|
|
||
|
Intensity.prototype.getColor = function (value) {
|
||
|
|
||
|
var imageData = this.getImageData(value);
|
||
|
|
||
|
return "rgba(" + imageData[0] + ", " + imageData[1] + ", " + imageData[2] + ", " + imageData[3] / 256 + ")";
|
||
|
};
|
||
|
|
||
|
Intensity.prototype.getImageData = function (value) {
|
||
|
|
||
|
var imageData = this.paletteCtx.getImageData(0, 0, 256, 1).data;
|
||
|
|
||
|
if (value === undefined) {
|
||
|
return imageData;
|
||
|
}
|
||
|
|
||
|
var max = this.max;
|
||
|
var min = this.min;
|
||
|
|
||
|
if (value > max) {
|
||
|
value = max;
|
||
|
}
|
||
|
|
||
|
if (value < min) {
|
||
|
value = min;
|
||
|
}
|
||
|
|
||
|
var index = Math.floor((value - min) / (max - min) * (256 - 1)) * 4;
|
||
|
|
||
|
return [imageData[index], imageData[index + 1], imageData[index + 2], imageData[index + 3]];
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @param Number value
|
||
|
* @param Number max of value
|
||
|
* @param Number max of size
|
||
|
* @param Object other options
|
||
|
*/
|
||
|
Intensity.prototype.getSize = function (value) {
|
||
|
|
||
|
var size = 0;
|
||
|
var max = this.max;
|
||
|
var min = this.min;
|
||
|
var maxSize = this.maxSize;
|
||
|
var minSize = this.minSize;
|
||
|
|
||
|
if (value > max) {
|
||
|
value = max;
|
||
|
}
|
||
|
|
||
|
if (value < min) {
|
||
|
value = min;
|
||
|
}
|
||
|
|
||
|
size = minSize + (value - min) / (max - min) * (maxSize - minSize);
|
||
|
|
||
|
return size;
|
||
|
};
|
||
|
|
||
|
Intensity.prototype.getLegend = function (options) {
|
||
|
var gradient = this.gradient;
|
||
|
|
||
|
var width = options.width || 20;
|
||
|
var height = options.height || 180;
|
||
|
|
||
|
var canvas = new Canvas(width, height);
|
||
|
|
||
|
var paletteCtx = canvas.getContext('2d');
|
||
|
|
||
|
var lineGradient = paletteCtx.createLinearGradient(0, height, 0, 0);
|
||
|
|
||
|
for (var key in gradient) {
|
||
|
lineGradient.addColorStop(parseFloat(key), gradient[key]);
|
||
|
}
|
||
|
|
||
|
paletteCtx.fillStyle = lineGradient;
|
||
|
paletteCtx.fillRect(0, 0, width, height);
|
||
|
|
||
|
return canvas;
|
||
|
};
|
||
|
|
||
|
function Flate(container) {
|
||
|
|
||
|
this.container = container;
|
||
|
this.init();
|
||
|
|
||
|
var that = this;
|
||
|
|
||
|
this.group = new THREE.Group();
|
||
|
|
||
|
this.center = [105, 33];
|
||
|
|
||
|
function animate(time) {
|
||
|
requestAnimationFrame(animate);
|
||
|
|
||
|
//that.controls.update();
|
||
|
|
||
|
that.render();
|
||
|
}
|
||
|
|
||
|
requestAnimationFrame(animate);
|
||
|
}
|
||
|
|
||
|
Flate.prototype.init = function () {
|
||
|
this.intensity = new Intensity({
|
||
|
gradient: {
|
||
|
0: '#006bab',
|
||
|
1: '#002841'
|
||
|
},
|
||
|
max: 100
|
||
|
});
|
||
|
|
||
|
var WIDTH = this.container.offsetWidth;
|
||
|
var HEIGHT = this.container.offsetHeight;
|
||
|
var camera = this.camera = new THREE.PerspectiveCamera(40, WIDTH / HEIGHT, 0.01, 9000);
|
||
|
camera.position.x = 0;
|
||
|
camera.position.y = 0;
|
||
|
camera.position.z = 85;
|
||
|
camera.lookAt(new THREE.Vector3(0, 0, 0));
|
||
|
|
||
|
var scene = this.scene = new THREE.Scene();
|
||
|
|
||
|
var renderer = this.renderer = new THREE.WebGLRenderer({
|
||
|
alpha: true
|
||
|
});
|
||
|
|
||
|
/*
|
||
|
var controls = this.controls = new THREE.OrbitControls( camera, renderer.domElement );
|
||
|
controls.enableDamping = true;
|
||
|
controls.dampingFactor = 0.25;
|
||
|
controls.enableZoom = true;
|
||
|
*/
|
||
|
|
||
|
// renderer.setClearColor('rgb(1, 11, 21)', 1);
|
||
|
renderer.setPixelRatio(window.devicePixelRatio);
|
||
|
renderer.setSize(WIDTH, HEIGHT);
|
||
|
|
||
|
this.container.appendChild(renderer.domElement);
|
||
|
|
||
|
var floorTexture = THREE.ImageUtils.loadTexture('images/china.png');
|
||
|
var floorMaterial = new THREE.MeshBasicMaterial({
|
||
|
map: floorTexture,
|
||
|
transparent: true,
|
||
|
side: THREE.DoubleSide
|
||
|
});
|
||
|
var floorGeometry = new THREE.PlaneGeometry(100, 100, 1, 1);
|
||
|
var floor = new THREE.Mesh(floorGeometry, floorMaterial);
|
||
|
floor.position.x = 0;
|
||
|
floor.position.y = 0;
|
||
|
floor.position.z = 0;
|
||
|
//scene.add(floor);
|
||
|
|
||
|
// LIGHT
|
||
|
var light = new THREE.PointLight('rgb(50, 50, 250)');
|
||
|
light.position.set(0, 0, 35);
|
||
|
scene.add(light);
|
||
|
|
||
|
var SUBDIVISIONS = 20;
|
||
|
var geometry = new THREE.Geometry();
|
||
|
var curve = new THREE.QuadraticBezierCurve3();
|
||
|
curve.v0 = new THREE.Vector3(0, 0, 0);
|
||
|
curve.v1 = new THREE.Vector3(20, 20, 0);
|
||
|
curve.v2 = new THREE.Vector3(40, 40, 0);
|
||
|
for (var j = 0; j < SUBDIVISIONS; j++) {
|
||
|
geometry.vertices.push(curve.getPoint(j / SUBDIVISIONS));
|
||
|
}
|
||
|
|
||
|
var material = new THREE.LineBasicMaterial({ color: 0xff0000, linewidth: 95 });
|
||
|
var line = this.line = new THREE.Line(geometry, material);
|
||
|
//scene.add(line);
|
||
|
|
||
|
this.current = 0;
|
||
|
};
|
||
|
|
||
|
Flate.prototype.render = function () {
|
||
|
|
||
|
var SUBDIVISIONS = 50;
|
||
|
var geometry = new THREE.Geometry();
|
||
|
var curve = new THREE.QuadraticBezierCurve3();
|
||
|
curve.v0 = new THREE.Vector3(0, 0, 0);
|
||
|
curve.v1 = new THREE.Vector3(25, 25, 50);
|
||
|
curve.v2 = new THREE.Vector3(50, 50, 0);
|
||
|
this.current += 0.01;
|
||
|
if (this.current > 1) {
|
||
|
this.current = 0;
|
||
|
}
|
||
|
|
||
|
for (var j = 0; j < SUBDIVISIONS; j++) {
|
||
|
var percent = j / SUBDIVISIONS;
|
||
|
if (percent < this.current) {
|
||
|
geometry.vertices.push(curve.getPoint(percent));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//this.line.geometry = geometry;
|
||
|
|
||
|
this.renderer.render(this.scene, this.camera);
|
||
|
};
|
||
|
|
||
|
Flate.prototype.setDataSet = function (dataSet) {
|
||
|
// create a canvas element
|
||
|
var canvas = document.createElement('canvas');
|
||
|
var context = canvas.getContext('2d');
|
||
|
canvas.width = 50;
|
||
|
canvas.height = 50;
|
||
|
context.fillStyle = "rgba(255,255,50,0.75)";
|
||
|
//context.shadowColor = "rgba(255,255,255,0.95)";
|
||
|
//context.shadowBlur = 0;
|
||
|
context.arc(25, 25, 10, 0, Math.PI * 2);
|
||
|
context.fill();
|
||
|
|
||
|
// canvas contents will be used for a texture
|
||
|
var texture = new THREE.Texture(canvas);
|
||
|
texture.needsUpdate = true;
|
||
|
|
||
|
var material = new THREE.MeshBasicMaterial({ map: texture, side: THREE.DoubleSide });
|
||
|
material.transparent = true;
|
||
|
|
||
|
var rs = dataSet.get();
|
||
|
var features = rs;
|
||
|
for (var i = 0; i < features.length; i++) {
|
||
|
var feature = features[i];
|
||
|
if (feature.geometry.type == 'Polygon') {
|
||
|
var coords = this.getCoordinates(feature.geometry.coordinates[0]);
|
||
|
this.addShape(coords);
|
||
|
} else if (feature.geometry.type == 'MultiPolygon') {
|
||
|
for (var j = 0; j < feature.geometry.coordinates.length; j++) {
|
||
|
var coords = this.getCoordinates(feature.geometry.coordinates[j][0]);
|
||
|
this.addShape(coords);
|
||
|
}
|
||
|
} else if (feature.geometry.type == 'Point') {
|
||
|
|
||
|
var size = canvas.width / 15 + Math.random() * 4;
|
||
|
var mesh = new THREE.Mesh(new THREE.PlaneGeometry(size, size), material);
|
||
|
mesh.position.set(feature.geometry.coordinates[0] - this.center[0], feature.geometry.coordinates[1] - this.center[1], 1);
|
||
|
this.scene.add(mesh);
|
||
|
}
|
||
|
|
||
|
var cityname = feature.name;
|
||
|
var center = feature.cp;
|
||
|
}
|
||
|
this.scene.add(this.group);
|
||
|
};
|
||
|
|
||
|
Flate.prototype.getCoordinates = function (coordinates) {
|
||
|
var coords = [];
|
||
|
for (var j = 0; j < coordinates.length; j++) {
|
||
|
coords.push(new THREE.Vector2(coordinates[j][0] - this.center[0], coordinates[j][1] - this.center[1]));
|
||
|
}
|
||
|
return coords;
|
||
|
};
|
||
|
|
||
|
Flate.prototype.addShape = function (coords) {
|
||
|
var shape = new THREE.Shape(coords);
|
||
|
var geometry = new THREE.ShapeGeometry(shape);
|
||
|
|
||
|
var color = 'rgb(' + ~~(Math.random() * 256) + ', ' + ~~(Math.random() * 256) + ', ' + ~~(Math.random() * 256) + ')';
|
||
|
color = this.intensity.getColor(Math.random() * 100);
|
||
|
var mesh = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({ color: color, side: THREE.DoubleSide }));
|
||
|
mesh.position.set(0, 0, 0);
|
||
|
this.group.add(mesh);
|
||
|
|
||
|
var points = shape.createPointsGeometry();
|
||
|
var line = new THREE.Line(points, new THREE.LineBasicMaterial({ color: 'rgb(0, 137, 191)', linewidth: 1 }));
|
||
|
line.position.set(0, 0, 0.1);
|
||
|
this.group.add(line);
|
||
|
};
|
||
|
|
||
|
var flights = [[43.061306, 74.477556, 40.608989, 72.793269]];
|
||
|
|
||
|
var index = 100;
|
||
|
while (index--) {
|
||
|
flights.push([19.670399 + Math.random() * 35, 78.895343 + Math.random() * 50, 19.670399 + Math.random() * 35, 78.895343 + Math.random() * 50]);
|
||
|
}
|
||
|
|
||
|
var positions;
|
||
|
var start_flight_idx = 0;
|
||
|
var end_flight_idx = flights.length;
|
||
|
var flight_path_splines = [];
|
||
|
var flight_distance = [];
|
||
|
var flight_path_lines;
|
||
|
var flight_track_opacity = 0.32;
|
||
|
var flight_point_cloud_geom;
|
||
|
var flight_point_start_time = [];
|
||
|
var flight_point_end_time = [];
|
||
|
var flight_point_speed_changed = false;
|
||
|
var flight_point_speed_scaling = 5.0;
|
||
|
var flight_point_speed_min_scaling = 1.0;
|
||
|
var flight_point_speed_max_scaling = 25.0;
|
||
|
|
||
|
function Earth(container) {
|
||
|
|
||
|
this.container = container;
|
||
|
this.init();
|
||
|
|
||
|
var that = this;
|
||
|
|
||
|
function animate(time) {
|
||
|
requestAnimationFrame(animate);
|
||
|
that.render();
|
||
|
}
|
||
|
|
||
|
requestAnimationFrame(animate);
|
||
|
}
|
||
|
|
||
|
Earth.prototype.init = function () {
|
||
|
var WIDTH = this.container.offsetWidth;
|
||
|
var HEIGHT = this.container.offsetHeight;
|
||
|
var camera = this.camera = new THREE.PerspectiveCamera(40, WIDTH / HEIGHT, 0.01, 9000);
|
||
|
camera.position.z = 1.0;
|
||
|
|
||
|
var scene = this.scene = new THREE.Scene();
|
||
|
|
||
|
var renderer = this.renderer = new THREE.WebGLRenderer({
|
||
|
alpha: true
|
||
|
});
|
||
|
// renderer.setClearColor('rgb(1, 11, 21)', 1);
|
||
|
renderer.setPixelRatio(window.devicePixelRatio);
|
||
|
renderer.setSize(WIDTH, HEIGHT);
|
||
|
|
||
|
this.container.appendChild(renderer.domElement);
|
||
|
|
||
|
// LIGHT
|
||
|
/*
|
||
|
var light = new THREE.PointLight('rgb(50, 50, 250)');
|
||
|
light.position.set(0, 0, 35);
|
||
|
scene.add(light);
|
||
|
*/
|
||
|
|
||
|
scene.add(new THREE.AmbientLight(0x777777));
|
||
|
|
||
|
var light1 = new THREE.DirectionalLight(0xffffff, 0.2);
|
||
|
light1.position.set(5, 3, 5);
|
||
|
scene.add(light1);
|
||
|
|
||
|
var light2 = new THREE.DirectionalLight(0xffffff, 0.2);
|
||
|
light2.position.set(5, 3, -5);
|
||
|
scene.add(light2);
|
||
|
|
||
|
var earth_img, elevation_img, water_img;
|
||
|
var radius = 0.5;
|
||
|
var segments = 64;
|
||
|
earth_img = THREE.ImageUtils.loadTexture('images/earth_airports.png', THREE.UVMapping, function () {
|
||
|
elevation_img = THREE.ImageUtils.loadTexture('images/elevation.jpg', THREE.UVMapping, function () {
|
||
|
water_img = THREE.ImageUtils.loadTexture('images/water.png', THREE.UVMapping, function () {
|
||
|
var earth = new THREE.Mesh(new THREE.SphereGeometry(radius, segments, segments), new THREE.MeshPhongMaterial({
|
||
|
map: earth_img,
|
||
|
bumpMap: elevation_img,
|
||
|
bumpScale: 0.01,
|
||
|
specularMap: water_img,
|
||
|
specular: new THREE.Color('grey')
|
||
|
}));
|
||
|
earth.rotation.y = 170 * (Math.PI / 180);
|
||
|
earth.rotation.x = 30 * (Math.PI / 180);
|
||
|
scene.add(earth);
|
||
|
|
||
|
generateControlPoints(radius);
|
||
|
|
||
|
flight_path_lines = flightPathLines();
|
||
|
earth.add(flight_path_lines);
|
||
|
|
||
|
earth.add(flightPointCloud());
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
};
|
||
|
|
||
|
Earth.prototype.render = function () {
|
||
|
update_flights();
|
||
|
|
||
|
this.renderer.render(this.scene, this.camera);
|
||
|
};
|
||
|
|
||
|
Earth.prototype.setDataSet = function (dataSet) {
|
||
|
console.log(dataSet.get());
|
||
|
};
|
||
|
|
||
|
function generateControlPoints(radius) {
|
||
|
for (var f = start_flight_idx; f < end_flight_idx; ++f) {
|
||
|
|
||
|
var start_lat = flights[f][0];
|
||
|
var start_lng = flights[f][1];
|
||
|
var end_lat = flights[f][2];
|
||
|
var end_lng = flights[f][3];
|
||
|
|
||
|
var max_height = Math.random() * 0.04;
|
||
|
|
||
|
var points = [];
|
||
|
var spline_control_points = 8;
|
||
|
for (var i = 0; i < spline_control_points + 1; i++) {
|
||
|
var arc_angle = i * 180.0 / spline_control_points;
|
||
|
var arc_radius = radius + Math.sin(arc_angle * Math.PI / 180.0) * max_height;
|
||
|
var latlng = latlngInterPoint(start_lat, start_lng, end_lat, end_lng, i / spline_control_points);
|
||
|
|
||
|
var pos = xyzFromLatLng(latlng.lat, latlng.lng, arc_radius);
|
||
|
|
||
|
points.push(new THREE.Vector3(pos.x, pos.y, pos.z));
|
||
|
}
|
||
|
|
||
|
var spline = new THREE.SplineCurve3(points);
|
||
|
|
||
|
flight_path_splines.push(spline);
|
||
|
|
||
|
var arc_length = spline.getLength();
|
||
|
flight_distance.push(arc_length);
|
||
|
|
||
|
setFlightTimes(f);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function latlngInterPoint(lat1, lng1, lat2, lng2, offset) {
|
||
|
lat1 = lat1 * Math.PI / 180.0;
|
||
|
lng1 = lng1 * Math.PI / 180.0;
|
||
|
lat2 = lat2 * Math.PI / 180.0;
|
||
|
lng2 = lng2 * Math.PI / 180.0;
|
||
|
|
||
|
var d = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((lat1 - lat2) / 2), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin((lng1 - lng2) / 2), 2)));
|
||
|
var A = Math.sin((1 - offset) * d) / Math.sin(d);
|
||
|
var B = Math.sin(offset * d) / Math.sin(d);
|
||
|
var x = A * Math.cos(lat1) * Math.cos(lng1) + B * Math.cos(lat2) * Math.cos(lng2);
|
||
|
var y = A * Math.cos(lat1) * Math.sin(lng1) + B * Math.cos(lat2) * Math.sin(lng2);
|
||
|
var z = A * Math.sin(lat1) + B * Math.sin(lat2);
|
||
|
var lat = Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))) * 180 / Math.PI;
|
||
|
var lng = Math.atan2(y, x) * 180 / Math.PI;
|
||
|
|
||
|
return {
|
||
|
lat: lat,
|
||
|
lng: lng
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function xyzFromLatLng(lat, lng, radius) {
|
||
|
var phi = (90 - lat) * Math.PI / 180;
|
||
|
var theta = (360 - lng) * Math.PI / 180;
|
||
|
|
||
|
return {
|
||
|
x: radius * Math.sin(phi) * Math.cos(theta),
|
||
|
y: radius * Math.cos(phi),
|
||
|
z: radius * Math.sin(phi) * Math.sin(theta)
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function flightPathLines() {
|
||
|
|
||
|
var num_control_points = 32;
|
||
|
|
||
|
var geometry = new THREE.BufferGeometry();
|
||
|
var material = new THREE.LineBasicMaterial({
|
||
|
color: 0xffff00,
|
||
|
vertexColors: THREE.VertexColors,
|
||
|
transparent: true,
|
||
|
opacity: flight_track_opacity,
|
||
|
depthTest: true,
|
||
|
depthWrite: false,
|
||
|
linewidth: 1.0001
|
||
|
});
|
||
|
var line_positions = new Float32Array(flights.length * 3 * 2 * num_control_points);
|
||
|
var colors = new Float32Array(flights.length * 3 * 2 * num_control_points);
|
||
|
|
||
|
for (var i = start_flight_idx; i < end_flight_idx; ++i) {
|
||
|
|
||
|
for (var j = 0; j < num_control_points - 1; ++j) {
|
||
|
|
||
|
var start_pos = flight_path_splines[i].getPoint(j / (num_control_points - 1));
|
||
|
var end_pos = flight_path_splines[i].getPoint((j + 1) / (num_control_points - 1));
|
||
|
|
||
|
line_positions[(i * num_control_points + j) * 6 + 0] = start_pos.x;
|
||
|
line_positions[(i * num_control_points + j) * 6 + 1] = start_pos.y;
|
||
|
line_positions[(i * num_control_points + j) * 6 + 2] = start_pos.z;
|
||
|
line_positions[(i * num_control_points + j) * 6 + 3] = end_pos.x;
|
||
|
line_positions[(i * num_control_points + j) * 6 + 4] = end_pos.y;
|
||
|
line_positions[(i * num_control_points + j) * 6 + 5] = end_pos.z;
|
||
|
|
||
|
colors[(i * num_control_points + j) * 6 + 0] = 1.0;
|
||
|
colors[(i * num_control_points + j) * 6 + 1] = 0.4;
|
||
|
colors[(i * num_control_points + j) * 6 + 2] = 1.0;
|
||
|
colors[(i * num_control_points + j) * 6 + 3] = 1.0;
|
||
|
colors[(i * num_control_points + j) * 6 + 4] = 0.4;
|
||
|
colors[(i * num_control_points + j) * 6 + 5] = 1.0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
geometry.addAttribute('position', new THREE.BufferAttribute(line_positions, 3));
|
||
|
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3));
|
||
|
|
||
|
geometry.computeBoundingSphere();
|
||
|
|
||
|
return new THREE.Line(geometry, material, THREE.LinePieces);
|
||
|
}
|
||
|
|
||
|
function flightPointCloud() {
|
||
|
flight_point_cloud_geom = new THREE.BufferGeometry();
|
||
|
|
||
|
var num_points = flights.length;
|
||
|
|
||
|
positions = new Float32Array(num_points * 3);
|
||
|
var colors = new Float32Array(num_points * 3);
|
||
|
var sizes = new Float32Array(num_points);
|
||
|
|
||
|
for (var i = 0; i < num_points; i++) {
|
||
|
positions[3 * i + 0] = 0;
|
||
|
positions[3 * i + 1] = 0;
|
||
|
positions[3 * i + 2] = 0;
|
||
|
|
||
|
colors[3 * i + 0] = Math.random();
|
||
|
colors[3 * i + 1] = Math.random();
|
||
|
colors[3 * i + 2] = Math.random();
|
||
|
|
||
|
sizes[i] = 0.1;
|
||
|
}
|
||
|
|
||
|
flight_point_cloud_geom.addAttribute('position', new THREE.BufferAttribute(positions, 3));
|
||
|
flight_point_cloud_geom.addAttribute('customColor', new THREE.BufferAttribute(colors, 3));
|
||
|
flight_point_cloud_geom.addAttribute('size', new THREE.BufferAttribute(sizes, 1));
|
||
|
flight_point_cloud_geom.computeBoundingBox();
|
||
|
|
||
|
var attributes = {
|
||
|
size: {
|
||
|
type: 'f',
|
||
|
value: null
|
||
|
},
|
||
|
customColor: {
|
||
|
type: 'c',
|
||
|
value: null
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var uniforms = {
|
||
|
color: {
|
||
|
type: "c",
|
||
|
value: new THREE.Color(0xffffff)
|
||
|
},
|
||
|
texture: {
|
||
|
type: "t",
|
||
|
value: THREE.ImageUtils.loadTexture("images/point.png")
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var shaderMaterial = new THREE.ShaderMaterial({
|
||
|
uniforms: uniforms,
|
||
|
//attributes: attributes,
|
||
|
vertexShader: document.getElementById('vertexshader').textContent,
|
||
|
fragmentShader: document.getElementById('fragmentshader').textContent,
|
||
|
blending: THREE.AdditiveBlending,
|
||
|
depthTest: true,
|
||
|
depthWrite: false,
|
||
|
transparent: true
|
||
|
});
|
||
|
|
||
|
return new THREE.Points(flight_point_cloud_geom, shaderMaterial);
|
||
|
}
|
||
|
|
||
|
function update_flights() {
|
||
|
if (!flight_point_cloud_geom) {
|
||
|
return;
|
||
|
}
|
||
|
flight_point_cloud_geom.attributes.position.needsUpdate = true;
|
||
|
|
||
|
for (var i = start_flight_idx; i < end_flight_idx; ++i) {
|
||
|
|
||
|
if (Date.now() > flight_point_start_time[i]) {
|
||
|
var ease_val = easeOutQuadratic(Date.now() - flight_point_start_time[i], 0, 1, flight_point_end_time[i] - flight_point_start_time[i]);
|
||
|
|
||
|
if (ease_val < 0 || flight_point_speed_changed) {
|
||
|
ease_val = 0;
|
||
|
setFlightTimes(i);
|
||
|
}
|
||
|
|
||
|
var pos = flight_path_splines[i].getPoint(ease_val);
|
||
|
positions[3 * i + 0] = pos.x;
|
||
|
positions[3 * i + 1] = pos.y;
|
||
|
positions[3 * i + 2] = pos.z;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function setFlightTimes(index) {
|
||
|
var scaling_factor = (flight_point_speed_scaling - flight_point_speed_min_scaling) / (flight_point_speed_max_scaling - flight_point_speed_min_scaling);
|
||
|
var duration = (1 - scaling_factor) * flight_distance[index] * 80000;
|
||
|
|
||
|
var start_time = Date.now() + Math.random() * 5000;
|
||
|
flight_point_start_time[index] = start_time;
|
||
|
flight_point_end_time[index] = start_time + duration;
|
||
|
}
|
||
|
|
||
|
function easeOutQuadratic(t, b, c, d) {
|
||
|
if ((t /= d / 2) < 1) return c / 2 * t * t + b;
|
||
|
return -c / 2 * (--t * (t - 2) - 1) + b;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* get the center by the city name
|
||
|
* @author kyle / http://nikai.us/
|
||
|
*/
|
||
|
|
||
|
var citycenter = { municipalities: [{ n: "北京", g: "116.395645,39.929986|12" }, { n: "上海", g: "121.487899,31.249162|12" }, { n: "天津", g: "117.210813,39.14393|12" }, { n: "重庆", g: "106.530635,29.544606|12" }], provinces: [{ n: "安徽", g: "117.216005,31.859252|8", cities: [{ n: "合肥", g: "117.282699,31.866942|12" }, { n: "安庆", g: "117.058739,30.537898|13" }, { n: "蚌埠", g: "117.35708,32.929499|13" }, { n: "亳州", g: "115.787928,33.871211|13" }, { n: "巢湖", g: "117.88049,31.608733|13" }, { n: "池州", g: "117.494477,30.660019|14" }, { n: "滁州", g: "118.32457,32.317351|13" }, { n: "阜阳", g: "115.820932,32.901211|13" }, { n: "淮北", g: "116.791447,33.960023|13" }, { n: "淮南", g: "117.018639,32.642812|13" }, { n: "黄山", g: "118.29357,29.734435|13" }, { n: "六安", g: "116.505253,31.755558|13" }, { n: "马鞍山", g: "118.515882,31.688528|13" }, { n: "宿州", g: "116.988692,33.636772|13" }, { n: "铜陵", g: "117.819429,30.94093|14" }, { n: "芜湖", g: "118.384108,31.36602|12" }, { n: "宣城", g: "118.752096,30.951642|13" }] }, { n: "福建", g: "117.984943,26.050118|8", cities: [{ n: "福州", g: "119.330221,26.047125|12" }, { n: "龙岩", g: "117.017997,25.078685|13" }, { n: "南平", g: "118.181883,26.643626|13" }, { n: "宁德", g: "119.542082,26.656527|14" }, { n: "莆田", g: "119.077731,25.44845|13" }, { n: "泉州", g: "118.600362,24.901652|12" }, { n: "三明", g: "117.642194,26.270835|14" }, { n: "厦门", g: "118.103886,24.489231|12" }, { n: "漳州", g: "117.676205,24.517065|12" }] }, { n: "甘肃", g: "102.457625,38.103267|6", cities: [{ n: "兰州", g: "103.823305,36.064226|12" }, { n: "白银", g: "104.171241,36.546682|13" }, { n: "定西", g: "104.626638,35.586056|13" }, { n: "甘南州", g: "102.917442,34.992211|14" }, { n: "嘉峪关", g: "98.281635,39.802397|13" }, { n: "金昌", g: "102.208126,38.516072|13" }, { n: "酒泉", g: "98.508415,39.741474|13" }, { n: "临夏州", g: "103.215249,35.598514|13" }, { n: "陇南", g: "104.934573,33.39448|14" }, { n: "平凉", g: "106.688911,35.55011|13" }, { n: "庆阳", g: "107.644227,35.726801|13" }, { n: "天水", g: "105.736932,34.584319|13" }, { n: "武威", g: "102.640147,37.933172|13" }, { n: "张掖", g: "100.459892,38.93932|13" }] }, { n: "广东", g: "113.394818,23.408004|8", cities: [{ n: "广州", g: "113.30765,23.120049|12" }, { n: "潮州", g: "116.630076,23.661812|13" }, { n: "东莞", g: "113.763434,23.043024|12" }, { n: "佛山", g: "113.134026,23.035095|13" }, { n: "河源", g: "114.713721,23.757251|12" }, { n: "惠州", g: "114.410658,23.11354|12" }, { n: "江门", g: "113.078125,22.575117|13" }, { n: "揭阳", g: "116.379501,23.547999|13" }, { n: "茂名", g: "110.931245,21.668226|13" }, { n: "梅州", g: "116.126403,24.304571|13" }, { n: "清远", g: "113.040773,23.698469|13" }, { n: "汕头", g: "116.72865,23.383908|13" }, { n: "汕尾", g: "115.372924,22.778731|14" }, { n: "韶关", g: "113.594461,24.80296|13" }, { n: "深圳", g: "114.025974,22.546054|12" }, { n: "阳江", g: "111.97701,21.871517|14" }, { n: "云浮", g: "112.050946,22.937976|13" }, { n: "湛江", g: "110.365067,21.257463|13" }, { n: "肇庆", g: "112.479653,23.078663|13" }, { n: "中山", g: "113.42206,22.545178|12" }, { n: "珠海", g: "113.562447,22.256915|13" }] }, { n: "广西", g: "108.924274,23.552255|7", cities: [{ n: "南宁", g: "108.297234,22.806493|12" }, { n: "百色", g: "106.631821,23.901512|13" }, { n: "北海", g: "109.122628,21.472718|13" }, { n: "崇左", g: "107.357322,22.415455|14" }, { n: "防城港", g: "108.351791,21.617398|15" }, { n: "桂林", g: "110.26092,25.262901|12" }, { n: "贵港", g: "109.613708,23.103373|13" }, { n: "河池", g: "108.069948,24.699521|14" }, { n: "贺州", g: "111.552594,24.411054|14" }, { n: "来宾", g: "109.231817,23.741166|14" }, { n: "柳州", g: "109.422402,24.329053|12" }, { n: "钦州", g: "108.638798,21.97335|13" }, { n: "梧州", g: "111.305472,23.485395|13" }, { n: "玉林", g: "110.151676,22.643974|14" }] }, { n: "贵州", g: "106.734996,26.902826|8", cities: [{ n: "
|
||
|
|
||
|
function getCenter(g) {
|
||
|
var item = g.split("|");
|
||
|
item[0] = item[0].split(",");
|
||
|
return {
|
||
|
lng: parseFloat(item[0][0]),
|
||
|
lat: parseFloat(item[0][1])
|
||
|
};
|
||
|
}
|
||
|
|
||
|
var cityCenter = {
|
||
|
getProvinceNameByCityName: function getProvinceNameByCityName(name) {
|
||
|
var provinces = citycenter.provinces;
|
||
|
for (var i = 0; i < provinces.length; i++) {
|
||
|
var provinceName = provinces[i].n;
|
||
|
var cities = provinces[i].cities;
|
||
|
for (var j = 0; j < cities.length; j++) {
|
||
|
if (cities[j].n == name) {
|
||
|
return provinceName;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
},
|
||
|
getCenterByCityName: function getCenterByCityName(name) {
|
||
|
for (var i = 0; i < citycenter.municipalities.length; i++) {
|
||
|
if (citycenter.municipalities[i].n == name) {
|
||
|
return getCenter(citycenter.municipalities[i].g);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var provinces = citycenter.provinces;
|
||
|
for (var i = 0; i < provinces.length; i++) {
|
||
|
if (provinces[i].n == name) {
|
||
|
return getCenter(provinces[i].g);
|
||
|
}
|
||
|
var cities = provinces[i].cities;
|
||
|
for (var j = 0; j < cities.length; j++) {
|
||
|
if (cities[j].n == name) {
|
||
|
return getCenter(cities[j].g);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* 根据弧线的坐标节点数组
|
||
|
*/
|
||
|
function getCurvePoints(points) {
|
||
|
var curvePoints = [];
|
||
|
for (var i = 0; i < points.length - 1; i++) {
|
||
|
var p = getCurveByTwoPoints(points[i], points[i + 1]);
|
||
|
if (p && p.length > 0) {
|
||
|
curvePoints = curvePoints.concat(p);
|
||
|
}
|
||
|
}
|
||
|
return curvePoints;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据两点获取曲线坐标点数组
|
||
|
* @param Point 起点
|
||
|
* @param Point 终点
|
||
|
*/
|
||
|
function getCurveByTwoPoints(obj1, obj2) {
|
||
|
if (!obj1 || !obj2) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
var B1 = function B1(x) {
|
||
|
return 1 - 2 * x + x * x;
|
||
|
};
|
||
|
var B2 = function B2(x) {
|
||
|
return 2 * x - 2 * x * x;
|
||
|
};
|
||
|
var B3 = function B3(x) {
|
||
|
return x * x;
|
||
|
};
|
||
|
|
||
|
var curveCoordinates = [];
|
||
|
|
||
|
var count = 40; // 曲线是由一些小的线段组成的,这个表示这个曲线所有到的折线的个数
|
||
|
var isFuture = false;
|
||
|
var t, h, h2, lat3, lng3, j, t2;
|
||
|
var LnArray = [];
|
||
|
var i = 0;
|
||
|
var inc = 0;
|
||
|
|
||
|
if (typeof obj2 == "undefined") {
|
||
|
if (typeof curveCoordinates != "undefined") {
|
||
|
curveCoordinates = [];
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var lat1 = parseFloat(obj1.lat);
|
||
|
var lat2 = parseFloat(obj2.lat);
|
||
|
var lng1 = parseFloat(obj1.lng);
|
||
|
var lng2 = parseFloat(obj2.lng);
|
||
|
|
||
|
// 计算曲线角度的方法
|
||
|
if (lng2 > lng1) {
|
||
|
if (parseFloat(lng2 - lng1) > 180) {
|
||
|
if (lng1 < 0) {
|
||
|
lng1 = parseFloat(180 + 180 + lng1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (lng1 > lng2) {
|
||
|
if (parseFloat(lng1 - lng2) > 180) {
|
||
|
if (lng2 < 0) {
|
||
|
lng2 = parseFloat(180 + 180 + lng2);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
j = 0;
|
||
|
t2 = 0;
|
||
|
if (lat2 == lat1) {
|
||
|
t = 0;
|
||
|
h = lng1 - lng2;
|
||
|
} else if (lng2 == lng1) {
|
||
|
t = Math.PI / 2;
|
||
|
h = lat1 - lat2;
|
||
|
} else {
|
||
|
t = Math.atan((lat2 - lat1) / (lng2 - lng1));
|
||
|
h = (lat2 - lat1) / Math.sin(t);
|
||
|
}
|
||
|
if (t2 == 0) {
|
||
|
t2 = t + Math.PI / 5;
|
||
|
}
|
||
|
h2 = h / 2;
|
||
|
lng3 = h2 * Math.cos(t2) + lng1;
|
||
|
lat3 = h2 * Math.sin(t2) + lat1;
|
||
|
|
||
|
for (i = 0; i < count + 1; i++) {
|
||
|
curveCoordinates.push([lng1 * B1(inc) + lng3 * B2(inc) + lng2 * B3(inc), lat1 * B1(inc) + lat3 * B2(inc) + lat2 * B3(inc)]);
|
||
|
inc = inc + 1 / count;
|
||
|
}
|
||
|
return curveCoordinates;
|
||
|
}
|
||
|
|
||
|
var curve = {
|
||
|
getPoints: getCurvePoints
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
FDEB algorithm implementation [www.win.tue.nl/~dholten/papers/forcebundles_eurovis.pdf].
|
||
|
|
||
|
Author: (github.com/upphiminn)
|
||
|
2013
|
||
|
|
||
|
*/
|
||
|
|
||
|
var ForceEdgeBundling = function ForceEdgeBundling() {
|
||
|
var data_nodes = {},
|
||
|
// {'nodeid':{'x':,'y':},..}
|
||
|
data_edges = [],
|
||
|
// [{'source':'nodeid1', 'target':'nodeid2'},..]
|
||
|
compatibility_list_for_edge = [],
|
||
|
subdivision_points_for_edge = [],
|
||
|
K = 0.1,
|
||
|
// global bundling constant controling edge stiffness
|
||
|
S_initial = 0.1,
|
||
|
// init. distance to move points
|
||
|
P_initial = 1,
|
||
|
// init. subdivision number
|
||
|
P_rate = 2,
|
||
|
// subdivision rate increase
|
||
|
C = 6,
|
||
|
// number of cycles to perform
|
||
|
I_initial = 70,
|
||
|
// init. number of iterations for cycle
|
||
|
I_rate = 0.6666667,
|
||
|
// rate at which iteration number decreases i.e. 2/3
|
||
|
compatibility_threshold = 0.6,
|
||
|
invers_quadratic_mode = false,
|
||
|
eps = 1e-8;
|
||
|
|
||
|
/*** Geometry Helper Methods ***/
|
||
|
function vector_dot_product(p, q) {
|
||
|
return p.x * q.x + p.y * q.y;
|
||
|
}
|
||
|
|
||
|
function edge_as_vector(P) {
|
||
|
return { 'x': data_nodes[P.target].x - data_nodes[P.source].x,
|
||
|
'y': data_nodes[P.target].y - data_nodes[P.source].y };
|
||
|
}
|
||
|
|
||
|
function edge_length(e) {
|
||
|
return Math.sqrt(Math.pow(data_nodes[e.source].x - data_nodes[e.target].x, 2) + Math.pow(data_nodes[e.source].y - data_nodes[e.target].y, 2));
|
||
|
}
|
||
|
|
||
|
function custom_edge_length(e) {
|
||
|
return Math.sqrt(Math.pow(e.source.x - e.target.x, 2) + Math.pow(e.source.y - e.target.y, 2));
|
||
|
}
|
||
|
|
||
|
function edge_midpoint(e) {
|
||
|
var middle_x = (data_nodes[e.source].x + data_nodes[e.target].x) / 2.0;
|
||
|
var middle_y = (data_nodes[e.source].y + data_nodes[e.target].y) / 2.0;
|
||
|
return { 'x': middle_x, 'y': middle_y };
|
||
|
}
|
||
|
|
||
|
function compute_divided_edge_length(e_idx) {
|
||
|
var length = 0;
|
||
|
for (var i = 1; i < subdivision_points_for_edge[e_idx].length; i++) {
|
||
|
var segment_length = euclidean_distance(subdivision_points_for_edge[e_idx][i], subdivision_points_for_edge[e_idx][i - 1]);
|
||
|
length += segment_length;
|
||
|
}
|
||
|
return length;
|
||
|
}
|
||
|
|
||
|
function euclidean_distance(p, q) {
|
||
|
return Math.sqrt(Math.pow(p.x - q.x, 2) + Math.pow(p.y - q.y, 2));
|
||
|
}
|
||
|
|
||
|
function project_point_on_line(p, Q) {
|
||
|
var L = Math.sqrt((Q.target.x - Q.source.x) * (Q.target.x - Q.source.x) + (Q.target.y - Q.source.y) * (Q.target.y - Q.source.y));
|
||
|
var r = ((Q.source.y - p.y) * (Q.source.y - Q.target.y) - (Q.source.x - p.x) * (Q.target.x - Q.source.x)) / (L * L);
|
||
|
|
||
|
return { 'x': Q.source.x + r * (Q.target.x - Q.source.x), 'y': Q.source.y + r * (Q.target.y - Q.source.y) };
|
||
|
}
|
||
|
|
||
|
/*** ********************** ***/
|
||
|
|
||
|
/*** Initialization Methods ***/
|
||
|
function initialize_edge_subdivisions() {
|
||
|
for (var i = 0; i < data_edges.length; i++) {
|
||
|
if (P_initial == 1) subdivision_points_for_edge[i] = []; //0 subdivisions
|
||
|
else {
|
||
|
subdivision_points_for_edge[i] = [];
|
||
|
subdivision_points_for_edge[i].push(data_nodes[data_edges[i].source]);
|
||
|
subdivision_points_for_edge[i].push(data_nodes[data_edges[i].target]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function initialize_compatibility_lists() {
|
||
|
for (var i = 0; i < data_edges.length; i++) {
|
||
|
compatibility_list_for_edge[i] = [];
|
||
|
} //0 compatible edges.
|
||
|
}
|
||
|
|
||
|
function filter_self_loops(edgelist) {
|
||
|
var filtered_edge_list = [];
|
||
|
for (var e = 0; e < edgelist.length; e++) {
|
||
|
if (data_nodes[edgelist[e].source].x != data_nodes[edgelist[e].target].x && data_nodes[edgelist[e].source].y != data_nodes[edgelist[e].target].y) {
|
||
|
//or smaller than eps
|
||
|
filtered_edge_list.push(edgelist[e]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return filtered_edge_list;
|
||
|
}
|
||
|
/*** ********************** ***/
|
||
|
|
||
|
/*** Force Calculation Methods ***/
|
||
|
function apply_spring_force(e_idx, i, kP) {
|
||
|
|
||
|
var prev = subdivision_points_for_edge[e_idx][i - 1];
|
||
|
var next = subdivision_points_for_edge[e_idx][i + 1];
|
||
|
var crnt = subdivision_points_for_edge[e_idx][i];
|
||
|
|
||
|
var x = prev.x - crnt.x + next.x - crnt.x;
|
||
|
var y = prev.y - crnt.y + next.y - crnt.y;
|
||
|
|
||
|
x *= kP;
|
||
|
y *= kP;
|
||
|
|
||
|
return { 'x': x, 'y': y };
|
||
|
}
|
||
|
|
||
|
function apply_electrostatic_force(e_idx, i, S) {
|
||
|
var sum_of_forces = { 'x': 0, 'y': 0 };
|
||
|
var compatible_edges_list = compatibility_list_for_edge[e_idx];
|
||
|
|
||
|
for (var oe = 0; oe < compatible_edges_list.length; oe++) {
|
||
|
var force = { 'x': subdivision_points_for_edge[compatible_edges_list[oe]][i].x - subdivision_points_for_edge[e_idx][i].x,
|
||
|
'y': subdivision_points_for_edge[compatible_edges_list[oe]][i].y - subdivision_points_for_edge[e_idx][i].y };
|
||
|
|
||
|
if (Math.abs(force.x) > eps || Math.abs(force.y) > eps) {
|
||
|
|
||
|
var diff = 1 / Math.pow(custom_edge_length({ 'source': subdivision_points_for_edge[compatible_edges_list[oe]][i],
|
||
|
'target': subdivision_points_for_edge[e_idx][i] }), 1);
|
||
|
|
||
|
sum_of_forces.x += force.x * diff;
|
||
|
sum_of_forces.y += force.y * diff;
|
||
|
}
|
||
|
}
|
||
|
return sum_of_forces;
|
||
|
}
|
||
|
|
||
|
function apply_resulting_forces_on_subdivision_points(e_idx, P, S) {
|
||
|
var kP = K / (edge_length(data_edges[e_idx]) * (P + 1)); // kP=K/|P|(number of segments), where |P| is the initial length of edge P.
|
||
|
// (length * (num of sub division pts - 1))
|
||
|
var resulting_forces_for_subdivision_points = [{ 'x': 0, 'y': 0 }];
|
||
|
for (var i = 1; i < P + 1; i++) {
|
||
|
// exclude initial end points of the edge 0 and P+1
|
||
|
var resulting_force = { 'x': 0, 'y': 0 };
|
||
|
|
||
|
var spring_force = apply_spring_force(e_idx, i, kP);
|
||
|
var electrostatic_force = apply_electrostatic_force(e_idx, i, S);
|
||
|
|
||
|
resulting_force.x = S * (spring_force.x + electrostatic_force.x);
|
||
|
resulting_force.y = S * (spring_force.y + electrostatic_force.y);
|
||
|
|
||
|
resulting_forces_for_subdivision_points.push(resulting_force);
|
||
|
}
|
||
|
resulting_forces_for_subdivision_points.push({ 'x': 0, 'y': 0 });
|
||
|
return resulting_forces_for_subdivision_points;
|
||
|
}
|
||
|
/*** ********************** ***/
|
||
|
|
||
|
/*** Edge Division Calculation Methods ***/
|
||
|
function update_edge_divisions(P) {
|
||
|
for (var e_idx = 0; e_idx < data_edges.length; e_idx++) {
|
||
|
|
||
|
if (P == 1) {
|
||
|
subdivision_points_for_edge[e_idx].push(data_nodes[data_edges[e_idx].source]); // source
|
||
|
subdivision_points_for_edge[e_idx].push(edge_midpoint(data_edges[e_idx])); // mid point
|
||
|
subdivision_points_for_edge[e_idx].push(data_nodes[data_edges[e_idx].target]); // target
|
||
|
} else {
|
||
|
|
||
|
var divided_edge_length = compute_divided_edge_length(e_idx);
|
||
|
var segment_length = divided_edge_length / (P + 1);
|
||
|
var current_segment_length = segment_length;
|
||
|
var new_subdivision_points = [];
|
||
|
new_subdivision_points.push(data_nodes[data_edges[e_idx].source]); //source
|
||
|
|
||
|
for (var i = 1; i < subdivision_points_for_edge[e_idx].length; i++) {
|
||
|
var old_segment_length = euclidean_distance(subdivision_points_for_edge[e_idx][i], subdivision_points_for_edge[e_idx][i - 1]);
|
||
|
|
||
|
while (old_segment_length > current_segment_length) {
|
||
|
var percent_position = current_segment_length / old_segment_length;
|
||
|
var new_subdivision_point_x = subdivision_points_for_edge[e_idx][i - 1].x;
|
||
|
var new_subdivision_point_y = subdivision_points_for_edge[e_idx][i - 1].y;
|
||
|
|
||
|
new_subdivision_point_x += percent_position * (subdivision_points_for_edge[e_idx][i].x - subdivision_points_for_edge[e_idx][i - 1].x);
|
||
|
new_subdivision_point_y += percent_position * (subdivision_points_for_edge[e_idx][i].y - subdivision_points_for_edge[e_idx][i - 1].y);
|
||
|
new_subdivision_points.push({ 'x': new_subdivision_point_x,
|
||
|
'y': new_subdivision_point_y });
|
||
|
|
||
|
old_segment_length -= current_segment_length;
|
||
|
current_segment_length = segment_length;
|
||
|
}
|
||
|
current_segment_length -= old_segment_length;
|
||
|
}
|
||
|
new_subdivision_points.push(data_nodes[data_edges[e_idx].target]); //target
|
||
|
subdivision_points_for_edge[e_idx] = new_subdivision_points;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
/*** ********************** ***/
|
||
|
|
||
|
/*** Edge compatibility measures ***/
|
||
|
function angle_compatibility(P, Q) {
|
||
|
var result = Math.abs(vector_dot_product(edge_as_vector(P), edge_as_vector(Q)) / (edge_length(P) * edge_length(Q)));
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
function scale_compatibility(P, Q) {
|
||
|
var lavg = (edge_length(P) + edge_length(Q)) / 2.0;
|
||
|
var result = 2.0 / (lavg / Math.min(edge_length(P), edge_length(Q)) + Math.max(edge_length(P), edge_length(Q)) / lavg);
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
function position_compatibility(P, Q) {
|
||
|
var lavg = (edge_length(P) + edge_length(Q)) / 2.0;
|
||
|
var midP = { 'x': (data_nodes[P.source].x + data_nodes[P.target].x) / 2.0,
|
||
|
'y': (data_nodes[P.source].y + data_nodes[P.target].y) / 2.0 };
|
||
|
var midQ = { 'x': (data_nodes[Q.source].x + data_nodes[Q.target].x) / 2.0,
|
||
|
'y': (data_nodes[Q.source].y + data_nodes[Q.target].y) / 2.0 };
|
||
|
var result = lavg / (lavg + euclidean_distance(midP, midQ));
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
function edge_visibility(P, Q) {
|
||
|
var I0 = project_point_on_line(data_nodes[Q.source], { 'source': data_nodes[P.source],
|
||
|
'target': data_nodes[P.target] });
|
||
|
var I1 = project_point_on_line(data_nodes[Q.target], { 'source': data_nodes[P.source],
|
||
|
'target': data_nodes[P.target] }); //send acutal edge points positions
|
||
|
var midI = { 'x': (I0.x + I1.x) / 2.0,
|
||
|
'y': (I0.y + I1.y) / 2.0 };
|
||
|
var midP = { 'x': (data_nodes[P.source].x + data_nodes[P.target].x) / 2.0,
|
||
|
'y': (data_nodes[P.source].y + data_nodes[P.target].y) / 2.0 };
|
||
|
var result = Math.max(0, 1 - 2 * euclidean_distance(midP, midI) / euclidean_distance(I0, I1));
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
function visibility_compatibility(P, Q) {
|
||
|
return Math.min(edge_visibility(P, Q), edge_visibility(Q, P));
|
||
|
}
|
||
|
|
||
|
function compatibility_score(P, Q) {
|
||
|
var result = angle_compatibility(P, Q) * scale_compatibility(P, Q) * position_compatibility(P, Q) * visibility_compatibility(P, Q);
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
function are_compatible(P, Q) {
|
||
|
// console.log('compatibility ' + P.source +' - '+ P.target + ' and ' + Q.source +' '+ Q.target);
|
||
|
return compatibility_score(P, Q) >= compatibility_threshold;
|
||
|
}
|
||
|
|
||
|
function compute_compatibility_lists() {
|
||
|
for (var e = 0; e < data_edges.length - 1; e++) {
|
||
|
for (var oe = e + 1; oe < data_edges.length; oe++) {
|
||
|
// don't want any duplicates
|
||
|
if (e == oe) continue;else {
|
||
|
if (are_compatible(data_edges[e], data_edges[oe])) {
|
||
|
compatibility_list_for_edge[e].push(oe);
|
||
|
compatibility_list_for_edge[oe].push(e);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*** ************************ ***/
|
||
|
|
||
|
/*** Main Bundling Loop Methods ***/
|
||
|
var forcebundle = function forcebundle() {
|
||
|
var S = S_initial;
|
||
|
var I = I_initial;
|
||
|
var P = P_initial;
|
||
|
|
||
|
initialize_edge_subdivisions();
|
||
|
initialize_compatibility_lists();
|
||
|
update_edge_divisions(P);
|
||
|
compute_compatibility_lists();
|
||
|
for (var cycle = 0; cycle < C; cycle++) {
|
||
|
for (var iteration = 0; iteration < I; iteration++) {
|
||
|
var forces = [];
|
||
|
for (var edge = 0; edge < data_edges.length; edge++) {
|
||
|
forces[edge] = apply_resulting_forces_on_subdivision_points(edge, P, S);
|
||
|
}
|
||
|
for (var e = 0; e < data_edges.length; e++) {
|
||
|
for (var i = 0; i < P + 1; i++) {
|
||
|
subdivision_points_for_edge[e][i].x += forces[e][i].x;
|
||
|
subdivision_points_for_edge[e][i].y += forces[e][i].y;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//prepare for next cycle
|
||
|
S = S / 2;
|
||
|
P = P * 2;
|
||
|
I = I_rate * I;
|
||
|
|
||
|
update_edge_divisions(P);
|
||
|
// console.log('C' + cycle);
|
||
|
// console.log('P' + P);
|
||
|
// console.log('S' + S);
|
||
|
}
|
||
|
return subdivision_points_for_edge;
|
||
|
};
|
||
|
/*** ************************ ***/
|
||
|
|
||
|
/*** Getters/Setters Methods ***/
|
||
|
forcebundle.nodes = function (nl) {
|
||
|
if (arguments.length == 0) {
|
||
|
return data_nodes;
|
||
|
} else {
|
||
|
data_nodes = nl;
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
forcebundle.edges = function (ll) {
|
||
|
if (arguments.length == 0) {
|
||
|
return data_edges;
|
||
|
} else {
|
||
|
data_edges = filter_self_loops(ll); //remove edges to from to the same point
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
forcebundle.bundling_stiffness = function (k) {
|
||
|
if (arguments.length == 0) {
|
||
|
return K;
|
||
|
} else {
|
||
|
K = k;
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
forcebundle.step_size = function (step) {
|
||
|
if (arguments.length == 0) {
|
||
|
return S_initial;
|
||
|
} else {
|
||
|
S_initial = step;
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
forcebundle.cycles = function (c) {
|
||
|
if (arguments.length == 0) {
|
||
|
return C;
|
||
|
} else {
|
||
|
C = c;
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
forcebundle.iterations = function (i) {
|
||
|
if (arguments.length == 0) {
|
||
|
return I_initial;
|
||
|
} else {
|
||
|
I_initial = i;
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
forcebundle.iterations_rate = function (i) {
|
||
|
if (arguments.length == 0) {
|
||
|
return I_rate;
|
||
|
} else {
|
||
|
I_rate = i;
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
forcebundle.subdivision_points_seed = function (p) {
|
||
|
if (arguments.length == 0) {
|
||
|
return P;
|
||
|
} else {
|
||
|
P = p;
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
forcebundle.subdivision_rate = function (r) {
|
||
|
if (arguments.length == 0) {
|
||
|
return P_rate;
|
||
|
} else {
|
||
|
P_rate = r;
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
forcebundle.compatbility_threshold = function (t) {
|
||
|
if (arguments.length == 0) {
|
||
|
return compatbility_threshold;
|
||
|
} else {
|
||
|
compatibility_threshold = t;
|
||
|
}
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
/*** ************************ ***/
|
||
|
|
||
|
return forcebundle;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @author kyle / http://nikai.us/
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* Category
|
||
|
* @param {Object} splitList:
|
||
|
* {
|
||
|
* other: 1,
|
||
|
* 1: 2,
|
||
|
* 2: 3,
|
||
|
* 3: 4,
|
||
|
* 4: 5,
|
||
|
* 5: 6,
|
||
|
* 6: 7
|
||
|
* }
|
||
|
*/
|
||
|
function Category(splitList) {
|
||
|
this.splitList = splitList || {
|
||
|
other: 1
|
||
|
};
|
||
|
}
|
||
|
|
||
|
Category.prototype.get = function (count) {
|
||
|
|
||
|
var splitList = this.splitList;
|
||
|
|
||
|
var value = splitList['other'];
|
||
|
|
||
|
for (var i in splitList) {
|
||
|
if (count == i) {
|
||
|
value = splitList[i];
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return value;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* 根据DataSet自动生成对应的splitList
|
||
|
*/
|
||
|
Category.prototype.generateByDataSet = function (dataSet) {
|
||
|
var colors = ['rgba(255, 255, 0, 0.8)', 'rgba(253, 98, 104, 0.8)', 'rgba(255, 146, 149, 0.8)', 'rgba(255, 241, 193, 0.8)', 'rgba(110, 176, 253, 0.8)', 'rgba(52, 139, 251, 0.8)', 'rgba(17, 102, 252, 0.8)'];
|
||
|
var data = dataSet.get();
|
||
|
this.splitList = {};
|
||
|
var count = 0;
|
||
|
for (var i = 0; i < data.length; i++) {
|
||
|
if (this.splitList[data[i].count] === undefined) {
|
||
|
this.splitList[data[i].count] = colors[count];
|
||
|
count++;
|
||
|
}
|
||
|
if (count >= colors.length - 1) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.splitList['other'] = colors[colors.length - 1];
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @author kyle / http://nikai.us/
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* Choropleth
|
||
|
* @param {Object} splitList:
|
||
|
* [
|
||
|
* {
|
||
|
* start: 0,
|
||
|
* end: 2,
|
||
|
* value: randomColor()
|
||
|
* },{
|
||
|
* start: 2,
|
||
|
* end: 4,
|
||
|
* value: randomColor()
|
||
|
* },{
|
||
|
* start: 4,
|
||
|
* value: randomColor()
|
||
|
* }
|
||
|
* ];
|
||
|
*
|
||
|
*/
|
||
|
function Choropleth(splitList) {
|
||
|
this.splitList = splitList || [{
|
||
|
start: 0,
|
||
|
value: 'red'
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
Choropleth.prototype.get = function (count) {
|
||
|
var splitList = this.splitList;
|
||
|
|
||
|
var value = false;
|
||
|
|
||
|
for (var i = 0; i < splitList.length; i++) {
|
||
|
if ((splitList[i].start === undefined || splitList[i].start !== undefined && count >= splitList[i].start) && (splitList[i].end === undefined || splitList[i].end !== undefined && count < splitList[i].end)) {
|
||
|
value = splitList[i].value;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return value;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* 根据DataSet自动生成对应的splitList
|
||
|
*/
|
||
|
Choropleth.prototype.generateByDataSet = function (dataSet) {
|
||
|
|
||
|
var min = dataSet.getMin('count');
|
||
|
var max = dataSet.getMax('count');
|
||
|
|
||
|
this.generateByMinMax(min, max);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* 根据DataSet自动生成对应的splitList
|
||
|
*/
|
||
|
Choropleth.prototype.generateByMinMax = function (min, max) {
|
||
|
var colors = ['rgba(255, 255, 0, 0.8)', 'rgba(253, 98, 104, 0.8)', 'rgba(255, 146, 149, 0.8)', 'rgba(255, 241, 193, 0.8)', 'rgba(110, 176, 253, 0.8)', 'rgba(52, 139, 251, 0.8)', 'rgba(17, 102, 252, 0.8)'];
|
||
|
var splitNum = (max - min) / 7;
|
||
|
var index = min;
|
||
|
this.splitList = [];
|
||
|
var count = 0;
|
||
|
while (index < max) {
|
||
|
this.splitList.push({
|
||
|
start: index,
|
||
|
end: index + splitNum,
|
||
|
value: colors[count]
|
||
|
});
|
||
|
count++;
|
||
|
index += splitNum;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
exports.Three = THREE$1;
|
||
|
exports.x = X;
|
||
|
exports.X = X;
|
||
|
exports.Flate = Flate;
|
||
|
exports.Earth = Earth;
|
||
|
exports.utilCityCenter = cityCenter;
|
||
|
exports.utilCurve = curve;
|
||
|
exports.utilForceEdgeBundling = ForceEdgeBundling;
|
||
|
exports.utilDataRangeIntensity = Intensity;
|
||
|
exports.utilDataRangeCategory = Category;
|
||
|
exports.utilDataRangeChoropleth = Choropleth;
|
||
|
|
||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||
|
|
||
|
})));
|