<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">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 class="">SELECT</span> <span class="">row_to_json</span><span class="">(</span>fc<span class="">)</span>
<span class="">FROM</span> <span class="">(</span> <span class="">SELECT</span> <span class="">'</span><span class="">FeatureCollection</span><span class="">'</span> <span class="">As</span> <span class="">type</span>, <span class="">array_to_json</span><span class="">(</span><span class="">array_agg</span><span class="">(</span>f<span class="">)</span><span class="">)</span> <span class="">As</span> features
<span class="">FROM</span> <span class="">(</span><span class="">SELECT</span> <span class="">'</span><span class="">Feature</span><span class="">'</span> <span class="">As</span> <span class="">type</span>
, <span class="">ST_AsGeoJSON</span><span class="">(</span>lg.geog<span class="">)</span>::json <span class="">As</span> geometry
, <span class="">row_to_json</span><span class="">(</span><span class="">(</span>loc_id, loc_name<span class="">)</span><span class="">)</span> <span class="">As</span> properties
<span class="">FROM</span> locations <span class="">As</span> lg <span class="">)</span> <span class="">As</span> f <span class="">)</span> <span class="">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>