UNPKG

@berlin-vegan/berlin-vegan-data-js

Version:

A library and stand-alone program that specifies the native open-source JSON format used by Berlin-Vegan and allows to convert data in this format to be converted to OpenStreetMap/Overpass and Schema.org JSON formats.

62 lines 3.13 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var packageJson = require("../../../../package.json"); var conversion = require("./OsmTagsExtractor"); var DefaultConfig = require("../default-config.json"); var OverpassGeoJSONConverter = /** @class */ (function () { function OverpassGeoJSONConverter(osmConfig, overpassConfig) { if (osmConfig === void 0) { osmConfig = DefaultConfig.osm; } if (overpassConfig === void 0) { overpassConfig = DefaultConfig.overpass; } this.overpassConfig = overpassConfig; this.osmTagsConverter = new conversion.OsmTagsExtractor(osmConfig); } OverpassGeoJSONConverter.prototype.convertGastroLocations = function (locations) { var _this = this; return this.convertLocations(locations, function (location) { return _this.convertGastroLocation(location); }); }; OverpassGeoJSONConverter.prototype.convertShoppingLocations = function (locations) { var _this = this; return this.convertLocations(locations, function (location) { return _this.convertShoppingLocation(location); }); }; OverpassGeoJSONConverter.prototype.convertLocations = function (locations, getFeature) { return { type: "FeatureCollection", generator: packageJson.name, copyright: this.overpassConfig.copyright, timestamp: this.overpassConfig.placeholders.timestamp, features: locations.map(function (it) { return getFeature(it); }), }; }; OverpassGeoJSONConverter.prototype.convertGastroLocation = function (location) { return this.convertLocation(location, this.osmTagsConverter.getGastroLocationTags(location), this.osmTagsConverter.getGastroLocationCustomTags(location)); }; OverpassGeoJSONConverter.prototype.convertShoppingLocation = function (location) { return this.convertLocation(location, this.osmTagsConverter.getShoppingLocationTags(location), this.osmTagsConverter.getShoppingLocationCustomTags(location)); }; OverpassGeoJSONConverter.prototype.convertLocation = function (location, tags, customTags) { var nodeId = "node/" + this.overpassConfig.placeholders.nodeId; return { type: "Feature", id: nodeId, geometry: { type: "Point", coordinates: [location.longCoord, location.latCoord] }, properties: __assign(__assign({ "@id": nodeId }, tags), customTags), }; }; return OverpassGeoJSONConverter; }()); exports.OverpassGeoJSONConverter = OverpassGeoJSONConverter; //# sourceMappingURL=OverpassGeoJSONConverter.js.map