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

geojson-projector

v0.0.11

Published

Fast projector for immutable GeoJSON

Downloads

34

Readme

geojson-projector

Fast projector for immutable GeoJSON. It can project any branch of GeoJSON object.

geojson-projector can produce the cacheing of projected values which is a good point while one is using immutable data flow.

Instalation

npm install --save geojson-projector

Usage

import GeojsonProjector from 'geojson-projector';
let project = GeojsonProjector('EPSG:4326', 'EPSG:3857');

// use cases
let coordinates = project([-122.416667, 37.783333]);
let geometry = project({
    "type": "Point",
    "coordinates": [-122.416667, 37.783333]
});
let feature = project({
    "type": "Feature",
    "geometry": {
        "type": "LineString",
        "coordinates": [
            [-122.416667, 37.783333],
            [4.900000, 52.366667]
        ]
    }

});
let geojson = project({
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [-122.416667, 37.783333]
            }
        },
        {
            "type": "Feature",
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [-122.416667, 37.783333],
                    [4.900000, 52.366667]
                ]
            }

        }
    ]
})

Immutable input GeoJSON mode

In case of immutable input GeoJSON mode projector produce cacheing of output results based upon input source instance. Immutable input GeoJSON mode is used by default.

import {isEqual, clone} from 'lodash';
import {GeojsonProjector} from 'geojson-projector';

let project = GeojsonProjector({
    from: 'EPSG:4326',
    to: 'EPSG:3857',
    immutable: true
});
let geometry = project({
    "type": "Point",
    "coordinates": [-122.416667, 37.783333]
});
let projection1 = project(geometry);
let projection2 = project(geometry);
let projectionOfClone = project(clone(geometry));

console.log(projection1 === projection2); // true
console.log(projection1 !== projectionOfClone); // true
console.log(isEqual(projection1, projectionOfClone)); // true

Mutable input GeoJSON mode

In case of mutable input GeoJSON mode projector produce a new calculation per each project call.

import {isEqual, clone} from 'lodash';
import {GeojsonProjector} from 'gojson-projector';

let project = GeojsonProjector({
    from: 'EPSG:4326',
    to: 'EPSG:3857',
    immutable: false
});
let geometry = project({
    "type": "Point",
    "coordinates": [-122.416667, 37.783333]
});
let projection1 = project(geometry);
let projection2 = project(geometry);

console.log(projection1 !== projection2); // true
console.log(isEqual(projection1, projectionOfClone)); // true