mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 01:33:03 +00:00
16 lines
534 B
JavaScript
16 lines
534 B
JavaScript
export function Path(projection, graph, polygon) {
|
|
var cache = {},
|
|
clip = d3.geo.clipExtent().extent(projection.clipExtent()).stream,
|
|
project = projection.stream,
|
|
path = d3.geo.path()
|
|
.projection({stream: function(output) { return polygon ? project(output) : project(clip(output)); }});
|
|
|
|
return function(entity) {
|
|
if (entity.id in cache) {
|
|
return cache[entity.id];
|
|
} else {
|
|
return cache[entity.id] = path(entity.asGeoJSON(graph));
|
|
}
|
|
};
|
|
}
|