# spatiasql

> JS (emscripten) port of SpatiaLite

Latest version **3.0.2-beta** (published 2018-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install spatiasql
pnpm add spatiasql
yarn add spatiasql
bun add spatiasql
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2-beta |
| Published | 2018-08-14 |
| First published | 2017-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 56 |
| Author | jvail |
| Maintainers | jvail |
| Keywords | spatialite, sqlite, spatial DBMS, geodata |

## Links

- npm: https://www.npmjs.com/package/spatiasql
- Repository: https://github.com/jvail/spatiasql.js
- Homepage: https://github.com/jvail/spatiasql.js#readme
- Issues: https://github.com/jvail/spatiasql.js/issues
- npm.io page: https://npm.io/package/spatiasql

## Recent versions

- 3.0.2-beta (latest) — 2018-08-14
- 3.0.1-beta — 2018-08-13
- 2.0.1 — 2017-12-26

## README

# spatiasql.js

JavaScript (emscripten) port of [SpatiaLite 5.0.0-beta](https://www.gaia-gis.it/fossil/libspatialite/index) (including SQLite 3.24.0, proj 5.1.0, geos 3.6.2)

[![Build Status](https://travis-ci.org/jvail/spatiasql.js.svg?branch=master)](https://travis-ci.org/jvail/spatiasql.js)

## Demo
A demo (WebAssembly required) is available from here: http://jvail.github.io/spatiasql.js/

(be patient, loading the js and database file takes some time).

## Usage
spatiasql.js (SpatiaLite) is an extension of [sql.js](https://github.com/kripken/sql.js/) (SQLite) and implements the same (for node), but async API for the browser, exept:

 - loading shapefiles in node:
```js
const fs = require('fs');
const spatiasql = require('spatiasql-node');

spatiasql.then(Database => {

  const db = new Database();

  db.loadshp('my_table', 'CP1251', 4326, {
    shp: fs.readFileSync('my_file.shp'),
    shx: fs.readFileSync('my_file.shx'),
    dbf: fs.readFileSync('my_file.dbf')
  });

  let res = db.exec('SELECT * FROM my_table');
  console.log(res);

});
```

 - loading shapefiles in the browser:
```js
import { Database } from 'spatiasql';

const db = new Database();

const files = await Promise.all([
  fetch('my_file.shp').then(res => res.arrayBuffer()),
  fetch('my_file.shx').then(res => res.arrayBuffer()),
  fetch('my_file.dbf').then(res => res.arrayBuffer())
]);

const loaded = await db.loadshp('my_table', 'CP1251', 4326, {
    shp: files[0],
    shx: files[1],
    dbf: files[2]
  });

if (loaded) {
  db.exec('SELECT * FROM my_table')
    .then(res => console.log(res));
}

```

---
_Source: https://npm.io/package/spatiasql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
