Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
neocarto committed Dec 5, 2024
1 parent ebc6961 commit 367e89e
Show file tree
Hide file tree
Showing 81 changed files with 321 additions and 153 deletions.
6 changes: 4 additions & 2 deletions docs/container_create.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/container_draw.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/container_render.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/data/search.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/effect_blur.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/effect_clippath.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/effect_radialgradient.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/effect_shadow.js.html

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions docs/global.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_arbitrary.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_count.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_diamond.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_dot.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_h3.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_hexbin.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_intersect.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_make.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_square.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/grid_triangle.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/helpers_tooltip.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_box.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_choro-horizontal.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_choro-vertical.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_circles-half.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_circles-nested.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_circles.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_mushrooms.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_spikes.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_squares-nested.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_squares.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_symbol-horizontal.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_symbol-vertical.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_typo-horizontal.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/legend_typo-vertical.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_circle.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_footer.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_graticule.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_halfcircle.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_header.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_north.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_outline.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_path.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_scalebar.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_spike.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_square.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_symbol.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_text.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/mark_tile.js.html

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions docs/mark_tissot.js.html

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions docs/plot_plot.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/plot_plot_choro.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/plot_plot_prop.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/plot_plot_propchoro.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/plot_plot_proptypo.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/plot_plot_symbol.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/plot_plot_typo.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_addfonts.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_centroid.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_choro.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_dissolve.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_dodge.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_dotstogrid.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_featurecollection.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_geotable.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_height.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_merge.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_proj4d3.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_project.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_radius.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_random.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_replicate.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_rewind.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_ridge.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_symbols.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_typo.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/tool_unproject.js.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/container/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { clipPath as addclippath } from "../effect/clippath.js";
import { blur as addblur } from "../effect/blur.js";
import { shadow as addshadow } from "../effect/shadow.js";
import { radialGradient as addradialGradient } from "../effect/radialgradient.js";
import { tissot as addtissot } from "../mark/tissot.js";

import { make as addgrid } from "../grid/make.js";

Expand Down Expand Up @@ -210,6 +211,7 @@ export function create({
{ id: "scalebar", func: addscalebar },
{ id: "north", func: addnorth },
{ id: "plot", func: addplot },
{ id: "tissot", func: addtissot },
].forEach(
(d) =>
(mark[d.id] = function () {
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export { render } from "./container/render";
export { tile } from "./mark/tile.js";
export { halfcircle } from "./mark/halfcircle.js";
export { symbol } from "./mark/symbol.js";
export { tissot } from "./mark/tissot.js";

// Plot
export { plot } from "./plot/plot.js";
Expand Down
74 changes: 74 additions & 0 deletions src/mark/tissot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { create } from "../container/create";
import { render } from "../container/render";
import { geoCircle, geoPath, geoNaturalEarth1 } from "d3-geo";
const d3 = Object.assign({}, { geoPath, geoCircle, geoNaturalEarth1 });

/**
* @function tissot
* @description The `tissot` function aims to draw Tissot circles to visualize the deformations due to the projection
* @see {@link https://observablehq.com/@neocartocnrs/https://observablehq.com/@neocartocnrs/map-projections}
*
* @property {number} [step = 20] - step between circles
* @property {string} [id] - id of the layer
* @property {string} [fill = "red"] - fill color.
* @property {string} [stroke = "white"] - stroke color.
* @property {number} [strokeOpacity = 0.5] - stroke color.
* @property {*} [*] - *other SVG attributes that can be applied (strokeDasharray, strokeWidth, opacity, strokeLinecap...)*
* @property {*} [svg_*] - *parameters of the svg container created if the layer is not called inside a container (e.g svg_width)*
* @example
* // There are several ways to use this function
* geoviz.tissot(svg, { step: 25 }) // where svg is the container
* svg.tissot({ step: 25 }) // where svg is the container
* svg.plot({ type: "tissot", step: 25 }) // where svg is the container
* geoviz.tissot({ step: 25 }) // no container
*/

export function tissot(arg1, arg2) {
let newcontainer =
(arguments.length <= 1 || arguments[1] == undefined) &&
!arguments[0]?._groups
? true
: false;
let options = newcontainer ? arg1 : arg2;
// Default values
let opts = {
step: 20,
fill: "red",
fillOpacity: 0.5,
stroke: "white",
};
opts = { ...opts, ...options };
opts.datum = regularcircles(opts.step);
let ids = `#${opts.id}`;
let svg = newcontainer ? create({ projection: d3.geoNaturalEarth1() }) : arg1;
svg.path(opts);
if (newcontainer) {
return render(svg);
} else {
return ids;
}
}

// Create circles
function regularcircles(step) {
const circle = d3
.geoCircle()
.center((d) => d)
.radius(step / 4)
.precision(10);
const features = [];
for (let y = -80; y <= 80; y += step) {
for (let x = -180; x < 180; x += step) {
features.push({
type: "Feature",
properties: {},
geometry: {
type: "MultiPolygon",
coordinates: [circle([x, y]).coordinates],
},
});
}
}

return { type: "FeatureCollection", features: features };
}
4 changes: 4 additions & 0 deletions src/plot/plot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Marks
import { graticule } from "../mark/graticule";
import { tissot } from "../mark/tissot";
import { outline } from "../mark/outline";
import { path } from "../mark/path";
import { text } from "../mark/text";
Expand Down Expand Up @@ -95,6 +96,9 @@ export function plot(arg1, arg2) {
: arg2;

switch (options.type) {
case "tissot":
return tissot(arg1, arg2);
break;
case "graticule":
return graticule(arg1, arg2);
break;
Expand Down

0 comments on commit 367e89e

Please sign in to comment.