New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@simwrapper/gmns

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@simwrapper/gmns

GMNS: the General Modeling Network Specification. Load GMNS networks from cmdline or in the browser. Converts GMNS to GeoJSON.

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
0
Created
Source

GMNS

GMNS is the "General Modeling Network Specification." GMNS itself is supported by the Zephyr Transport Foundation and is being developed here:

This is a JavaScript/TypeScript implementation of a GMNS reader. It allows you to read GMNS networks from your JavaScript code and convert them to a standard GeoJSON object usable anywhere that GeoJSON is spoken!

Current features

Load GMNS networks:

  • from a .zipfile containing all GMNS tables
  • from a folder containing the raw .csv tables

Convert GMNS:

  • to GeoJSON format

Converting MATSim networks to GMNS

As a courtesy, this package also contains a Python script which converts a MATSIM network.xml file into GMNS format. To convert your MATSIM network.xml to a zipped GMNS network file, first run:

  • python3 create-gmns-network.py

Installation of NPM package

npm install @simwrapper/gmns

Usage

// ESM
import GMNS from '@simwrapper/gmns'

// CommonJS
const GMNS = require('@simwrapper/gmns')

const network = GMNS.load('mynetwork.gmns.zip')
const geojson = GMNS.toGeojson(network)
console.log(geojson) // Output: { "type": "FeatureCollection", "features": [...]}

API Documentation

load(path: string, data?: ArrayBuffer|Blob|Uint8Array|String|Promise)

Load a GMNS file from a path or from an already-loaded Blob object.

Returns a GMNSNetwork object, which contains

  • path the file path from which the network was loaded
  • config parameters loaded from config.csv
  • t object which contains all of the .csv tables that were found in the zip file or folder.

Parameters:

path Required. can be a valid .zip file, a valid folder path containing the various CSV files, or sometimes a path directly to the GMNS config.csv file itself (but this only works with certain web servers). Even if you pass in the data directly (see below), this path string is used for identifying the dataset.

data Optional. Pass in an ArrayBuffer, Blob object, Uint8Array, or Promise to one of those datatypes with the .zip file content. The data will be used directly instead of loading from the net or disk.

toGeojson(GMNS: GMNSNetwork)

Returns a GeoJSON-compatible object with the network content. Currently only the nodes and link tables are read, and optionally if a geometry table exists, then the link geometries will also be present.

License

MIT

Keywords

gmns

FAQs

Package last updated on 18 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts