[gdal-dev] How to concatenate with newlines by using OGR SQL?

Rahkonen Jukka Jukka.Rahkonen at mmmtike.fi
Tue Jul 31 02:54:12 PDT 2012


Hi,

Great, it does work. I was reading an entertaining page
http://stackoverflow.com/questions/245395/hidden-features-of-windows-batch-files
and because of http://stackoverflow.com/a/254169 I was just experimenting with ^

I wonder if OGR SQL could have one more special field for newline for making things easier and similar for Linux and Windows users. Usage could  then be like
-sql "select name,CONCAT(addr_street,NEWLINE,addr_housenumber)

There may not be so many use cases for this, but at least it would make it easier to create nice POI files in GPX format for GPS units which is not at all uncommon task.

-Jukka-


Chaitanya kumar wrote:

Jukka,

This should work:

ogr2ogr -f gpx test.gpx finland.osm.pbf -sql ^
More? "select name,CONCAT(addr_street,'^
More?
More? ',addr_housenumber) as 'desc' from points where amenity='toilets'"

Note that the "More? " part is given by DOS. By giving ^ at the end of line you are saying that there is more stuff to come. If you simply press 'return' when it prompts for more, it will treat it as a newline char and ask for more one more time.

DOS treats ^ as a quote character.
On Tue, Jul 31, 2012 at 1:06 PM, Rahkonen Jukka <Jukka.Rahkonen at mmmtike.fi<mailto:Jukka.Rahkonen at mmmtike.fi>> wrote:
Hi,

Sorry, I forgot to tell that I am on Windows.  “$’\n’” looks so gurutic that I feel jealous. I hope I will never need to teach anybody to use it at work, though ☺

-Jukka-

Chaitanya kumar wrote:

Jukka,

You can try to pass the newline character directly from the command line. With bash, you can use $'\n'. In your case it will be like this:

ogr2ogr -f gpx test.gpx finland.osm.pbf
-sql "select name,CONCAT(addr_street,"$'\n'",addr_housenumber)
as 'desc' from points where amenity='toilets'"
On Tue, Jul 31, 2012 at 12:09 PM, Jukka Rahkonen <jukka.rahkonen at mmmtike.fi<mailto:jukka.rahkonen at mmmtike.fi>> wrote:
Hi,

I was playing with the new OSM driver and tried to transfer some
POI features into my GPS. It goes well by using GPX format in
between. However, I have a little problem. My GPS supports multiline
descriptions but I do not know how to insert newlines into the
output of ogr2ogr. The following command adds a space character
between addr_street and addr_housenumber, but is is somehow possible
to insert newline instead?

ogr2ogr -f gpx test.gpx finland.osm.pbf
-sql "select name,CONCAT(addr_street,' ',addr_housenumber)
as 'desc' from points where amenity='toilets'"

I made two blind trials as
CONCAT(addr_street,\n,addr_housenumber) which gives parsing error and
CONCAT(addr_street,'\n',addr_housenumber) which adds string \n literally.

-Jukka Rahkonen-


_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/gdal-dev



--
Best regards,
Chaitanya kumar CH.

+91-9494447584<tel:%2B91-9494447584>
17.2416N 80.1426E

_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/gdal-dev



--
Best regards,
Chaitanya kumar CH.

+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120731/264486a4/attachment.html>


More information about the gdal-dev mailing list