Skip to content

Commit

Permalink
Add minimal embeded proj.db, update proj & emsdk
Browse files Browse the repository at this point in the history
  • Loading branch information
jvail committed Sep 25, 2022
1 parent 4452068 commit 4f01bbb
Show file tree
Hide file tree
Showing 20 changed files with 318 additions and 55 deletions.
3 changes: 0 additions & 3 deletions CHANGES.md

This file was deleted.

10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PREFIX = --prefix=$(BC_DIR)

SQLITE_VERSION = 3360000
GEOS_VERSION = 3.9.0
PROJ_VERSION = 8.1.0
PROJ_VERSION = 9.1.0
RTTOPO_VERSION = 1.1.0

ZLIB_VERSION = 1.2.12
Expand Down Expand Up @@ -54,7 +54,7 @@ else
EMX_FLAGS += -Os
endif

em: dir zlib iconv sqlite proj geos rttopo xml2 spatialite extensions
em: dir zlib iconv sqlite proj proj-db-min geos rttopo xml2 spatialite extensions

dir:
mkdir -p $(BUILD_DIR);
Expand Down Expand Up @@ -138,6 +138,10 @@ xml2: xml2-conf

# sqlite3 executable needed for building proj.db

proj-db-min:
cp -f $(BC_DIR)/share/proj/proj.db $(BC_DIR)/share/proj_min.db;
sqlite3 $(BC_DIR)/share/proj_min.db < $(PWD)/scripts/projdb_min.sql;

proj-src:
cd $(BUILD_DIR); \
wget -nc http://download.osgeo.org/proj/proj-$(PROJ_VERSION).tar.gz; \
Expand Down Expand Up @@ -281,7 +285,7 @@ spl: src/pre.js
-I$(SQLITE_SRC) \
-I$(SPATIALITE_SRC)/src/headers \
-I$(SPATIALITE_SRC)/src/headers/spatialite \
src/spl.c --pre-js src/pre.js -o $(BUILD_DIR)/js/spl.js;
src/spl.c --pre-js src/pre.js -o $(BUILD_DIR)/js/spl.js --embed-file $(BC_DIR)/share/proj_min.db@/proj_min.db;

