I am learning Web GIS, and I can't find a good example that gives a big picture of a web interface of running spatial analysis using PostGIS.
What I am looking for is a graphical/GIS version of pgAdmin running on the web. Given a SQL statement, the web interface calls PostGIS, possibly generating a result table, which then gets rendered in a graphical/cartographic form rather than in a tabular form as in pgAdmin.
I looked around, and most question/answers here is regarding how to display an existing table in PostGIS. But there is nothing that covers the complete loop. That is, start query, store the result in the database, display it, and maybe using the result table for a new query.
I have a little bit of familiarity with GeoServer and its RESTful API, and very basic knowledge of JavScript/jQuery/HTML5.
Can some suggest a viable route for achieving this query-store-display loop?
Note: I am less interested in the visualization part and getting GeoJson's because they cannot be directly used by PostGIS for further analysis.
From @John's answer, GeoJSON seems to be a very good option and I think there is good reason why GeoJSON is so popular. On the other hand, I was hoping to find a more "server-side" solution that relies primarily on PostGIS doing the spatial analysis and GeoServer doing the rendering/cartography of the PostGIS tables/views. Hopefully, this will involve minimal client side programming (other than issuing SQL commands and GeoServer API calls).
I can do this manually with pgAdmin together with the GeoServer administration interface or RESTful API curling. But I am not sure how to do the same programmatically from the Web with e.g. AJAX and REST APIs. I have tried to use WPS, but without much success. For example, I have tried to perform simple raster map algebra, but the WPS in GeoServer takes two input rasters from server and only gives you an output image for download, not another raster dataset for further analysis. Here, the "loop" is broken.
Besides, WPS functions vary from one package to another. If there is something wrong in a WPS, it's less easy to get it fixed unless the upstream team is really active.
So I am thinking to not rely on WPS, and instead rely on PostGIS to do all vector and raster analysis, as I think Postgres is more tested and the relational/map algebra therein is complete. And I was hoping to use AJAX as a "command center" to issue SQL statements to Postgres (maybe with some server side PHP proxy??), and to render some of the resulting tables to the web via GeoServer (or another map server) (e.g. by publishing/updating the result tables/views).