Git Product home page Git Product logo

geospatial-metadata's Introduction

geospatial-metadata

A JavaScript library for parsing and converting Geospatial Metadata.

Try me!

npm npm npm GitHub

Features

  • Convert XML document into JSON.
  • Convert XML document into HTML.

Installation

npm install @wsdot/geospatial-metadata

Use

import { toHtmlFragment } from "@wsdot/geospatial-metadata";

/**
 * Gets a metadata XML document, converts it to an HTMLDocumentFragment,
 * then appends the fragment to the document body.
 * @param {string} url - Metadata URL.
 * @returns {Promise}
 */
async function getMetadataHtml(url) {
    const response = await fetch(url);
    const xml = await response.text();
    const frag = toHtmlFragment(xml);
    document.body.append(frag);
}

// URL to retrieve XML metadata via ArcGIS Server.
const url = "https://data.wsdot.wa.gov/arcgis/rest/services/Shared/BridgeData/MapServer/2/metadata/";

getMetadataHtml(url).then(() => {
    console.log(`Successfully added metadata from ${url}.`);
}, error => {
    console.error(`Error adding metadata from ${url}`, error);
});

Resources

geospatial-metadata's People

Contributors

dependabot[bot] avatar jeffjacobson avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

geospatial-metadata's Issues

Section headings do not show up in IE 11

When the JavaScript code creates the sections and headers (<h1> elements), in IE 11, the headers are omitted. If you look at the markup via the F12 debugging tools, the <h1> elements are not there at all. (I.e., this is not a case of the elements not being displayed because of CSS.)

Replace incomplete csdgmAliases with module parsed from complete text file

Parse the reference/csdgm.txt file into JSON to get complete list of elements. This can be used to replace the csdgmAliases.js file.

  1. Read text line by line.

  2. Use the regular expression see if the current line is the first line of an element definition.

    // Matches first line of element definition
    var firstLine = /^\s*([\d\.]+)\s+(.+)\s-+\s(.+)/;
    /* [
        entire match, 
        element index number, 
        element long name, 
        description (until line break)
       ]
    */
  3. Lines after the first line of an element definition are a continuation of the description from the first line.

  4. The description stops when a line starting with (not including spaces) Type: is encountered.

  5. The Short Name: line indicates what the XML nodes name will be.

  6. Keep reading lines until another "first line" is encountered, which indicates a new element definition.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.