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

carto-geocoding-sql

v0.0.6

Published

Turns simple text locations into SQL queries to be run against CARTO geocoding API

Downloads

5

Readme

carto-geocoding-sql

Turns simple text locations into SQL queries ready to be run against CARTO geocoding API.

It'll *magically*™ decide which SQL function it should call depending on the content you provide.

show me some code

var geocodeSQL = require('carto-geocoding-sql');

geocodeSQL('Stockholm');
// SELECT cdb_geocode_namedplace_point('Stockholm') the_geom;
// assumes a city by default

geocodeSQL('South Africa');
// SELECT ST_Centroid(cdb_geocode_admin0_polygon('South Africa')) the_geom;
// ... unless it's a country, in which case it will use its centroid

geocodeSQL('200.199.198.197');
SELECT cdb_geocode_ipaddress_point('200.199.198.197') the_geom;
// IP adresses !

geocodeSQL('Paris, USA');
// SELECT cdb_geocode_namedplace_point('Paris','USA') the_geom;
// two fragments separated by a comma: assume city, country

geocodeSQL('75013, France');
// SELECT cdb_geocode_postalcode_point('75013','France') the_geom;
// numbers in first fragment: assume postal code

geocodeSQL('201 Moore St, Brooklyn, USA');
geocodeSQL('201 Moore St, Brooklyn, NY, USA');
// SELECT cdb_geocode_street_point('201 Moore St','Brooklyn','','USA') the_geom;
// street level address with 3+ fragments, with or without state

multiple geocodings

Send multiple strings if you need several geocodings at once:

geocodeSQL('Utrecht', '81.204.10.10', 'Roelof Hartplein 2G, Amsterdam, Nederland');
//SELECT cdb_geocode_namedplace_point('Utrecht') the_geom UNION SELECT cdb_geocode_ipaddress_point('81.204.10.10') the_geom UNION SELECT cdb_geocode_street_point('Roelof Hartplein 2G','Amsterdam','','Nederland') the_geom;

CLI

Carto-geocoding-sql can be run on the command line with carto-geocode-sql:

➜ carto-geocode-sql 'Germany'
SELECT ST_Centroid(cdb_geocode_admin0_polygon('Germany')) the_geom;
➜ carto-geocode-sql 'Beijing'
SELECT cdb_geocode_namedplace_point('Beijing') the_geom;

Protip: use with the CARTO node client CLI

➜ cartodb -f geojson "`carto-geocode-sql '201 Moore St, Brooklyn, USA'`"
{"type": "FeatureCollection", "features": [{"type":"Feature","geometry":{"type":"Point","coordinates":[-73.93661,40.70442]},"properties":{}}]}

yeah

Runs on Node > 4.0 Should run on the browser, but it has not been tested and should be packaged with your method of choice.