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

@kartotherian/postgis-vt-util

v0.3.1

Published

PostGIS helper functions for making vector tiles

Downloads

75

Readme

postgis-vt-util

postgres helper functions for making vector tiles in Mapbox Studio

z

Given the !scale_denominator! mapnik token, returns a zoom level. Lets you to control at which zoom levels features appear.

Arguments: !scale_denominator! [mapnik token]

Example:

( SELECT
    some, attributes,
    geom_generalized
  FROM your_table
  where z(!scale_denominator!) in (10,11,12)
  union ALL
  SELECT
    some, attributes,
    geom_not_generalized
  FROM your_table
  where z(!scale_denominator!) >= 13
) as data

labelgrid

De-duplicates features based on a given grid size, letting you control feature density. All features are snapped to a grid, but only 1 feature per grid cell is returend when selecting DISTINCT ON the labelgrid function.

Arguments: geometry [geometry], grid size [an integer that divides evenly into 256], !pixel_width! [mapnik token]

Example:

( SELECT
    disctinct on(labelgrid(geom, 128, !pixel_width!))
    some, other, attributes
  FROM your_table
) AS data

linelabel

Select only those line geometries long enough to be labeled; drops all line geometries too short for mapnik to place a label. Linelabel compares line length to the length of a user-supplied label field.

Arguments: zoom [integer], label [text field], geometry [geometry]

Example:

( SELECT
    name, geom
  FROM your_table
  WHERE linelabel(z(!scale_denominator!), name, geom)
) AS data

merc_buffer

Wrapper for ST_Buffer that adjusts distance by latitude to approximate real-world measurements. Assumes input geometries are Web Mercator and input distances are real-world meters. Accuracy decreases for larger buffer distances and at extreme latitudes.

Arguments: geometry [geometry], distance in meters [numeric]

merc_dwithin

Wrapper for ST_DWithin that adjusts distance by latitude to approximate real-world measurements. Assumes input geometries are Web Mercator and input distances are real-world meters. Accuracy decreases for larger distances and at extreme latitudes.

Arguments: geometry a [geometry], geometry b [geometry], distance in meters [numeric]

merc_length

Wrapper for ST_Length that adjusts distance by latitude to approximate real-world measurements. Assumes input geometries are Web Mercator. Accuracy decreases for larger y-axis ranges of the input.

Arguments: geometry [geometry]

tile_bbox

Given a Web Mercator tile ID as (z, x, y), returns a bounding-box geometry of the area covered by that tile.

Arguments: zoom_level [integer], x_tile [integer], y_tile [integer]