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

@vicentecalfo/aqui-tem-mata-api-wrapper

v1.0.0

Published

Este pacote visa buscar informações de desmatamento da Mata Atlântica através dos recursos da API do projeto "Aqui Tem Mata?"

Downloads

2

Readme

@vicentecalfo/aqui-tem-mata-api-wrapper

Este pacote visa facilitar a busca de informações de desmatamento da Mata Atlântica através dos recursos da API do projeto "Aqui Tem Mata?".

O projeto Aqui tem Mata? é um aplicativo para busca de informações sobre a existência de áreas remanescentes de Mata Atlântica no país. Para saber mais, clique aqui.

Instalação

npm install @vicentecalfo/aqui-tem-mata-api-wrapper --save

Utilização

import { AquiTemMataApi } from '@vicentecalfo/aqui-tem-mata-api-wrapper';

const aquiTemMataApi = new AquiTemMataApi();
// Busca município
aquiTemMataApi
    .municipio('duque de caxias')
    .subscribe(
        (data) => console.log(data.body),
        (error) => console.log(error)
    );

// Busca por área de mata
aquiTemMataApi
	.areaDeMata(
        { municipio: 'Duque de Caxias', uf: 'RJ' }
    )
	.subscribe(
        (data) => console.log(data.body),
        (error) => console.log(error)
    );

Resultado das consultas acima

Observe que o resultado de fato está na propriedade rows. Esta estrutura será a mesma para todos os endpoints.

// Resultado para consulta de município
{
	"rows": [{
		"municipio": "Duque de Caxias",
		"uf": "RJ"
	}],
	"time": 0.016,
	"fields": {
		"municipio": {
			"type": "string",
			"pgtype": "text"
		},
		"uf": {
			"type": "string",
			"pgtype": "text"
		}
	},
	"total_rows": 1
}
// Resultado para consulta de área de mata
{
	"rows": [{
		"area_verde_total_km2": 162.07575612574,
		"area_verde_total_ha": 16207.575612574,
		"municipio_na_lei_ma_porcentagem": 1.00000000016057
	}],
	"time": 0.005,
	"fields": {
		"area_verde_total_km2": {
			"type": "number",
			"pgtype": "float8"
		},
		"area_verde_total_ha": {
			"type": "number",
			"pgtype": "float8"
		},
		"municipio_na_lei_ma_porcentagem": {
			"type": "number",
			"pgtype": "float8"
		}
	},
	"total_rows": 1
}

Métodos Disponíveis

Todos os métodos podem receber um parâmetro adicional para as requisições HTTP (reqOptions). Para verificar todas as opções clique aqui.

Os métodos retornam uma observable, no entanto você pode usar promises também. Clique aqui para ver o exemplo.

Método | Parâmetro | Descrição ---|---|--- municipio(nomeDoMunicipio, reqOptions) | Nome do município | Busca um município do Brasil. areaDeMata(municipio, reqOptions) | { municipio, uf }| Busca valores da área total de Mata Atlântica em Km2 e ha. UCs(municipio, reqOptions) | { municipio, uf }| Busca presença em unidades de conservação (UCs). baciaHidro(municipio, reqOptions) | { municipio, uf }| Busca Localização em bacias hidrográficas. formacoesNaturais(municipio, reqOptions) | { municipio, uf }| Busca Valores de área (ha) por formação natural. taxaDesmatamentoAnual(anoInicio, anoFinal, reqOptions) | anoInicio (número) e anoFinal(número) | Busca a taxa de desmatamento por séries anuais. Séries disponíveis até o momento: 2000~2005, 2005~2008, 2008~2010, 2010~2011, 2011~2012, 2012~2013, 2013~2014, 2014~2015, 2015~2016, 2016~2017, 2017~2018, 2018~2019. convertTexto(texto, json) | Texto (texto com problema de codficação que precisa ser corrigido) e Json (boleano, determina se a saída será em texto ou um objeto JSON) | Corrige problemas de codificação no texto.

Exemplos

Observable

import { AquiTemMataApi } from '@vicentecalfo/aqui-tem-mata-api-wrapper';

const aquiTemMataApi = new AquiTemMataApi();

aquiTemMataApi
	.taxaDesmatamentoAnual(
        2018, 
        2019, 
        { json:true } // Faz o parse automático para JSON
    )
	.subscribe(
        (data) => console.log(data.body),
        (error) => console.log(error)
    );

Promise

import { AquiTemMataApi } from '@vicentecalfo/aqui-tem-mata-api-wrapper';

const aquiTemMataApi = new AquiTemMataApi();

aquiTemMataApi
	.UCs(municipio, {json: true})
	.toPromise()
	.then((data) => console.log(data.body))
	.catch((error) => console.log(error));

Codificação de Texto

Até o momento somente o endpoint (método) bacia hidro, apresentou problemas de codificação (encode). Para resolver o problema você pode usar o método convertTexto. Para maiores informações ver métodos disponíveis.

Considerações gerais