Skip to content

Latest commit

 

History

History
93 lines (67 loc) · 2.44 KB

README.md

File metadata and controls

93 lines (67 loc) · 2.44 KB

@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