A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

[Proposal] А standard for physical measurements (enabling machine-read/convert)

futekov
2021-02-13

Currently no standard has been established for physical measurements such as dimensions, volume, mass, speed, temperature, etc.

This image shows a sample UI that will be made possible if such a standard existed:

The Problem

The measuring systems in modern use are the metric, imperial, and US customary systems and web users are forced to interrupt their browsing journey to convert units that are not native to them.

Google Search has been answering conversion queries for at least 16 years so we can infer that the demand for unit conversion is indeed huge.

A standard like that would provide hooks for measurements, which would make client-side conversion of units between measurement systems much easier to accomplish. Any site would then be able write a script to convert it, browsers extensions could be easily created to convert units across the web, and browsers themselves could offer it as built-in function similar to page translation (available in Chrome and Safari).

Idea with a new HTML element

I’ve written a short essay proposing a <m> element, but the same applies to also using <data> or something else. A basic structure would look like this:

<m unit="mi" value="20">twenty miles</m>

Challenges

The main problem that needs solving is establishing a standard for the markup:

  • which semantic element(s) to use
  • what unit code standard to use in attributes

All these have to make physical measurements machine-readable and easy to implement at the same time.

tomayac
2021-02-19

I think this could just be implemented as a custom element similar to GitHub’s time elements.

As you write in your Explainer, the Intl interface sounds like a good place for this if you aim for having it as a browser API, to be used similar to, for example, RelativeTimeFormat.

For machine-readability, there’s Distance as a type in schmema.org markup.

ghobona-ogc
2021-02-22

The Observations and Measurements (O&M) standard could address your requirements. The conceptual model is an ISO standard. Version 2 of the XML encoding is an OGC standard. The O&M Standards Working Group (SWG) is working on Version 3, which will include JSON and XML encodings.

futekov
2021-03-21

My intention isn’t to just implement some sort of a solution. I want to probe the opinion of the people here whether such a standard is viable and useful.

@tomayac - RelativeTimeFormat is something that very much resembles my idea, I even saw that recently more localisation ideas have gotten into ECMAScript 2020 and it seems to be moving in a similar direction.