[Qgis-user] wkt multipoint via delimited text requires internal parens

Andreas Plesch andreasplesch at netscape.net
Wed Jul 12 07:53:13 PDT 2017


It looks like the regex in
https://qgis.org/api/qgsmultipoint_8cpp_source.html#l00037
does not work this case. Although it should, hm.
Was it fixed for 2.99 ? . Let's see:
http://qgis.org/api/2.18/qgsmultipointv2_8cpp_source.html#l00037
Yes ! The regex for 2.18 does not recognize the '-', and therefore does not
recognize the 'non-standard' wkt form.
Looks like no need for a bug report then. Maybe I have missed an existing
one (?).
2.18.10 should also work as it has the fixed regex:
https://github.com/qgis/QGIS/blob/final-2_18_10/src/core/geometry/qgsmultipointv2.cpp#L37
Too bad, on my gentoo system >2.18.3 does not work anymore due to qt5
issues, I think.
Well, all cleared up then.
-Andreas
PS: Thinking about the regex, it should probably recognize '+' as well:
MULTIPOINT(+4 4, 5 5) may not work now. Hm, and '.' as in (.4 0.5, .1 .06)
What about testing for the 'standard' wkt form by looking for double
parentheses with '(\\s*(' instead ?


On Wed, Jul 12, 2017 at 10:05 AM, Andreas Plesch <andreasplesch at netscape.net
> wrote:

> Hi, I could narrow down the error to negative coordinates:
>
> This works on the console:
> >>> QgsGeometry.fromWkt('MULTIPOINTZ(2 2 4,3 3 4)').exportToWkt()
> u'MultiPointZ ((2 2 4),(3 3 4))'
>
> But this does not:
>
> >>> QgsGeometry.fromWkt('MULTIPOINTZ(-2 2 4,3 3 4)').exportToWkt()
> Traceback (most recent call last):
>   File "<input>", line 1, in <module>
> AttributeError: 'NoneType' object has no attribute 'exportToWkt'
>
> So negative coordinates do not work without parentheses, surprisingly.
> Perhaps some oversight in parsing.
>
> But negative coordinates work with parentheses:
>
> >>> QgsGeometry.fromWkt('MULTIPOINTZ((-2 2 4),(3 3 4))').exportToWkt()
> u'MultiPointZ ((-2 2 4),(3 3 4))'
>
> If there are no objections, I will file a report on the bug tracker.
>
> -Andreas
>
>
> On Tue, Jul 11, 2017 at 7:09 PM, Andreas Plesch <
> andreasplesch at netscape.net> wrote:
>
>> Hi
>>
>> Using 2.18.3, I found that Add Delimited Text Layer required a WKT of the
>> form:
>>
>> MULTIPOINT Z ((-119.00 34.82 1487),(-119.01 34.81 1450))
>>
>> rather than just
>>
>> MULTIPOINT Z (-119.00 34.82 1487,-119.01 34.81 1450)
>>
>> without the internal parentheses which is also allowed, and perhaps more
>> common.
>>
>> I searched through the bug tracker for 'MULTIPOINT' but could not find a
>> relevant issue.
>>
>> Did anybody come across this ?
>>
>> On a related note, I did this in order to convert a LINESTRINGZ to POINTZ
>> since the Extract Nodes tool did not preserve Z. CSV Exporting, text
>> editing and reimporting as MULTIPOINTZ seemed the easiest option. Is there
>> another option ?
>>
>> Thanks, Andreas
>>
>> --
>> Andreas Plesch
>> 39 Barbara Rd.
>> Waltham, MA 02453
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20170712/0cc1c897/attachment.html>


More information about the Qgis-user mailing list