clean:
rm -rf $(PWD)/dist/*;
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Comments, bug reports and suggestions are welcome! spl.js will remain beta at le
## Install

```bash
npm install [email protected].5
npm install [email protected].6
```

The library for browsers bundles both the WebWorker script and the wasm file (~ 4MB). PROJ files (like proj.db) are not bundled but available from the `dist/proj` folder.
The library for browsers bundles both the WebWorker script and the wasm file (~ 4MB). A minimal proj.db including EPSG codes for lon/lat to "Web Mercator" and UTM is embeded. Other PROJ files and the complete proj.db are available from the `dist/proj` folder.

[Apparently](https://github.com/jvail/spl.js/issues/1) typescript has no option to switch between `main` and `browser` entrypoints in `package.json`. For typescript & browser development you need to import spl.js (async version) as

Expand Down Expand Up @@ -286,7 +286,7 @@ console.assert(await spl.spatialite_version() === '5.0.1');

## Building and Testing

An activated, working emsdk environment (2.0.29) is required (https://emscripten.org/docs/tools_reference/emsdk.html). All dependencies except SpatiaLite are fetched from the web. The `src/spatialite` git submodule (https://salsa.debian.org/debian-gis-team/spatialite.git) needs to be initialized before running the build script.
An activated, working emsdk environment (3.1.23) is required (https://emscripten.org/docs/tools_reference/emsdk.html). All dependencies except SpatiaLite & sqlean (git submodules) are fetched from the web. The git submodules needs to be initialized before running the build script.

```bash
npm install && npm run build:all
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions dist/proj/CH
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# See: https://shop.swisstopo.admin.ch/en/products/geo_software/GIS_info
#
# You'll need to download the grids separately and put in a directory
# scanned by libproj. Directories may be added to the scan list through
# the PROJ_LIB environment variable
# scanned by libproj.
#
# Note that an independent effort was made to derive an usable grid
# from the CH1903->CH1903+ grid initially available from the Swisstopo
Expand Down
37 changes: 35 additions & 2 deletions dist/proj/ITRF2008
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,47 @@

<NAZC> +proj=helmert +drx=-0.000330 +dry=-0.001551 +drz=0.001625 +convention=position_vector

<NOAM> +proj=helmert +drx=0.000035 +dry=-0.000662 +drz=0.0001 +convention=position_vector
<NOAM> +proj=helmert +drx=0.000035 +dry=-0.000662 +drz=-0.0001 +convention=position_vector

<NUBI> +proj=helmert +drx=0.000095 +dry=-0.000598 +drz=0.000723 +convention=position_vector

<PCFC> +proj=helmert +drx=0.000411 +dry=0.001036 +drz=-0.002166 +convention=position_vector
<PCFC> +proj=helmert +drx=-0.000411 +dry=0.001036 +drz=-0.002166 +convention=position_vector

<SOAM> +proj=helmert +drx=-0.000243 +dry=-0.000311 +drz=-0.000154 +convention=position_vector

<SOMA> +proj=helmert +drx=-0.000080 +dry=-0.000745 +drz=0.000897 +convention=position_vector

<SUND> +proj=helmert +drx=0.000047 +dry=-0.001 +drz=0.000975 +convention=position_vector


# Plate names suffixed by _T (for Translation) that includes the translation
# rates +dx=0.00041 +dy=0.00022 +dz=0.00041 given by Table 2 of the ITRF2008 plate motion model
# paper

<AMUR_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=-0.000190 +dry=-0.000442 +drz=0.000915 +convention=position_vector

<ANTA_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=-0.000252 +dry=-0.000302 +drz=0.000643 +convention=position_vector

<ARAB_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=0.001202 +dry=-0.000054 +drz=0.001485 +convention=position_vector

<AUST_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=0.001504 +dry=0.001172 +drz=0.001228 +convention=position_vector

<CARB_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=0.000049 +dry=-0.001088 +drz=0.000664 +convention=position_vector

<EURA_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=-0.000083 +dry=0.000534 +drz=0.000750 +convention=position_vector

<INDI_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=0.001232 +dry=0.000303 +drz=0.001540 +convention=position_vector

<NAZC_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=-0.000330 +dry=-0.001551 +drz=0.001625 +convention=position_vector

<NOAM_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=0.000035 +dry=-0.000662 +drz=-0.0001 +convention=position_vector

<NUBI_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=0.000095 +dry=-0.000598 +drz=0.000723 +convention=position_vector

<PCFC_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=-0.000411 +dry=0.001036 +drz=-0.002166 +convention=position_vector

<SOAM_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=-0.000243 +dry=-0.000311 +drz=-0.000154 +convention=position_vector

<SOMA_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=-0.000080 +dry=-0.000745 +drz=0.000897 +convention=position_vector

<SUND_T> +proj=helmert +dx=0.00041 +dy=0.00022 +dz=0.00041 +drx=0.000047 +dry=-0.001 +drz=0.000975 +convention=position_vector
6 changes: 3 additions & 3 deletions dist/proj/ITRF2014
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

<ITRF97> +proj=helmert +x=0.0074 +y=-0.0005 +z=-0.0628 +d=0.0038 +rz=0.00026 +dx0.0001 +dy=-0.0005 +dz=-0.0033 +ds=0.00012 +drz=0.00002 +t_epoch=2010.0 +convention=position_vector

<ITRF96> +proj=helmert +x=0.0074 +y=-0.0005 +z=-0.0628 +s=0.0038 +rz=0.00026 +dx=0.0001 +dy=-0.0005 +dz=-0.0033 +ds=0.00012 +t_epoch=2010.0 +convention=position_vector
<ITRF96> +proj=helmert +x=0.0074 +y=-0.0005 +z=-0.0628 +s=0.0038 +rz=0.00026 +dx=0.0001 +dy=-0.0005 +dz=-0.0033 +ds=0.00012 +drz=0.00002 +t_epoch=2010.0 +convention=position_vector

<ITRF94> +proj=helmert +x=0.0074 +y=-0.0005 +z=-0.0628 +s=0.0038 +rz=0.00026 +dx=0.0001 +dy=-0.0005 +dz=-0.0033 +ds=0.00012 +t_epoch=2010.0 +convention=position_vector
<ITRF94> +proj=helmert +x=0.0074 +y=-0.0005 +z=-0.0628 +s=0.0038 +rz=0.00026 +dx=0.0001 +dy=-0.0005 +dz=-0.0033 +ds=0.00012 +drz=0.00002 +t_epoch=2010.0 +convention=position_vector

<ITRF93> +proj=helmert +x=-0.0504 +y=0.0033 +z=-0.0602 +s=0.00429 +rx=-0.00281 +ry=-0.00338 +rz=0.0004 +dx=-0.0028 +dy=-0.0001 +dz=-0.0025 +ds=0.00012 +drx=-0.00011 +dry=-0.00019 +drz=0.00007 +t_epoch=2010.0 +convention=position_vector

Expand All @@ -23,7 +23,7 @@

<ITRF89> +proj=helmert +x=0.0304 +y=0.0355 +z=-0.1308 +s=0.00819 +rz=0.00026 +dx=0.0001 +dy=-0.0005 +dz=-0.0033 +ds=0.00012 +drz=0.00002 +t_epoch=2010.0 +convention=position_vector

<ITRF88> +proj=helmert +x=0.0254 +y=-0.0005 +z=-0.1548 +s=0.01129 +rx=0.0001 +rz= +dx=0.00026 +dy=0.0001 +dx=-0.0005 +dz=-0.0033 +ds=0.00012 +drz=0.00002 +t_epoch=2010.0 +convention=position_vector
<ITRF88> +proj=helmert +x=0.0254 +y=-0.0005 +z=-0.1548 +s=0.01129 +rx=0.0001 +rz=0.00026 +dx=0.0001 +dy=-0.0005 +dz=-0.0033 +ds=0.00012 +drz=0.00002 +t_epoch=2010.0 +convention=position_vector

# ITRF2014 Plate Motion Model parameters
#
Expand Down
Binary file modified dist/proj/proj.db
Binary file not shown.
5 changes: 5 additions & 0 deletions dist/proj/proj.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ cache_size_MB = 300

cache_ttl_sec = 86400

; Filename of the Certificate Authority (CA) bundle.
; Can be overriden with the PROJ_CURL_CA_BUNDLE / CURL_CA_BUNDLE environment variable.
; (added in PROJ 9.0)
; ca_bundle_path = /path/to/cabundle.pem

; Transverse Mercator (and UTM) default algorithm: auto, evenden_snyder or poder_engsager
; * evenden_snyder is the fastest, but less accurate far from central meridian
; * poder_engsager is slower, but more accurate far from central meridian
Expand Down
Loading

0 comments on commit 4f01bbb

Please sign in to comment.