Coder Social home page Coder Social logo

Lat / Long matches incorrectly about pywhat HOT 6 CLOSED

bee-san avatar bee-san commented on May 28, 2024
Lat / Long matches incorrectly

from pywhat.

Comments (6)

Saacket avatar Saacket commented on May 28, 2024 1

plz explain

from pywhat.

Vipul-Bajaj avatar Vipul-Bajaj commented on May 28, 2024

Can you please explain more on this issue?

from pywhat.

bee-san avatar bee-san commented on May 28, 2024

Can you please explain more on this issue?

Sure! e90963 is not valid latitude / longitude coordinates and it shouldn't match :(

from pywhat.

bee-san avatar bee-san commented on May 28, 2024

plz explain

What are you confused about? :)

image

e90963 is not valid lat / long coordinates as it's only one single item (that's rather small)

from pywhat.

bee-san avatar bee-san commented on May 28, 2024

Another example:

Matched on: e26
Name: Latitude & Longitude Coordinates
Link:  https://www.google.com/maps/place/e26

from pywhat.

nodtem66 avatar nodtem66 commented on May 28, 2024

I propose this new one: https://regex101.com/r/WrINyr/1

The old RegEx consists of three patterns:

  1. Full expression with symbols and prefix N/W/S/E , e.g. N 32° 53.733 W 096° 48.358
    (?:(?:N|W|S|E)\\s?\\d+\\s?\\u00B0?\\s?\\d+\\.?\\d*\\s?\\'?\\s?\\d*\\.?\\,?\\d*?\"?\\s?){1,2}
  2. Full expression with symbols and subfix N/W/S/E, e.g. 13°55'24.3"N 101°20'30.1"E
    (?:\\d+\\s?\\u00B0\\s?\\d+\\s?\\'\\s?\\d+\\.?\\,?\\d{0,}?\"\\s?(?:N|W|S|E)\\s?){1,2}
  3. Two decimal numbers without symbols and prefixs, e.g. 52.6169586, -1.9779857
    (?:[-+]?(?:[0-8]?\\d+\\.\\d{4,}|90(?:\\.0+)?),\\s*[-+]?(?:180(?:\\.0+)?|(?:(?:1[0-7]\\d)|(?:[1-9]?\\d))(?:\\.\\d+)?))
    "Regex": "(?i)^((?:(?:N|W|S|E)\\s?\\d+\\s?\\u00B0?\\s?\\d+\\.?\\d*\\s?\\'?\\s?\\d*\\.?\\,?\\d*?\"?\\s?){1,2}|(?:\\d+\\s?\\u00B0\\s?\\d+\\s?\\'\\s?\\d+\\.?\\,?\\d{0,}?\"\\s?(?:N|W|S|E)\\s?){1,2}|(?:[-+]?(?:[0-8]?\\d+\\.\\d{4,}|90(?:\\.0+)?),\\s*[-+]?(?:180(?:\\.0+)?|(?:(?:1[0-7]\\d)|(?:[1-9]?\\d))(?:\\.\\d+)?)))$",

The first pattern slightly differs from the second pattern in the symbol matchings

  • \\u00B0? and \\u00B0
  • \\'? and \\'
  • \"? and \"
    This causes the RegEx matching of e26, e90963, and so on.

I've observed that there is nothing like N 52.6169586, W -1.9779857; only N 32° 53.733 W 096° 48.358, and 52.6169586, -1.9779857 are valid.

Then these symbol matching should've been changed to the strict matching of \\u00B0, \\', and \" or the flexible matching of \\u00B0, \\'?, and \"?.

If it looks fine, I'll make a patch.
Thanks

from pywhat.

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.