### Install and Use CLI Source: https://github.com/tyrasd/geojsontoosm/blob/master/README.md Install the package globally to use it as a command-line tool. Pipe GeoJSON input to the tool and redirect OSM output. ```bash $ npm install -g geojsontoosm $ geojsontoosm file.geojson > file.osm ``` -------------------------------- ### Install and Use as Node.js Library Source: https://github.com/tyrasd/geojsontoosm/blob/master/README.md Install the package locally for use within a Node.js project. Import the library and pass GeoJSON data to the function. ```bash $ npm install geojsontoosm ``` ```javascript var geojsontoosm = require('geojsontoosm'); geojsontoosm(geojson_data); ``` -------------------------------- ### Install geojsontoosm CLI Globally Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Installs the geojsontoosm command-line tool globally using npm. This allows you to use the 'geojsontoosm' command in your terminal. ```bash npm install -g geojsontoosm ``` -------------------------------- ### Print geojsontoosm version Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Check the installed version of the geojsontoosm tool. ```bash geojsontoosm --version ``` -------------------------------- ### geojsontoosm(geojson) - Convert GeoJSON to OSM XML Source: https://context7.com/tyrasd/geojsontoosm/llms.txt The main exported function of the library. It accepts various GeoJSON input formats and returns an OSM XML string. Examples demonstrate conversion of Points, LineStrings, Polygons, and MultiPolygons. ```APIDOC ## geojsontoosm(geojson) ### Description Converts GeoJSON data into an OpenStreetMap (OSM) XML string. It handles `FeatureCollection` objects, arrays of features/geometries, or individual feature/geometry objects. The function assigns negative IDs to generated OSM elements, which is a convention for new, uncommitted OSM data. ### Method `geojsontoosm(geojson)` ### Parameters - **geojson** (object | array) - Required - A GeoJSON object (FeatureCollection, Feature, or Geometry) or an array of GeoJSON features/geometries. ### Request Example ```javascript var geojsontoosm = require('geojsontoosm'); var pointFeature = { type: 'FeatureCollection', features: [ { type: 'Feature', properties: { name: 'Eiffel Tower', tourism: 'attraction' }, geometry: { type: 'Point', coordinates: [2.2945, 48.8584] } } ] }; console.log(geojsontoosm(pointFeature)); ``` ### Response #### Success Response - Returns a UTF-8 OSM XML string. #### Response Example ```xml ``` ``` -------------------------------- ### Print geojsontoosm help information Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Display the usage instructions and available options for the geojsontoosm command-line tool. ```bash geojsontoosm --help ``` -------------------------------- ### Convert inline GeoJSON to OSM XML Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Use a here-doc to provide GeoJSON data directly to geojsontoosm for quick testing and conversion to OSM XML. ```bash echo '{\n "type": "FeatureCollection",\n "features": [{\n "type": "Feature",\n "properties": {"amenity": "cafe"},\n "geometry": {"type": "Point", "coordinates": [4.9041, 52.3676]}\n }]\n}' | geojsontoosm ``` -------------------------------- ### Convert GeoJSON File to OSM XML using CLI Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Uses the geojsontoosm CLI tool to convert a GeoJSON file to OSM XML format and save the output to a file. Reads from stdin or a specified file and writes to stdout. ```bash # Convert a file and save the result geojsontoosm input.geojson > output.osm ``` -------------------------------- ### CLI - geojsontoosm command-line tool Source: https://context7.com/tyrasd/geojsontoosm/llms.txt The command-line interface for the geojsontoosm package, allowing conversion of GeoJSON files to OSM XML directly from the terminal. ```APIDOC ## CLI — `geojsontoosm` command-line tool ### Description The `geojsontoosm` binary reads a GeoJSON file (or standard input) and writes the converted OSM XML to standard output. It supports `--version` and `--help` flags. Internally, it uses `geojson-stream` for efficient parsing and then passes the data to the `geojsontoosm()` library function. ### Usage 1. **Install globally**: ```bash npm install -g geojsontoosm ``` 2. **Convert a file and save the result**: ```bash geojsontoosm input.geojson > output.osm ``` ### Options - `--version`: Displays the version of the tool. - `--help`: Shows the help message. ``` -------------------------------- ### Pipe GeoJSON data to geojsontoosm Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Use this command to pipe GeoJSON data from a URL or another process into geojsontoosm for conversion to OSM XML. ```bash curl -s https://example.com/data.geojson | geojsontoosm > output.osm ``` -------------------------------- ### Convert Raw Geometry Array to OSM Nodes Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Converts an array of raw GeoJSON geometry objects (without FeatureCollection wrapper) into OSM elements. Properties are not included if not part of a Feature. Requires the 'geojsontoosm' library. ```javascript var geojsontoosm = require('geojsontoosm'); // --- Raw geometry array (no FeatureCollection wrapper) --- var geometries = [ { type: 'Point', coordinates: [13.405, 52.52] }, { type: 'Point', coordinates: [13.410, 52.53] } ]; console.log(geojsontoosm(geometries)); ``` -------------------------------- ### Convert GeoJSON LineString to OSM Way Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Converts a GeoJSON LineString feature into an OSM way element. Properties are mapped to OSM tags. Requires the 'geojsontoosm' library. ```javascript var geojsontoosm = require('geojsontoosm'); // --- LineString → OSM way --- var lineFeature = { type: 'FeatureCollection', features: [ { type: 'Feature', properties: { highway: 'residential', name: 'Main Street' }, geometry: { type: 'LineString', coordinates: [ [-0.1276, 51.5074], [-0.1280, 51.5080], [-0.1290, 51.5085] ] } } ] }; console.log(geojsontoosm(lineFeature)); ``` -------------------------------- ### Convert GeoJSON Point to OSM Node Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Converts a GeoJSON Point feature into an OSM node element. Properties are mapped to OSM tags. Requires the 'geojsontoosm' library. ```javascript var geojsontoosm = require('geojsontoosm'); // --- Point → OSM node --- var pointFeature = { type: 'FeatureCollection', features: [ { type: 'Feature', properties: { name: 'Eiffel Tower', tourism: 'attraction' }, geometry: { type: 'Point', coordinates: [2.2945, 48.8584] } } ] }; console.log(geojsontoosm(pointFeature)); ``` -------------------------------- ### Convert GeoJSON Polygon to OSM Way Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Converts a GeoJSON Polygon feature into a closed OSM way element. Properties are mapped to OSM tags. Requires the 'geojsontoosm' library. ```javascript var geojsontoosm = require('geojsontoosm'); // --- Simple Polygon → closed OSM way --- var polygonFeature = { type: 'FeatureCollection', features: [ { type: 'Feature', properties: { building: 'yes', name: 'City Hall' }, geometry: { type: 'Polygon', coordinates: [[ [10.0, 53.5], [10.1, 53.5], [10.1, 53.6], [10.0, 53.6], [10.0, 53.5] // closed ring ]] } } ] }; console.log(geojsontoosm(polygonFeature)); ``` -------------------------------- ### Convert GeoJSON MultiPolygon to OSM Relation Source: https://context7.com/tyrasd/geojsontoosm/llms.txt Converts a GeoJSON MultiPolygon feature into an OSM multipolygon relation. Handles outer rings and inner holes. Properties are mapped to OSM tags on the relation. Requires the 'geojsontoosm' library. ```javascript var geojsontoosm = require('geojsontoosm'); // --- MultiPolygon → OSM multipolygon relation --- var multiPolyFeature = { type: 'FeatureCollection', features: [ { type: 'Feature', properties: { natural: 'water', name: 'Lake with Island' }, geometry: { type: 'MultiPolygon', coordinates: [ [ // outer ring [[9.0,48.0],[9.1,48.0],[9.1,48.1],[9.0,48.1],[9.0,48.0]], // inner ring (hole / island) [[9.04,48.04],[9.06,48.04],[9.06,48.06],[9.04,48.06],[9.04,48.04]] ] ] } } ] }; console.log(geojsontoosm(multiPolyFeature)); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.