|
5397 | 5397 | while (++i < n) d3_geo_streamLine(coordinates[i], listener); |
5398 | 5398 | listener.polygonEnd(); |
5399 | 5399 | } |
5400 | | - function d3_geo_streamBuffer(buffer, pointRadius) { |
5401 | | - var stream = { |
5402 | | - point: point, |
5403 | | - lineStart: function() { |
5404 | | - stream.point = pointLineStart; |
5405 | | - }, |
5406 | | - lineEnd: lineEnd, |
5407 | | - polygonStart: function() { |
5408 | | - stream.lineEnd = lineEndPolygon; |
5409 | | - }, |
5410 | | - polygonEnd: function() { |
5411 | | - stream.lineEnd = lineEnd; |
5412 | | - } |
5413 | | - }; |
5414 | | - function point(x, y) { |
5415 | | - buffer.push("M", x, ",", y, pointRadius); |
5416 | | - } |
5417 | | - function pointLineStart(x, y) { |
5418 | | - buffer.push("M", x, ",", y); |
5419 | | - stream.point = pointLine; |
5420 | | - } |
5421 | | - function pointLine(x, y) { |
5422 | | - buffer.push("L", x, ",", y); |
5423 | | - } |
5424 | | - function lineEnd() { |
5425 | | - stream.point = point; |
5426 | | - } |
5427 | | - function lineEndPolygon() { |
5428 | | - buffer.push("Z"); |
5429 | | - } |
5430 | | - pointRadius = d3_geo_pathCircle(4.5); |
5431 | | - return stream; |
5432 | | - } |
5433 | | - function d3_geo_streamContext(context, pointRadius) { |
5434 | | - var stream = { |
5435 | | - point: point, |
5436 | | - lineStart: function() { |
5437 | | - stream.point = pointLineStart; |
5438 | | - }, |
5439 | | - lineEnd: lineEnd, |
5440 | | - polygonStart: function() { |
5441 | | - stream.lineEnd = lineEndPolygon; |
5442 | | - }, |
5443 | | - polygonEnd: function() { |
5444 | | - stream.lineEnd = lineEnd; |
5445 | | - } |
5446 | | - }; |
5447 | | - function point(x, y) { |
5448 | | - context.moveTo(x, y); |
5449 | | - context.arc(x, y, pointRadius, 0, 2 * π); |
5450 | | - } |
5451 | | - function pointLineStart(x, y) { |
5452 | | - context.moveTo(x, y); |
5453 | | - stream.point = pointLine; |
5454 | | - } |
5455 | | - function pointLine(x, y) { |
5456 | | - context.lineTo(x, y); |
5457 | | - } |
5458 | | - function lineEnd() { |
5459 | | - stream.point = point; |
5460 | | - } |
5461 | | - function lineEndPolygon() { |
5462 | | - context.closePath(); |
5463 | | - } |
5464 | | - return stream; |
5465 | | - } |
5466 | 5400 | function d3_geo_streamRadians(stream) { |
5467 | 5401 | return d3_geo_streamTransform(stream, function(x, y) { |
5468 | 5402 | stream.point(x * d3_radians, y * d3_radians); |
|
6327 | 6261 | var pointRadius = 4.5, pointCircle = d3_geo_pathCircle(pointRadius), projection = d3.geo.albersUsa(), context, buffer = []; |
6328 | 6262 | function path(object) { |
6329 | 6263 | var radius = typeof pointRadius === "function" ? pointRadius.apply(this, arguments) : pointRadius; |
6330 | | - d3.geo.stream(object, projection.stream(context != null ? new d3_geo_streamContext(context, radius) : new d3_geo_streamBuffer(buffer, radius))); |
6331 | | - var result = buffer.join(""); |
6332 | | - buffer = []; |
6333 | | - return result; |
| 6264 | + d3.geo.stream(object, projection.stream(context == null ? new d3_geo_pathBuffer(buffer, radius) : new d3_geo_pathContext(context, radius))); |
| 6265 | + if (buffer.length) { |
| 6266 | + var result = buffer.join(""); |
| 6267 | + buffer = []; |
| 6268 | + return result; |
| 6269 | + } |
6334 | 6270 | } |
6335 | 6271 | path.area = function(object) { |
6336 | 6272 | d3_geo_areaSum = 0; |
|
6365 | 6301 | function d3_geo_pathCircle(radius) { |
6366 | 6302 | return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + +2 * radius + "z"; |
6367 | 6303 | } |
| 6304 | + function d3_geo_pathBuffer(buffer, pointRadius) { |
| 6305 | + var stream = { |
| 6306 | + point: point, |
| 6307 | + lineStart: function() { |
| 6308 | + stream.point = pointLineStart; |
| 6309 | + }, |
| 6310 | + lineEnd: lineEnd, |
| 6311 | + polygonStart: function() { |
| 6312 | + stream.lineEnd = lineEndPolygon; |
| 6313 | + }, |
| 6314 | + polygonEnd: function() { |
| 6315 | + stream.lineEnd = lineEnd; |
| 6316 | + stream.point = point; |
| 6317 | + } |
| 6318 | + }; |
| 6319 | + function point(x, y) { |
| 6320 | + buffer.push("M", x, ",", y, pointRadius); |
| 6321 | + } |
| 6322 | + function pointLineStart(x, y) { |
| 6323 | + buffer.push("M", x, ",", y); |
| 6324 | + stream.point = pointLine; |
| 6325 | + } |
| 6326 | + function pointLine(x, y) { |
| 6327 | + buffer.push("L", x, ",", y); |
| 6328 | + } |
| 6329 | + function lineEnd() { |
| 6330 | + stream.point = point; |
| 6331 | + } |
| 6332 | + function lineEndPolygon() { |
| 6333 | + buffer.push("Z"); |
| 6334 | + } |
| 6335 | + pointRadius = d3_geo_pathCircle(4.5); |
| 6336 | + return stream; |
| 6337 | + } |
| 6338 | + function d3_geo_pathContext(context, pointRadius) { |
| 6339 | + var stream = { |
| 6340 | + point: point, |
| 6341 | + lineStart: function() { |
| 6342 | + stream.point = pointLineStart; |
| 6343 | + }, |
| 6344 | + lineEnd: lineEnd, |
| 6345 | + polygonStart: function() { |
| 6346 | + stream.lineEnd = lineEndPolygon; |
| 6347 | + }, |
| 6348 | + polygonEnd: function() { |
| 6349 | + stream.lineEnd = lineEnd; |
| 6350 | + stream.point = point; |
| 6351 | + } |
| 6352 | + }; |
| 6353 | + function point(x, y) { |
| 6354 | + context.moveTo(x, y); |
| 6355 | + context.arc(x, y, pointRadius, 0, 2 * π); |
| 6356 | + } |
| 6357 | + function pointLineStart(x, y) { |
| 6358 | + context.moveTo(x, y); |
| 6359 | + stream.point = pointLine; |
| 6360 | + } |
| 6361 | + function pointLine(x, y) { |
| 6362 | + context.lineTo(x, y); |
| 6363 | + } |
| 6364 | + function lineEnd() { |
| 6365 | + stream.point = point; |
| 6366 | + } |
| 6367 | + function lineEndPolygon() { |
| 6368 | + context.closePath(); |
| 6369 | + } |
| 6370 | + return stream; |
| 6371 | + } |
6368 | 6372 | var d3_geo_pathAreaScale, d3_geo_pathArea = { |
6369 | 6373 | point: d3_noop, |
6370 | 6374 | lineStart: d3_noop, |
|
0 commit comments