All Projects → ngageoint → Geopackage Js

ngageoint / Geopackage Js

Licence: mit
GeoPackage JavaScript Library

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Geopackage Js

Sql Kit
*️⃣ Build SQL queries in Swift. Extensible, protocol-based design that supports DQL, DML, and DDL.
Stars: ✭ 115 (-39.79%)
Mutual labels:  sql, sqlite
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (+1005.76%)
Mutual labels:  sql, sqlite
Sqlite3 To Mysql
Make an Sqlite3 export MySQL readable.
Stars: ✭ 116 (-39.27%)
Mutual labels:  sql, sqlite
Minisqlquery
Minimalist SQL Query tool for any .NET DB Provider - SQL, SQLite, SQL CE, Oracle, Access...
Stars: ✭ 103 (-46.07%)
Mutual labels:  sql, sqlite
Oreilly getting started with sql
Database files for the O'Reilly book "Getting Started with SQL: A hands on approach for beginners" http://goo.gl/z3zG54
Stars: ✭ 156 (-18.32%)
Mutual labels:  sql, sqlite
Legacy Search
Demo project showing how to add elasticsearch to a legacy application.
Stars: ✭ 103 (-46.07%)
Mutual labels:  sql, demo
Kangaroo
SQL client and admin tool for popular databases
Stars: ✭ 127 (-33.51%)
Mutual labels:  sql, sqlite
Selectstarsql
An interactive SQL book
Stars: ✭ 92 (-51.83%)
Mutual labels:  sql, sqlite
Atdatabases
TypeScript clients for databases that prevent SQL Injection
Stars: ✭ 154 (-19.37%)
Mutual labels:  sql, sqlite
Efcore.bulkextensions
Entity Framework Core Bulk Batch Extensions for Insert Update Delete Read (CRUD), Truncate and SaveChanges operations on SQL Server, PostgreSQL, SQLite
Stars: ✭ 2,295 (+1101.57%)
Mutual labels:  sql, sqlite
Contacts
A flutter project with Implementation of a Contacts app in 4 ways (API, Custom, Preferences and Sqflite).
Stars: ✭ 100 (-47.64%)
Mutual labels:  sql, sqlite
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+1057.59%)
Mutual labels:  sql, sqlite
Leaflet.browser.print
A leaflet plugin which allows users to print the map directly from the browser
Stars: ✭ 94 (-50.79%)
Mutual labels:  leaflet-plugins, leaflet
Sqhell.vim
An SQL wrapper for vim
Stars: ✭ 113 (-40.84%)
Mutual labels:  sql, sqlite
Qtl
A friendly and lightweight C++ database library for MySQL, PostgreSQL, SQLite and ODBC.
Stars: ✭ 92 (-51.83%)
Mutual labels:  sql, sqlite
Rbql
🦜RBQL - Rainbow Query Language: SQL-like language for (not only) CSV file processing. Supports SQL queries with Python and JavaScript expressions
Stars: ✭ 118 (-38.22%)
Mutual labels:  sql, sqlite
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+563.35%)
Mutual labels:  sql, sqlite
Leaflet Gps
Simple leaflet control plugin for tracking gps position
Stars: ✭ 90 (-52.88%)
Mutual labels:  leaflet-plugins, leaflet
Oreilly intermediate sql for data
Resources for the O'Reilly Online Training "Intermediate SQL For Data Analysis"
Stars: ✭ 136 (-28.8%)
Mutual labels:  sql, sqlite
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (-11.52%)
Mutual labels:  sql, sqlite

GeoPackage JS

GeoPackage JS is an implementation of the OGC GeoPackage spec. This library works in both the browser and Node 4+.

Demo

GeoPackage JS Demo Page

Cloning this repository and opening the docs/index.html in your browser will run the demo locally.

Installation

Build Status NPM Coverage Status

$ npm install @ngageoint/geopackage

GeoPackage JS Library

