Opened 8 years ago

Closed 8 years ago

#6217 closed enhancement (invalid)

<SrcDataSource>.</SrcDataSource> should reference current VRT

Reported by: timcera Owned by: warmerdam
Priority: low Milestone:
Component: default Version: unspecified
Severity: normal Keywords: VRT, srcdatasource
Cc:

Description

An "input.vrt" as below works (and is really cool by the way)...

<OGRVRTDataSource>
    <OGRVRTLayer name="boroughs">
        <SrcDataSource>nybb.shp</SrcDataSource>
        <SrcLayer>nybb</SrcLayer>
    </OGRVRTLayer>
    <OGRVRTLayer name="nursinghomes">
        <SrcDataSource>OEM_NursingHomes_001.shp</SrcDataSource>
        <SrcLayer>OEM_NursingHomes_001</SrcLayer>
    </OGRVRTLayer>
    <OGRVRTLayer name="joined">
        <SrcDataSource>input.vrt</SrcDataSource>
        <SrcSQL dialect="SQLITE">
        SELECT b.BoroName, sum(n.Capacity) as total_capacity from
        boroughs b, nursinghomes n WHERE ST_INTERSECTS(b.geometry, n.geometry) group
        by b.BoroName
        </SrcSQL>
    </OGRVRTLayer>
</OGRVRTDataSource>

The "joined" layer references itself ("input.vrt") to gain access to the other layers in the same VRT.

The <SrcDataSource>input.vrt</SrcDataSource> does introduce a frailty in that the connection could be broken by renaming the file. Suggest a special syntax to refer to itself and propose <SrcDataSource>.</SrcDataSource>.

Change History (1)

comment:1 by Even Rouault, 8 years ago

Resolution: invalid
Status: newclosed

I don't think it is a good idea since '.' is an actually valid datasource name for drivers like shapefile that accept directories as input.

You could rewrite your vrt as such using <![CDATA[stuff]]> syntax as a way of embedding an inner VRT

<OGRVRTDataSource>
    <OGRVRTLayer name="joined">
        <SrcDataSource><![CDATA[<OGRVRTDataSource>
    <OGRVRTLayer name="boroughs">
        <SrcDataSource>nybb.shp</SrcDataSource>
        <SrcLayer>nybb</SrcLayer>
    </OGRVRTLayer>
    <OGRVRTLayer name="nursinghomes">
        <SrcDataSource>OEM_NursingHomes_001.shp</SrcDataSource>
        <SrcLayer>OEM_NursingHomes_001</SrcLayer>
    </OGRVRTLayer>
</OGRVRTDataSource>]]></SrcDataSource>
        <SrcSQL dialect="SQLITE">
        SELECT b.BoroName, sum(n.Capacity) as total_capacity from
        boroughs b, nursinghomes n WHERE ST_INTERSECTS(b.geometry, n.geometry) group
        by b.BoroName
        </SrcSQL>
    </OGRVRTLayer>
</OGRVRTDataSource>
Note: See TracTickets for help on using tickets.