Code Monkey home page Code Monkey logo

Comments (2)

SkySails avatar SkySails commented on July 28, 2024

Alright, I think I have identified the cause. Two things I have noted:

  • 00000KT is technically not correctly parsed. The regex only matches the first 4 digits, which means that VIDP 270200Z 00000MPS is incorrectly parsed as 0 knots wind (I assume KT is the default unit)

    image

    This is technically not related to the original issue, so I opened #80 to track it separately!

  • The same regex also matches visibility stubs if the visibility is less than 100 meters. This match occurs later than the wind match, so it looks like the result overrides the real wind value resulting in the originally mentioned issue. I assume that this also means that the visibility parser never runs for this stub, which explains why there is no visibility reported in the output.

    image
    image

from metar-taf-parser.

SkySails avatar SkySails commented on July 28, 2024

Ok, so I dug a bit deeper. The culprit seems to be the double zero-digit matcher in the beginning of the regex.

It seems to be there in order to satisfy this test case, which includes an invalid METAR string according to the specifications I can find. As usual, most are not too explicit on the matter but this is one example:

Wind speeds (ff) are two digits (or three digits if required), in knots.
https://meteocentre.com/doc/metar.html

So I guess this is a case of choosing which case to support? If we change the regex by adding an additional required zero:

(VRB|000|[0-3]\d{2})(\d{2})G?(\d{2,3})?(KT|MPS|KM\/H)?

The result is much better, solving several issues:

image

  • Wind unit is correctly registered
  • Wind speed is correctly registered (not that it matters, it's all zeros anyway)
  • Visibility is no longer incorrectly matched

The downside is that the test case will start to fail. Is the METAR included in that test case a common occurrence? I mean, is it common for real-world METAR reports to report winds calm with only four digits?

from metar-taf-parser.

Related Issues (20)

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.