The GeoPackage Libraries were developed at the National Geospatial-Intelligence Agency (NGA) in collaboration with BIT Systems. The government has "unlimited rights" and is releasing this software to increase the impact of government investments by providing developers with the opportunity to take things in new directions. The software use, modification, and distribution rights are stipulated within the MIT license.

Pull Requests

If you'd like to contribute to this project, please make a pull request. We'll review the pull request and discuss the changes. All pull request contributions to this project will be released under the MIT license.

Software source code previously released under an open source license and then modified by NGA staff is considered a "joint work" (see 17 USC § 101); it is partially copyrighted, partially public domain, and as a whole is protected by the copyrights of the non-government authors and must be released according to the terms of the original open source license.

About

GeoPackage JS is a GeoPackage Library JavaScript implementation of the Open Geospatial Consortium GeoPackage spec. It is listed as an OGC GeoPackage Implementation by the National Geospatial-Intelligence Agency.

The GeoPackage JavaScript library currently provides the ability to read GeoPackage files. This library works both in the browser and in Node. In the browser tiles are rendered using HTML5 Canvas and GeoPackages are read using sql.js. In Node tiles are rendered PureImage and GeoPackages are read using node-sqlite3.

Changelog

2.1.0
  • Implementation of the Feature Style Extension and Contents ID Extension
2.0.8
  • Checks for Electron when returning a tile creator
2.0
  • All new API utilizing Promises
1.1.4
  • Adds a method to retrieve tiles in EPSG:4326
1.1.3
  • Fixes issue #115
1.1.2
  • fix case where GeoPackage Zoom does not correspond to the web map zoom
1.1.1
  • fix more instances of proj4 bug for react
  • fixed tile generation for images with different x and y pixel densities
1.1.0
  • accept pull request adding support for react
  • fix bug with projected tiles that spanned the date line
1.0.25
  • ensure we use proj4 2.4.3 instead of 2.4.4
1.0.22
  • Fixed bug where querying for indexed features only returned the geometry instead of the entire feature
1.0.19
  • Remove dependency on Lwip

Usage

View examples using Bower and Browserify

View the latest docs.

Browser Usage

// attach this method to a file input onchange event
window.loadGeoPackage = function(files) {
  var f = files[0];
  var r = new FileReader();
  r.onload = function() {
    var array = new Uint8Array(r.result);
    loadByteArray(array);
  }
  r.readAsArrayBuffer(f);
}

function loadByteArray(array, callback) {
  var db = new SQL.Database(array);
  GeoPackageConnection.connectWithDatabase(db, function(err, connection) {
    var geoPackage = new GeoPackage('', '', connection);

    // Now you can operate on the GeoPackage

    // get the tile table names
    geoPackage.getTileTables(function(err, tileTableNames) {
      // tileTableNames is an array of all tile table names

      // get the info for the first table
      geoPackage.getTileDaoWithTableName(tileTableNames[0], function(err, tileDao) {
        geoPackage.getInfoForTable(tileDao, function(err, info) {
          // do something with the tile table info
        });

        // draw a tile into a canvas for an XYZ tile
        var canvas = canvasFromSomewhere;
        var gpr = new GeoPackageTileRetriever(tileDao, 256, 256);
        var x = 0;
        var y = 0;
        var zoom = 0;

        console.time('Draw tile ' + x + ', ' + y + ' zoom: ' + zoom);
        gpr.drawTileIn(x, y, zoom, canvas, function() {
          console.timeEnd('Draw tile ' + x + ', ' + y + ' zoom: ' + zoom);
        });

        // or get a tile base64 data URL for an XYZ tile
        gpr.getTile(x, y, zoom, function(err, tileBase64DataURL) {
          console.log('got the base64 data url');
        });

        // or get a tile from a GeoPackage tile column and tile row
        tileDao.queryForTile(tileColumn, tileRow, zoom, function(err, tile) {
          var tileData = tile.getTileData();  // the raw bytes from the GeoPackage
        });

      });
    });

    // get the feature table names
    geoPackage.getFeatureTables(function(err, featureTableNames) {
      // featureTableNames is an array of all feature table names

      // get the info for the first table
      geoPackage.getFeatureDaoWithTableName(featureTableNames[0], function(err, featureDao) {
        geoPackage.getInfoForTable(featureDao, function(err, info) {
          // do something with the feature table info
        });

        // query for all features
        featureDao.queryForEach(function(err, row, rowDone) {
          var feature = featureDao.getFeatureRow(row);
          var geometry = currentRow.getGeometry();
          if (geometry) {
            var geom = geometry.geometry;
            var geoJson = geometry.geometry.toGeoJSON();

            geoJson.properties = {};
            for (var key in feature.values) {
              if(feature.values.hasOwnProperty(key) && key != feature.getGeometryColumn().name) {
                var column = info.columnMap[key];
                geoJson.properties[column.displayName] = currentRow.values[key];
              }
            }
          }
          rowDone();
        });
      });
    });
  });
}

