<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
12.05.2012 12:00, Siju Wu написал:
<blockquote
cite="mid:CAPKDXFxCkqur3xEyYrsf-8YNYWe5ansW-kvuM=DRpsKCn4gKEA@mail.gmail.com"
type="cite">Hi,
<div>I began using the GDAL for my master projet last month.
Before I used OGR to read directly the maps of shapefile. But
now I need to store the data first in the database of PostgreSQL
and then make access to the database by using the driver of
OGR. However I found that I can't connect the database by using
the function OGRSFDriverRegistrar::Open( source, FALSE ). My
code is as below:</div>
<div><br>
</div>
<div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>OGRRegisterAll();</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>OGRDataSource
*poDS;</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>poDS
= OGRSFDriverRegistrar::Open( "PG:dbname='postgis'
host='localhost' port='5432' user='postgres'
password='postgres'", FALSE );</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span></div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>if(
poDS == NULL )</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>printf(
"Open failed.\n" );</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>exit(
1 );</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>the value of poDS is null. Is that means in the version of
GDAL there is no driver for the postgreSQL and I need to write
it myself? I work with VS2010 c++ and GDAL 1.8.1. Dose anyone
know if there is method to connect the PostgreSQL by using OGR?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>-Michel</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/gdal-dev">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a></pre>
</blockquote>
Hi Siju,<br>
You can check an error message like this:<br>
const char* pszErr = CPLGetLastErrorMsg();<br>
<br>
Also you can log debug messages like this:<br>
CPLSetConfigOption("CPL_DEBUG", "ON");<br>
CPLSetConfigOption("CPL_TIMESTAMP", "ON");<br>
CPLSetConfigOption("CPL_LOG_ERRORS", "ON");<br>
CPLSetConfigOption("CPL_LOG", "/some_path/gdal_err.log" );<br>
<br>
Best regards,<br>
Dmitry<br>
</body>
</html>