diff --git a/packages/preview/mercator/0.1.2/LICENSE b/packages/preview/mercator/0.1.2/LICENSE new file mode 100644 index 0000000000..ea4e02644d --- /dev/null +++ b/packages/preview/mercator/0.1.2/LICENSE @@ -0,0 +1,26 @@ +Copyright 2025 bernsteining + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + diff --git a/packages/preview/mercator/0.1.2/README.md b/packages/preview/mercator/0.1.2/README.md new file mode 100644 index 0000000000..3fea6fc684 --- /dev/null +++ b/packages/preview/mercator/0.1.2/README.md @@ -0,0 +1,91 @@ +# mercator + +![logo](https://raw.githubusercontent.com/bernsteining/mercator/refs/heads/main/examples/data/logo.png) + +Mercator is a Typst plugin to render GeoJSON and TopoJSON as SVG maps. + +## usage + +```typst +#import "@preview/mercator:0.1.2": * + +#let world = read("examples/data/world.json", encoding: "utf8") + +#render-map(world, json.encode(( + projection: ( + type: "orthographic", + center_lat: 45, + center_lon: 10, + ), + graticule: (step: 15), +)), width: 100%) +``` + +## documentation + +Check the [documentation](https://github.com/bernsteining/mercator/raw/refs/heads/main/examples/documentation.pdf), it covers all the features with examples. + +## config options + +| Option | Type | Default | Description | +|--------|------|---------|-------------| +| `stroke` | string | `"black"` | Stroke color. Supports `{property_name}` interpolation. | +| `stroke_width` | float | `0.05` | Stroke width | +| `fill` | string | `"white"` | Fill color. Supports `{property_name}` interpolation. | +| `fill_opacity` | float | `1.0` | Fill opacity | +| `fill_pattern` | string | none | `"hatched"`, `"crosshatched"`, or `"dotted"`. Supports `{property_name}`. | +| `point_radius` | float | `stroke_width * 5` | Radius for Point/MultiPoint geometries | +| `point_color` | string | same as `fill` | Point fill color. `"none"` hides points. Supports `{property_name}`. | +| `viewbox` | array | auto | Manual viewbox as `(x, y, width, height)` | +| `viewbox_padding` | float | `0.15` | Padding fraction around auto-computed viewbox | +| `label` | string or array | none | Label template: `"{name}"` or array of `{text, font_size, color, font_family}` objects | +| `label_color` | string | `"black"` | Default label color | +| `label_font_size` | float | `0.3` | Default label font size | +| `label_font_family` | string | `"Arial"` | Default label font family | +| `projection` | object | equirectangular | Projection config (see below) | +| `graticule` | object | none | Graticule overlay config (see below) | +| `tissot` | object | none | Tissot's indicatrix overlay config (see below) | + +### projections + +| Type | Category | Parameters | +|------|----------|------------| +| `equirectangular` | Cylindrical | `central_meridian` | +| `mercator` | Cylindrical | `central_meridian` | +| `cassini` | Cylindrical | `central_meridian` | +| `lambert_conformal_conic` | Conic | `standard_parallel_1`, `standard_parallel_2`, `central_meridian`, `latitude_of_origin` | +| `albers_equal_area` | Conic | `standard_parallel_1`, `standard_parallel_2`, `central_meridian`, `latitude_of_origin` | +| `bonne` | Pseudo-conic | `standard_parallel`, `central_meridian` | +| `polyconic` | Pseudo-conic | `central_meridian` | +| `robinson` | Pseudo-cylindrical | `central_meridian` | +| `natural_earth` | Pseudo-cylindrical | `central_meridian` | +| `hammer` | Pseudo-cylindrical | `central_meridian` | +| `winkel_tripel` | Pseudo-cylindrical | `central_meridian` | +| `orthographic` | Azimuthal | `center_lat`, `center_lon` | +| `gnomonic` | Azimuthal | `center_lat`, `center_lon` | +| `lambert_azimuthal_equal_area` | Azimuthal | `center_lat`, `center_lon` | +| `azimuthal_equidistant` | Azimuthal | `center_lat`, `center_lon` | +| `wiechel` | Pseudo-azimuthal | `center_lat`, `center_lon` | +| `peirce_quincuncial` | Other | `center_lon` | +| `authagraph` | Other | _(no parameters)_ | + +### graticule + +| Option | Type | Default | Description | +|--------|------|---------|-------------| +| `step` | float | `15.0` | Degrees between grid lines | +| `color` | string | `"#ccc"` | Line color | +| `width` | float | `0.5` | Line width | +| `opacity` | float | `0.6` | Line opacity | + +### tissot + +| Option | Type | Default | Description | +|--------|------|---------|-------------| +| `step` | float | `30.0` | Degrees between indicator circles | +| `radius` | float | `5.0` | Circle radius in degrees | +| `fill` | string | `"red"` | Fill color | +| `fill_opacity` | float | `0.3` | Fill opacity | +| `stroke` | string | `"red"` | Stroke color | +| `stroke_width` | float | `0.5` | Stroke width | +| `max_lat` | float | `60.0` | Maximum latitude for indicators | diff --git a/packages/preview/mercator/0.1.2/mercator.typ b/packages/preview/mercator/0.1.2/mercator.typ new file mode 100644 index 0000000000..983fae0038 --- /dev/null +++ b/packages/preview/mercator/0.1.2/mercator.typ @@ -0,0 +1,24 @@ +/// Mercator: Rendering GeoJSon in typst. +/// Author: Bernstein +/// Tip: make geo-json codeblocks render an image: `#show raw.where(lang: "geojson"): it => render-image(it.text)` + +#let mercator = plugin("./mercator.wasm") + +/// Renders a GeoJSON and returns SVG code for it. +/// +/// - code (string, bytes): GeoJSON to be rendered. +/// -> string +#let render(code, config) = { + return str(mercator.geo(bytes(code), bytes(config))) +} + +/// Renders a GeoJSON and returns an image for it. Uses the same parameters as image. +/// +/// - code (string, bytes): GeoJSON to be rendered. +/// - config (string): JSON-encoded configuration string. Optional, defaults to `"{}"`. +/// - all remaining arguments: see image +/// -> content +#let render-map(code, ..args) = { + let config = args.pos().at(0, default: "{}") + image(bytes(render(code, config)), format: "svg", ..args.named()) +} diff --git a/packages/preview/mercator/0.1.2/mercator.wasm b/packages/preview/mercator/0.1.2/mercator.wasm new file mode 100644 index 0000000000..4a4cd652ca Binary files /dev/null and b/packages/preview/mercator/0.1.2/mercator.wasm differ diff --git a/packages/preview/mercator/0.1.2/typst.toml b/packages/preview/mercator/0.1.2/typst.toml new file mode 100644 index 0000000000..97a04d8d59 --- /dev/null +++ b/packages/preview/mercator/0.1.2/typst.toml @@ -0,0 +1,11 @@ +[package] +name = "mercator" +version = "0.1.2" +entrypoint = "mercator.typ" +authors = ["Bernstein "] +license = "MIT" +description = "🌎 Render GeoJSON and TopoJSON in typst." +repository = "https://github.com/bernsteining/mercator/" +keywords = ["geojson", "map", "cartography", "vector tiles", "GIS", "SVG"] +categories = ["visualization"] +compiler = "0.14.2"