npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

map-image-preview

v1.6.5

Published

Render static raster preview images of maps

Downloads

5

Readme

Features

Reads vector format map polygons and renders into to a bitmap file

  • Automatically detect minimal bounding box
    • Adjustable margin as a percentage
  • Selectable colors
  • Selectable outline stroke

Usage

map-image-preview v1.6.4

Usage: node map-image-preview <options> [mapfile]

mapfile    GeoJSON map source file for the preview

Options:
   -W  --width [0..]         Set the output image width in pixels
   -S  --strokeWidth [0.0..] Set the outline line width in pixels
   -SC --strokeColor #222    Set the outline color (hex code)
   -C  --color #f84          Set the fill color (hex code)
   -B  --bboxscale [0.0..]   Set the bounding box scaling factor, 1.1 = 10% margin
   -M  --meta [file.json]    Optional file containing map layer colors
   -CP --colorProperty [key] GeoJSON property to use for color lookup.  Metadata must have keys with same name.
   -O  --output [file]       Filename of output files, file extension will be added.
   -X  --maxbounds {left:1,bottom:2,right:3,top:4}  The maximum bounds for limiting image extents.

Example

node map-image-preview.js --width 600 --strokeColor "rgba(0,0,255,0.7)" \
  --fillColor "#ff6" --strokeWidth 0.5 example/world.geojson

Sample

Arguments

Color property

node map-image-preview.js --width 600 --colorProperty admin \
  --meta example/world.json example/world.geojson

Scale 0.8

Scale factor

The default scale factor of 1 will fit the map data precisely inside the target raster.

Scale factor 80%

npx map-image-preview --bboxscale 0.8 --width 300 example/world.geojson

Scale 0.8

Scale factor 120%

npx map-image-preview --bboxscale 1.2 --width 300 example/world.geojson

Scale 1.2

Metafile

Optionally a metadata json file can be used to specify colors to be used in the map. To use this the GeoJSON currently must have a property named "kode", matching with the "kode" value set in the accompanying meta.json file.

npx map-image-preview --meta meta.json example/world.geojson

Format

{
  "barn": [
    { "kode": "water", "farge": "#00f" },
    { "kode": "land", "farge": "#0f0" }
  ]
}

Composing background map

The app wms-save-image may be used to download background maps from any WMS server for use in combination with images from this program. It will read the generated JSON file.

Compose single image

Using convert program from Imagemagick to composite the images. To install Imagemagick:

sudo apt install imagemagick

To compose images:

convert thumbnail_back.png thumbnail.32633.png -compose Multiply -composite thumbnail.png

Composed example

Compose images recursively

find . -type d -exec sh -c "cd \"{}\" && pwd && \
  [ -f thumbnail.json ] && \
  convert thumbnail_back.png thumbnail.32633.png -compose Multiply -composite thumbnail.png" \;