NodeJS Usage

var GeoPackageAPI = require('@ngageoint/geopackage')
  , GeoPackageManager = GeoPackageAPI.GeoPackageManager
  , GeoPackageConnection = GeoPackageAPI.GeoPackageConnection
  , GeoPackageTileRetriever = GeoPackageAPI.GeoPackageTileRetriever;

GeoPackageAPI.open(filename, function(err, geoPackage) {

  // Now you can operate on the GeoPackage

  // get the tile table names
  geoPackage.getTileTables(function(err, tileTableNames) {
    // tileTableNames is an array of all tile table names

    // get the info for the first table
    geoPackage.getTileDaoWithTableName(tileTableNames[0], function(err, tileDao) {
      geoPackage.getInfoForTable(tileDao, function(err, info) {
        // do something with the tile table info
      });

      // draw a tile into a canvas for an XYZ tile
      var canvas = canvasFromSomewhere;
      var gpr = new GeoPackageTileRetriever(tileDao, 256, 256);
      var x = 0;
      var y = 0;
      var zoom = 0;

      console.time('Draw tile ' + x + ', ' + y + ' zoom: ' + zoom);
      gpr.drawTileIn(x, y, zoom, canvas, function() {
        console.timeEnd('Draw tile ' + x + ', ' + y + ' zoom: ' + zoom);
      });

      // or get a tile base64 data URL for an XYZ tile
      gpr.getTile(x, y, zoom, function(err, tileBase64DataURL) {
        console.log('got the base64 data url');
      });

      // or get a tile from a GeoPackage tile column and tile row
      tileDao.queryForTile(tileColumn, tileRow, zoom, function(err, tile) {
        var tileData = tile.getTileData();  // the raw bytes from the GeoPackage
      });

    });
  });

  // get the feature table names
  geoPackage.getFeatureTables(function(err, featureTableNames) {
    // featureTableNames is an array of all feature table names

    // get the info for the first table
    geoPackage.getFeatureDaoWithTableName(featureTableNames[0], function(err, featureDao) {
      geoPackage.getInfoForTable(featureDao, function(err, info) {
        // do something with the feature table info
      });

      // query for all features
      featureDao.queryForEach(function(err, row, rowDone) {
        var feature = featureDao.getFeatureRow(row);
        var geometry = currentRow.getGeometry();
        if (geometry) {
          var geom = geometry.geometry;
          var geoJson = geometry.geometry.toGeoJSON();

          geoJson.properties = {};
          for (var key in feature.values) {
            if(feature.values.hasOwnProperty(key) && key != feature.getGeometryColumn().name) {
              var column = info.columnMap[key];
              geoJson.properties[column.displayName] = currentRow.values[key];
            }
          }
        }
        rowDone();
      });
    });
  });
});

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].