[PATCH] Make ISO-6709 coordinate regex less restrictive

José Carlos Andreu Galán joscandreu at gmail.com
Mon May 26 15:03:15 PDT 2014


Here it is. Hopefully now everything is correct.

Regards,
Jose


2014-05-26 9:20 GMT+02:00 José Carlos Andreu Galán <joscandreu at gmail.com>:

> Certainly I'm not an expert at regex. I understand what you say.
> I'll resubmit the patch with the changes. Thanks for the advice!
>
>
> 2014-05-26 0:41 GMT+02:00 Dirk Hohndel <dirk at hohndel.org>:
>
> On Mon, May 26, 2014 at 12:02:33AM +0200, José Carlos Andreu Galán wrote:
>> > I found myself trying to copy/paste coordinates for my dives from diving
>> > websites / forums and Subsurface did not accept them because it was
>> > applying strictly the suggestions from ISO6709 Annex D.
>> > Now it parses them correctly with messy whitespace and use of '' (double
>> > simple quotes) instead of " (single char of double quotes) for the
>> seconds
>> > symbol which I found to be a very common mistake at this kind of sites.
>>
>> Thanks for that patch!
>> I have a quick question - I think you may have made the reg exp more
>> complicated than it needs to be...
>>
>> > diff --git a/qthelper.cpp b/qthelper.cpp
>> > index bcf78b5..0dbe0fc 100644
>> > --- a/qthelper.cpp
>> > +++ b/qthelper.cpp
>> > @@ -82,10 +82,11 @@ bool parseGpsText(const QString &gps_text, double
>> *latitude, double *longitude)
>> >       // ISO 6709 Annex D representation
>> >       //
>> http://en.wikipedia.org/wiki/ISO_6709#Representation_at_the_human_interface_.28Annex_D.29
>> >       // e.g. 52°49'02.388"N 1°36'17.388"E
>> > -     if (gps_text.at(0).isDigit() && (gps_text.count(",") % 2) == 0) {
>> > +     if (gps_text.at(0).isDigit() && ((gps_text.count(",") % 2) == 0
>> || gps_text.count(QChar('\'')) == 6)) {
>> >               gpsStyle = ISO6709D;
>> > -             regExp = QString("(\\d+)[" UTF8_DEGREE
>> "\\s](\\d+)[\'\\s](\\d+)([,\\.](\\d+))?[\"\\s]([NS%1%2])"
>> > -                              "\\s*(\\d+)[" UTF8_DEGREE
>> "\\s](\\d+)[\'\\s](\\d+)([,\\.](\\d+))?[\"\\s]([EW%3%4])")
>> > +             regExp = QString("(\\d+)([" UTF8_DEGREE "\\s]|"
>> UTF8_DEGREE "\\s*)(\\d+)([\'\\s]|\'\\s*)(\\d+)([,\\.]
>>
>>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>                                          that seems silly - why not just "
>>                                   (\\d+)[" UTF*_DEGREE "\\s]\\s*(\\d+
>>
>> If I'm right I think you could simplify the whole patch (as you no longer
>> need those extra groups for the '|'...)
>>
>> Can you comment and maybe resubmit?
>>
>> /D
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140527/217a6776/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Make-ISO6709-coordinate-regex-less-restrictive.patch
Type: text/x-patch
Size: 2575 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140527/217a6776/attachment-0001.bin>


More information about the subsurface mailing list