<div dir="ltr">What kind of client is plugged to your Java code ?<div>Does it expect a raw json document to process on its own, or a geographic object built in Java ?</div><div><br></div><div>Nicolas</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 6 October 2015 at 15:55, Andrew Davis <span dir="ltr"><<a href="mailto:drsockmonkee@gmail.com" target="_blank">drsockmonkee@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Thanks...<br>
I am just starting out on it. I will be passing only about 40 point features first.</p>
<p dir="ltr">I will make note of and go look at the stream... as well..</p>
<p dir="ltr">Andy</p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Oct 6, 2015 8:53 AM, "Nicolas Ribot" <<a href="mailto:nicolas.ribot@gmail.com" target="_blank">nicolas.ribot@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Andy,<div><br></div><div>Your Java ResultSet contains one big row representing your geoJson document. You can pass it to the client by building a string from the resultset:</div><div>String geojson = resultSet.getString(1);</div><div><br></div><div>Be careful to the potential big size of the String: if you expect a big geojson document from the database, it may be wiser to stream it to the client from the JDBC connection instead of building a Java String. </div><div><br></div><div>Nicolas</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 6 October 2015 at 15:32, Andrew Davis <span dir="ltr"><<a href="mailto:drsockmonkee@gmail.com" target="_blank">drsockmonkee@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all..<div><br></div><div>I'm sending my first question out so patience please.</div><div><br></div><div>I've got a working servlet on my server that will query for and get information back from my postgis DB.</div><div><br></div><div>Up until now I have been just parsing the results and sending back a json string. I want to get a GeoJSON back from my db now.</div><div><br></div><div>I've been working through the information I found here: </div><div> <a href="http://www.postgresonline.com/journal/archives/267-Creating-GeoJSON-Feature-Collections-with-JSON-and-PostGIS-functions.html" target="_blank">http://www.postgresonline.com/journal/archives/267-Creating-GeoJSON-Feature-Collections-with-JSON-and-PostGIS-functions.html</a></div><div><br></div><div>I can create the table with locations included and a geog value, and I can run the query below</div><div><br></div><div><pre><code><span>SELECT</span> <span>row_to_json</span><span>(</span>fc<span>)</span>
<span>FROM</span> <span>(</span> <span>SELECT</span> <span>'</span><span>FeatureCollection</span><span>'</span> <span>As</span> <span>type</span>, <span>array_to_json</span><span>(</span><span>array_agg</span><span>(</span>f<span>)</span><span>)</span> <span>As</span> features
<span>FROM</span> <span>(</span><span>SELECT</span> <span>'</span><span>Feature</span><span>'</span> <span>As</span> <span>type</span>
, <span>ST_AsGeoJSON</span><span>(</span>lg.geog<span>)</span>::json <span>As</span> geometry
, <span>row_to_json</span><span>(</span><span>(</span>loc_id, loc_name<span>)</span><span>)</span> <span>As</span> properties
<span>FROM</span> locations <span>As</span> lg <span>)</span> <span>As</span> f <span>)</span> <span>As</span> fc;</code></pre><pre><code><br></code></pre><pre><code>which brings back a single line string and is in the correct format all in PGAdmin3.</code></pre><pre><code><br></code></pre><pre><code>I have been trying to duplicate this from my server with java and am stuck at the point where I have </code></pre><pre><code>run the query and have a 'thing' (ResultSet) but am unsure as to how to handle it and then pass it </code></pre><pre><code>back to the client.</code></pre><pre><code><br></code></pre><pre><code>Any help would be welcome.</code></pre><pre><code><br></code></pre><pre><code>Andy..</code></pre></div></div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div>
</div></div><br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>