How to use osm-p2p-server - 2 common examples

To help you get started, we’ve selected a few osm-p2p-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WorldBank-Transport / ram-backend / app / services / export-road-network / export-road-network.js View on Github external
.then(poiTypes => {
      const bbox = [-180, -90, 180, 90];
      const toOsmOptions = {
        bounds: {minlon: bbox[0], minlat: bbox[1], maxlon: bbox[2], maxlat: bbox[3]}
      };
      const osmDb = getDatabase(projId, scId);
      const formatTransform = obj2osm(toOsmOptions);

      formatTransform.on('error', (err) => {
        throw err;
      });

      logger && logger.log('Exporting data from osm-p2p');

      let stream = osmP2PApi(osmDb).getMap(bbox, {order: 'type'})
        .pipe(processOSMP2PExport());

      // Extract the POI into a promise and continue with the road network.
      let splitting = collectPOIs(stream, poiTypes);

      stream = splitting.stream.pipe(formatTransform);

      function processRN () {
        const fileName = `road-network_${Date.now()}`;
        const filePath = `scenario-${scId}/${fileName}`;

        return putFileStream(filePath, stream)
          // Get previous file.
          .then(() => db('scenarios_files')
            .select('path')
            .where('type', 'road-network')
github WorldBank-Transport / ram-backend / app / services / rra-osm-p2p.js View on Github external
export function getRouter (projId, scId) {
  return osmrouter(getDatabase(projId, scId));
}

osm-p2p-server

Peer-to-peer OpenStreetMap API v0.6 Server

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis

Popular osm-p2p-server functions