Skip to content
AtmosphericX LogoWritten By: KiyoWx

Placefile Parser

Formally atmosx-placefile-parser


A Placefile is a structured text file used to provide geospatial data for mapping applications, often for weather alerts, storm reports, or points of interest. A Placefile contains instructions for displaying locations on a map, including coordinates, labels, colors, icons, and refresh intervals.

Installation (NPM)

bash
npm install @atmosx/placefile-parser

Example Usage

javascript
const { PlacefileManager } = require('@atmosx/placefile-parser'); // CJS
import { PlacefileManager } from '@atmosx/placefile-parser'; // ESM


const sample = fs.readFileSync("test", "utf-8"); // For testing...

// Parsing a basic placefile
PlacefileManager.parsePlacefile(sample).then((objects) => {
    console.log("Parsed Objects:", objects);
})

// Parsing a table
PlacefileManager.parseTable(sample).then((table) => {
    console.log("Parsed Table:", table);
})


// Parsing GeoJSON
PlacefileManager.parseGeoJSON(sample).then((geojson) => {
    console.log("Parsed GeoJSON:", geojson);
})

// Creating a placefile 
PlacefileManager.createPlacefile({
    refresh: 60,
    threshold: 50,
    title: "Sample Placefile",
    settings: "ShowLabels, ShowIcons",
    type: "Point",
    objects: [
        {
            coordinates: [34.0522, -118.2437],
            label: "Los Angeles",
            color: "255 0 0",
        },
        {
            coordinates: [40.7128, -74.0060],
            label: "New York",
            color: "0 0 255",
        }
    ]
}).then((placefile) => {
    console.log("Generated Placefile:\n", placefile);
});

References

Documentation | Discord Server | Project Board |
Code of Conduct | Contributing | License | Security | Changelogs |

Acknowledgements

  • k3yomi
    • Lead developer @ AtmosphericX and maintainer of this module.
  • StarflightWx
    • For testing and providing feedback (Co-Developer and Spotter @ AtmosphericX)