GDAL3.js 开源项目教程

GDAL3.js 开源项目教程

gdal3.jsConvert raster and vector geospatial data to various formats and coordinate systems entirely in the browser.项目地址:https://gitcode.com/gh_mirrors/gd/gdal3.js

1. 项目的目录结构及介绍

GDAL3.js 项目的目录结构如下:

gdal3.js/
├── apps/
│   ├── app-gui/
│   ├── example-module-browser/
│   ├── example-node/
│   └── example-browser/
├── dist/
│   └── package/
├── src/
│   ├── gdal/
│   ├── proj/
│   ├── geos/
│   ├── spatialite/
│   ├── sqlite/
│   ├── geotiff/
│   ├── tiff/
│   ├── webp/
│   ├── expat/
│   ├── zlib/
│   └── iconv/
├── static/
├── tests/
├── .gitignore
├── package.json
├── README.md
└── webpack.config.js

目录结构介绍

  • apps/: 包含多个示例应用程序,如 app-guiexample-module-browserexample-nodeexample-browser
  • dist/: 包含编译后的包文件。
  • src/: 包含 GDAL 及其依赖库的源代码。
  • static/: 静态资源文件。
  • tests/: 测试文件。
  • .gitignore: Git 忽略文件。
  • package.json: 项目依赖和脚本配置文件。
  • README.md: 项目说明文档。
  • webpack.config.js: Webpack 配置文件。

2. 项目的启动文件介绍

项目的启动文件主要位于 apps/ 目录下的各个示例应用程序中。以下是一些关键的启动文件:

app-gui/src/App.vue

<template>
  <div>Number of drivers: [[ count ]]</div>
</template>

<script setup>
import { ref } from 'vue';
import workerUrl from 'gdal3.js/dist/package/gdal3.js.url';
import dataUrl from 'gdal3.js/dist/package/gdal3WebAssembly.data.url';
import wasmUrl from 'gdal3.js/dist/package/gdal3WebAssembly.wasm.url';
import initGdalJs from 'gdal3.js';

const paths = {
  wasm: wasmUrl,
  data: dataUrl,
  js: workerUrl
};
const count = ref(0);

initGdalJs([paths]).then((Gdal) => {
  count.value = Object.keys(Gdal.drivers.raster).length + Object.keys(Gdal.drivers.vector).length;
});
</script>

example-node/index.js

const initGdalJs = require('gdal3.js/node');

initGdalJs().then((Gdal) => {
  // 使用 Gdal 进行操作
});

example-browser/index.js

import initGdalJs from 'gdal3.js';

initGdalJs().then((Gdal) => {
  // 使用 Gdal 进行操作
});

3. 项目的配置文件介绍

package.json

{
  "name": "gdal3.js",
  "version": "1.0.0",
  "description": "GDAL compiled to JavaScript",
  "main": "index.js",
  "scripts": {
    "build": "webpack",
    "test": "jest"
  },
  "dependencies": {
    "gdal3.js": "^2.8.1"
  },
  "devDependencies": {
    "webpack": "^5.0.0",
    "jest": "^27.0.0"
  }
}

webpack.config.js

const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
  plugins: [
    new CopyWebpackPlugin({
      patterns: [
        { from: 'node_modules/gdal3.js/dist/package/gdal3WebAssembly.wasm', to: 'static' },
        { from: 'node_modules/gdal3.js/dist/package/gdal3WebAssembly.data', to: 'static' }
      ]
    })

gdal3.jsConvert raster and vector geospatial data to various formats and coordinate systems entirely in the browser.项目地址:https://gitcode.com/gh_mirrors/gd/gdal3.js

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

严微海

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值