Quantcast
Channel: Question and Answer » gdal
Viewing all articles
Browse latest Browse all 397

ogr2ogr – PostGIS to GML with nested attributes

$
0
0

I am attempting to create GML from PostGIS tables and having issues with nested tags. Before I waste too much time on this, I would like to know if what I am trying to do is possible with “ogr2ogr”. I am currently using the VRT file listed below and the GML generation is successful printing all tags EXCEPT for the nested tags.

The specific tag is “changehistory” and contains the fields “changedate” & “reasonforchange” which can occur one or many times. Basically is there a way to format the vrt file to allow for nested tag output in the GML?

<OGRVRTDataSource>
<OGRVRTLayer name="boundaryline">
<SrcDataSource>PG:host=localhost port=8432 user=postgres dbname=mikes_test</SrcDataSource>
<SrcLayer>mastermap.boundaryline</SrcLayer>
    <Field name="fid" src="fid" />
    <Field name="featurecode" src="featurecode" />
    <Field name="version" src="version" />
    <Field name="versiondate" src="versiondate" />
    <Field name="theme" src="theme" />
    <Field name="accuracyofposition" src="accuracyofposition" />
        <Field name="changehistory">
            <Field name="changedate" src="changedate" />
            <Field name="reasonforchange" src="reasonforchange" />
        </Field>
    <Field name="descriptivegroup" src="descriptivegroup" />
    <Field name="descriptiveterm" src="descriptiveterm" />
</OGRVRTLayer> 

A valid example of the desired output is listed below:

<osgb:BoundaryLine fid="osgb1000001722014657">
<osgb:featureCode>10131</osgb:featureCode>
<osgb:version>3</osgb:version>
<osgb:versionDate>2004-06-25</osgb:versionDate>
<osgb:theme>Administrative Boundaries</osgb:theme>
<osgb:accuracyOfPosition>2.5m</osgb:accuracyOfPosition>
    <osgb:changeHistory>
        <osgb:changeDate>2003-02-13</osgb:changeDate>
        <osgb:reasonForChange>Attributes</osgb:reasonForChange>
    </osgb:changeHistory>
    <osgb:changeHistory>
        <osgb:changeDate>2004-02-19</osgb:changeDate>
        <osgb:reasonForChange>Position</osgb:reasonForChange>
    </osgb:changeHistory>
<osgb:descriptiveGroup>Political Or Administrative</osgb:descriptiveGroup>
<osgb:descriptiveTerm>District</osgb:descriptiveTerm>

Any alternative methods in achieving nested elements?


Viewing all articles
Browse latest Browse all 397

Trending Articles