<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Andreas;</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Thank you for your suggestion.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
How would this workflow handle </div>
<ul>
<li>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
multiple import operations spread over time into the same database and schema? The first import will yield a number of tables depending on data. The second import will need to determine which tables already contain a trigger and skip truncating it.
</div>
</li><li>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
adding (one or more) user specified metadata string. For example I would like to add description information or name of organization that produced data.</div>
</li></ul>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Another suggestion, add optional foreign key and value parameter to ogr2ogr. Using this option would add a extra colum to each created table which references a user define "metadata" table. The workflow could be
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
1. Create custom metadata table</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
2. Insert record into metadata table </div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
3. Run ogr2ogr with reference to record created in step 2.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
In this scenario ogr2ogr does not need to know much about any additional information and it reduces duplicated information.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
kind regards, Lars</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<hr tabindex="-1" style="width: 98%; display: inline-block;">
<div id="divRplyFwdMsg" dir="ltr"><font color="#000000" face="Calibri, sans-serif" style="font-size: 11pt;"><b>Fra:</b> gdal-dev <gdal-dev-bounces@lists.osgeo.org> på vegne av Andreas Oxenstierna <ao@t-kartor.se><br>
<b>Sendt:</b> onsdag 27. juni 2018 09.16<br>
<b>Til:</b> gdal-dev@lists.osgeo.org<br>
<b>Emne:</b> Re: [gdal-dev] ogr2ogr adding metadata</font>
<div> </div>
</div>
<meta content="text/html; charset=utf-8">
<div style="background-color: rgb(255, 255, 255);">
<div class="x_moz-cite-prefix">A S57 file with only 6 feature object classes? Normally there should be many more.<br>
<br>
I would add triggers to each table in the database for timestamps.<br>
Potential workflow:<br>
1 ogr for initial import into own schema<br>
2 Postgre script, reading all tables in the schema using the information_schema info, to truncate and add triggers<br>
3 ogr for final import<br>
<br>
<br>
</div>
<blockquote type="cite">
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Even,</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Appreciate the response.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Your example is interesting but there are a couple of issues. Importing a random .000 file using ogr2ogr yields 6 tables in the database. Which tables are created depend on the data and are unknown to me prior to import, so it is difficult to generate the SQL
in advance. This approach does not scale very well if data yields a number of tables.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Another issue was when adding the SQL statement for one specific table caused the import to ignore the other 5 tables. Is this the expect result or should all 6 table be imported?</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Regards, Lars</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<hr tabindex="-1" style="width: 98%; display: inline-block;">
<div id="x_divRplyFwdMsg" dir="ltr"><font color="#000000" face="Calibri, sans-serif" style="font-size: 11pt;"><b>Fra:</b> Even Rouault
<a class="x_moz-txt-link-rfc2396E" href="mailto:even.rouault@spatialys.com"><even.rouault@spatialys.com></a><br>
<b>Sendt:</b> fredag 22. juni 2018 23.15<br>
<b>Til:</b> <a class="x_moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">
gdal-dev@lists.osgeo.org</a><br>
<b>Kopi:</b> Lars<br>
<b>Emne:</b> Re: [gdal-dev] ogr2ogr adding metadata</font>
<div> </div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size: 11pt;">
<div class="x_PlainText">On vendredi 22 juin 2018 09:41:02 CEST Lars wrote:<br>
> Hello folks,<br>
> <br>
> Using ogr2ogr (version 2.2.3) to import s57 into PostgreSQL which works<br>
> great.<br>
> <br>
> What is the recommended approach for adding metadata to all inserted data?<br>
> <br>
> Say I wanted to add current date to all inserted data. Does ogr2ogr support<br>
> such operation? Tried using the "-mo" argument but it did not make any<br>
> inpact (same result with argument as without). Ideally I do not want the<br>
> client to be adding this information as a post insert operation (if even<br>
> possible).<br>
<br>
Lars,<br>
<br>
-mo will work only with very few target drivers (I can only think to <br>
GeoPackage actually). This is per-layer/per-table metadata. There's perhaps <br>
the equivalent in PostgreSQL but this isn't implemented by GDAL<br>
<br>
But you can add a column with the current timestamp for example with<br>
<br>
ogr2ogr -update PG:xxxxxx poly.shp \<br>
-sql "SELECT *, CURRENT_TIMESTAMP FROM poly" -dialect SQLITE<br>
<br>
Even<br>
<br>
-- <br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com">http://www.spatialys.com</a><br>
</div>
</span></font></div>
<br>
<fieldset class="x_mimeAttachmentHeader"></fieldset> <br>
<pre>_______________________________________________
gdal-dev mailing list
<a class="x_moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="x_moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></pre>
</blockquote>
<br>
<br>
<pre class="x_moz-signature" cols="72">--
Hälsningar
Andreas Oxenstierna
T-Kartor Geospatial AB
mobile: +46 733 206831
mailto: <a class="x_moz-txt-link-abbreviated" href="mailto:ao@t-kartor.se">ao@t-kartor.se</a>
<a class="x_moz-txt-link-freetext" href="http://www.t-kartor.com">http://www.t-kartor.com</a></pre>
</div>
</body>
</html>