0.0.3 • Published 7 days ago

@qgis-js/utils v0.0.3

Weekly downloads
-
License
GPL-2.0-or-later
Repository
github
Last release
7 days ago

@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

0.0.3

7 days ago

0.0.2

3 months ago

0.0.1

5 months ago