Even Rouault wrote:

> Le vendredi 24 mai 2013 23:52:43, Jukka Rahkonen a écrit :
>> Hi,
>>
>> The -dialect parameter in ogr2ogr does not have an effect when using VRT as
>> datasource but could it be made to inject the selected dialect into SrcSQL
>> element of the VRT? Thus
>> ogr2ogr -dialect SQLITE
>> would lead to
>> <SrcSQL dialect="sqlite">SELECT ...</SrcSQL>

> (Almost) everything is possible in matter of software development, but IMHO
> the above would be a horrible hack in the code, whereas you can simply edit a
> text file to indicate your will.

After rethinking I agree that using -dialect as I suggested is not a good idea 
and that editing a text file is simple. I do not agree that making VRT to 
indicate my will is always easy but it helps a lot if there are some examples 
about the correct use and syntax.

I suggest to add a new example into Virtual Format manual page 
http://www.gdal.org/ogr/drv_vrt.html and it might be something like this:

Example: SQLite/Spatialite SQL dialect (GDAL >=1.10.0)

The following example will return four different layers which are generated in 
a fly from the same polygon shapefile. The first one is the shapefile layer as 
it stands. The second layer gives simplified polygons by applying Spatialite 
function "Simplify" with parameter tolerance=10. In the third layer the 
original geometries are replaced by their convace hulls. In the fourth layer 
Spatialite function PointOnSurface is used for replacing the original 
geometries by points which are inside the corresponding source polygons. Note 
that for using the last three layers of this VRT file GDAL must be compiled 
with SQLite and Spatialite.

<OGRVRTDataSource>
<OGRVRTLayer name="polygons">
<SrcDataSource>polygons.shp</SrcDataSource>
</OGRVRTLayer>
<OGRVRTLayer name="polygons_as_simplified">
<SrcDataSource>polygons.shp</SrcDataSource>
<SrcSQL dialect="sqlite">SELECT Simplify(geometry,10) from polygons</SrcSQL>
</OGRVRTLayer>
<OGRVRTLayer name="polygons_as_hulls">
<SrcDataSource>polygons.shp</SrcDataSource>
<SrcSQL dialect="sqlite">SELECT ConvexHull(geometry) from polygons</SrcSQL>
</OGRVRTLayer>
<OGRVRTLayer name="polygons_as_points">
<SrcDataSource>polygons.shp</SrcDataSource>
<SrcSQL dialect="sqlite">SELECT PointOnSurface(geometry) from polygons</SrcSQL>
</OGRVRTLayer>
</OGRVRTDataSource>

The last Other note on the driver page dealing with the normal use of VRT 
driver feels somehow outdated
"Normally the SrcDataSource is a non-spatial tabular format (such as MySQL, 
SQLite, CSV, OCI, or ODBC) but it can also be a spatial database in which case 
the geometry can be directly copied over. "

Regards,

-Jukka Rahkonen-
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to