Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including jpgis-convert with all npm packages installed. Try it out:

var jpgisConvert = require("jpgis-convert")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

jpgis-convert v1.0.3

JPGIS GML to GeoJSON converter

JPGIS GML converter

Build Status

JPGIS GML converter

JPGIS GML to GeoJSON converter for building peripheral lines (=BldA) for node.

Installation

npm i jpgis-convert

Usage

Example

const convert = require('jpgis-convert');
convert(['input1.xml', 'input2.xml'], {
    output: 'output.geojson'
});

convert(files [, options [, callback]])

  • files - Array of String of BldA.xml file path
  • options:
    • output - String of an output file path. If you don't set it, convert() outputs to stdout.
    • typeIds - Object of building type name to ID mapper. Default:
    {
        '普通建物': 0,
        '堅ろう建物': 1,
        '普通無壁舎': 2,
        '堅ろう無壁舎': 3
    }
    
    • ignoreTypes - Building type name Set to ignore.
  • callback - The Function is called when convert() finished. It takes no arguments.

A full option example:

const convert = require('jpgis-convert');
convert(['input1.xml', 'input2.xml'], {
    output: 'output.geojson',
    typeIds: {
        '普通建物': 0,
        '堅ろう建物': 1
    },
    ignoreTypes: new Set(['普通無壁舎', '堅ろう無壁舎'])
}, () => console.log('finished'));

Background and purpose

In May 2016, I found the tool FGDV of the government of Japan can't handle coordinates in <gml:interior> tags in <BldA> as individual ring. Coordinates in <gml:interior> and <gml:exterior> tags are merged to a ring. It converts JPGIS GML to broken shape files. PSEA had a same problem. I needed a tool to convert JPGIS GML to right GeoJSON for my project.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free