MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / drawGray

Function drawGray

libs/mapv/mapv.js:1101–1163  ·  view source on GitHub ↗
(context, dataSet, options)

Source from the content-addressed store, hash-verified

1099}
1100
1101function drawGray(context, dataSet, options) {
1102
1103 var max = getMax(options);
1104 var min = getMin(options);
1105 // console.log(max)
1106 var size = options._size;
1107 if (size == undefined) {
1108 size = options.size;
1109 if (size == undefined) {
1110 size = 13;
1111 }
1112 }
1113
1114 var intensity = new Intensity({
1115 gradient: options.gradient,
1116 max: max,
1117 min: min
1118 });
1119
1120 var circle = createCircle(size);
1121 var circleHalfWidth = circle.width / 2;
1122 var circleHalfHeight = circle.height / 2;
1123
1124 var data = dataSet;
1125
1126 var dataOrderByAlpha = {};
1127
1128 data.forEach(function (item, index) {
1129 var count = item.count === undefined ? 1 : item.count;
1130 var alpha = Math.min(1, count / max).toFixed(2);
1131 dataOrderByAlpha[alpha] = dataOrderByAlpha[alpha] || [];
1132 dataOrderByAlpha[alpha].push(item);
1133 });
1134
1135 for (var i in dataOrderByAlpha) {
1136 if (isNaN(i)) continue;
1137 var _data = dataOrderByAlpha[i];
1138 context.beginPath();
1139 if (!options.withoutAlpha) {
1140 context.globalAlpha = i;
1141 }
1142 context.strokeStyle = intensity.getColor(i * max);
1143 _data.forEach(function (item, index) {
1144 if (!item.geometry) {
1145 return;
1146 }
1147
1148 var coordinates = item.geometry._coordinates || item.geometry.coordinates;
1149 var type = item.geometry.type;
1150 if (type === 'Point') {
1151 var count = item.count === undefined ? 1 : item.count;
1152 context.globalAlpha = count / max;
1153 context.drawImage(circle, coordinates[0] - circleHalfWidth, coordinates[1] - circleHalfHeight);
1154 } else if (type === 'LineString') {
1155 var count = item.count === undefined ? 1 : item.count;
1156 context.globalAlpha = count / max;
1157 context.beginPath();
1158 pathSimple.draw(context, item, options);

Callers 1

draw$1Function · 0.85

Calls 8

getMaxFunction · 0.85
getMinFunction · 0.85
createCircleFunction · 0.85
forEachMethod · 0.80
minMethod · 0.80
pushMethod · 0.80
getColorMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected