@qgis-js/utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@qgis-js/utils

Utilities to integrate qgis-js into web applications

qgis-js Repository | qgis-js Website | "@qgis-js/utils" package source

@qgis-js/utils on npm

⚠️🧪 Work in progress! Currently this project is in public beta

Installation

npm install -S @qgis-js/utils

Usage

useProjects

Provides an abstraction to load QGIS projects from various sources.

import { qgis } from "qgis-js";
import { useProjects } from "@qgis-js/utils";

const { api, fs } = await qgis();
const {
  openProject,
  loadLocalProject,
  loadGithubProjects,
  loadRemoteProjects,
} = useProjects(fs, (projectPath: string) => {
  api.loadProject(projectPath);
});

The following project sources are supported:

LocalProject

Loads QGIS projects from the user's file system with the File System API

await openProject(await loadLocalProject());

GithubProject

Loads QGIS projects from a GitHub repository with the GitHub API

RemoteProject

Fetches QGIS projects from a remote server with the Fetch API

  • If loadRemoteProjects is invoked with a string as, it is assumed to be the URL of a JSON file with the following structure:
{
  "name": "projects",
  "path": "projects",
  "type": "Folder",
  "entries": [
    {
      "name": "village",
      "path": "projects/village",
      "type": "Folder",
      "entries": [
        {
          "name": "project.qgs",
          "path": "projects/village/project.qgs",
          "type": "File"
        },
        {
          "name": "rgb.tif",
          "path": "projects/village/rgb.tif",
          "type": "File"
        }
      ]
    }
  ]
}
  • Otherwise a Folder object can also be passed directly to loadRemoteProjects, see FileSystem.ts

Versioning

This package uses SemVer for versioning. For the versions available, see the tags on this repository.

License

GNU General Public License v2.0

Readme

Keywords

none

Package Sidebar

Install

npm i @qgis-js/utils

Weekly Downloads

5

Version

0.0.5

License

GPL-2.0-or-later

Unpacked Size

39.7 kB

Total Files

5

Last publish

Collaborators

  • martin-dobias
  • boardend
  • qgis-js-admin