JS functions to translate ISO19139 from/to MapX format
The package has been developed and tested using
- node v12.16.2
- npm 6.14.4
Grab the source by git cloning and run
npm install
to install the required dependencies.
In order to build the standalone bundle file, run
npm run build
You'll find the compiled js in dist/iso19139_mapx_converter.js
.
In order to run the tests, run
npm run test
Please note that the test script is run using the --experimental-module
option,
since full ES6 support is only implemented starting from node version 13.
For a syntax check, run
npx eslint src/
If you want to run a local test, first build the module, then make sure you have python installed on your machine.
If you have python 2.x, run:
python -m SimpleHTTPServer
For python 3, run:
python -m SimpleHTTPServer
then point the browser on http://localhost:8000/test/test.html
You can create the JSDoc for the functions in index.js
by running:
npm run jsdoc
you'll find the generated doc in the doc/
directory.
You can reformat the code with:
npm run format
Make sure you installed js-beautify globally:
npm -g install js-beautify
This package implements a mapping from ISO19139 XML documents to MAPX JSON and vice versa.
There are a couple of command line scripts that performs the conversions. These scripts can also be used as examples for using the mapping functions.
Basic usage:
node --experimental-modules ./src/loadISO.js [-v | -vv] INPUT OUTPUT
-v
: verbose output (i.e. INFO level logging)-vv
: very verbose output (i.e. DEBUG level logging)INPUT
: local filenameOUTPUT
: the output file name for the mapx JSON
Basic usage from command line:
node --experimental-modules ./src/loadMAPX.js [-v | -vv] INPUT OUTPUT
-v
: verbose output (i.e. INFO level logging)-vv
: very verbose output (i.e. DEBUG level logging)INPUT
: local filenameOUTPUT
: the output file name for the ISO19139 XML
You can find a working example in the test/test.html
file.
You need to include the bundle file, e.g.
<script src="dist/iso19139_mapx_converter.js"></script>
You can then call the functions in this way:
function iso2mapx() {
var iso_xml = document.getElementById("ta_iso").value;
var mapx_txt = window.iso19139_mapx_converter.iso19139_to_mapx(iso_xml);
document.getElementById("ta_mapx").value = mapx_txt;
}
function mapx2iso() {
var mapx = document.getElementById("ta_mapx").value;
var iso = window.iso19139_mapx_converter.mapx_to_iso19139(mapx);
document.getElementById("ta_iso").value = iso;
}
You may want to read the wiki pages for more detailed info.