<div dir="ltr">Hi everyone,<div><br></div><div>I am Xuri Gong. This is the <a href="https://trac.osgeo.org/postgis/wiki/GeospatialDataViewerInPgAdmin4ForPostGIS_FinalReport">final report</a> for my GSoC project.</div><div><br></div><div><div><div><font size="4"><b>Final Report: Implement Geospatial Data Viewer in pgAdmin4 for PostGIS</b></font></div><div><ul><li><b>Title: </b>Implement Geospatial Data Viewer in pgAdmin4 for PostGIS<br></li><li><b>Mentors:</b> Victoria Rautenbach and Frikan Erwee<br></li><li><b>Student: </b>Xuri Gong</li><li><b>Wiki:</b> <a href="https://trac.osgeo.org/postgis/wiki/GeospatialDataViewerInPgAdmin4ForPostGIS">https://trac.osgeo.org/postgis/wiki/GeospatialDataViewerInPgAdmin4ForPostGIS</a></li><li><b>Repository:</b> <a href="https://github.com/Gooong/pgadmin4/tree/geoviewer">https://github.com/Gooong/pgadmin4/tree/geoviewer</a><br></li><li><b>Pull Request:</b> <a href="https://www.postgresql.org/message-id/CAA7HE_fnAKtAqfzz2jNZGfYnB5BAcuSt_ZCsJ%2Be-nwFPDHCdxg%40mail.gmail.com">Code patch has been sent</a><br></li></ul></div><div><br></div><div><b><font size="4">Abstract</font></b></div><div>I propose to implement a geospatial data viewer in pgAdmin4 that will allow users to view the tables in a spatial database and the results of queries executed. With the viewer I intend to develop, users can directly view geospatial data on a map within the pgAdmin4 GUI.</div><div><br></div><div><b><font size="4">Status Before GSoC</font></b></div><div><a href="https://www.pgadmin.org/">pgAdmin</a> is the GUI management tool for PostgreSQL. The latest version pgAdmin4 is web-based and written in Python and jQuery with Bootstrap, using the Flask framework. But currently there is no geospatial data viewer in pgAdmin4-3.1, and external applications, such as QGIS are required if we want to view the data on a map. The pgAdmin4 Data Output panel only allows the user to view the table with the encoded geometries in text format.</div><div><br></div><div><b><font size="4">My Proposal and Work</font></b></div><div>With the geometry viewer I have created, users can now view individual geometry as well as all the geometries in the map. They can also view the properties of the geometries directly in the geometry viewer by clicking the specific geometry. Here are some screenshots:</div><div><br></div><div><div><img src="cid:ii_jkvdarez0" alt="Peek 2018-08-16 00-13.gif" width="539" height="324"><br></div><div><img src="cid:ii_jkvdb4aa1" alt="screenshot_1.png" width="539" height="343"><br></div><div><img src="cid:ii_jkvdb4be2" alt="screenshot_2.png" width="539" height="343"><br></div><div><img src="cid:ii_jkvdb4c83" alt="screenshot_4.png" width="539" height="343"><br></div></div><div><br></div><div>Below are the default strategies for parsing data:</div><div><ul><li><b>Supported data type: </b>Geometry Viewer support 2d and 3dm geometries in EWKB format including `Point, LineString, Polygon MultiPoint, MultiLineString, MultiPolygon, GeometryCollection`.<br></li><li><b>About SRID: </b>If there are geometries with different SRIDs in the same column, the viewer will render geometries with the same SRID in the map. If SRID=4326 the OSM tile layer will be added into the map.<br></li><li><b>About data size: </b>For performance considerations, the viewer will render geometries no more than 100000, totaling up to 20MB.<br></li></ul><div><br></div></div><div><b><font size="4">Test</font></b><br></div><div>Please test my code following the instructions below:</div><div><ol><li>Download the <span id="gmail-goog_1086658274"></span><span id="gmail-goog_1086658275"></span><a href="https://github.com/Gooong/pgadmin4/tree/geoviewer">geoviewer branch</a>.</li><li>Build and run pgAdmin4 following README.md in the repository.</li><li>For unit test, run <code style="color:rgb(102,0,0);border:1px solid rgb(238,221,204);border-radius:0.25em;padding:0px 0.3em;background:rgb(250,250,250);font-size:13px">cd $PGADMIN4_SRC</code><span style="color:rgb(0,0,0);font-size:13px"><font face="arial, helvetica, sans-serif"> and</font><font face="Verdana, Arial, Bitstream Vera Sans, Helvetica, sans-serif"> </font></span><code style="color:rgb(102,0,0);border:1px solid rgb(238,221,204);border-radius:0.25em;padding:0px 0.3em;background:rgb(250,250,250);font-size:13px">make check-js</code><span style="color:rgb(0,0,0);font-family:Verdana,Arial,"Bitstream Vera Sans",Helvetica,sans-serif;font-size:13px">.</span></li><li>If you want to have a try or test manually, install <a href="https://postgis.net/">PostGIS</a> and import some geometry data (for example import <a href="https://drive.google.com/open?id=1NHWW4WPli7kxpuGaDFGVFLDXdc2D20wp">this database</a> using <a href="https://www.postgresql.org/docs/9.2/static/app-psql.html">psql</a>). Then execute query in the pgAdmin4 and view the results.</li></ol></div><div><br></div><div><font size="4"><b>Future Work</b></font></div><div>The geometry viewer is functional and below are some suggestions for future work:</div><div><b>Optimize performance:</b></div><div><ul><li> Cluster markers using <a href="https://github.com/Leaflet/Leaflet.markercluster">Leaflet.markercluster</a> and deflate lines and polygons to a marker when their screen size becomes too small using <a href="https://github.com/oliverroick/Leaflet.Deflate">Leaflet.Deflate</a>.</li><li>Enable vectortile layer <a href="https://github.com/mapbox/geojson-vt">using geojson-vt</a>. Here is an example: <a href="https://www.getbounds.com/blog/leaflet-and-geojson-tiles/">leaflet-and-geojson-tiles</a>.</li><li>PgAdmin4 only load 1000 records by default. When users click 'view' button in the column header, show the map firstly and load the other records in the background and then add the records dynamically.</li></ul></div><div><b>New features:</b></div><div><ul><li>Custom geometry style, e.g<span style="font-size:13px;color:rgb(0,0,0);font-family:Verdana,Arial,"Bitstream Vera Sans",Helvetica,sans-serif"> </span><code style="font-size:13px;color:rgb(102,0,0);border:1px solid rgb(238,221,204);border-radius:0.25em;padding:0px 0.3em;background:rgb(250,250,250)">SELECT *, '#333333' as __fillcolor, '#232323' as __strokecolor, 0.5 as __strokewidth FROM xxx</code><span style="font-size:13px;color:rgb(0,0,0);font-family:Verdana,Arial,"Bitstream Vera Sans",Helvetica,sans-serif">.</span></li><li>Custom background tile layer. Enable users to specify their own tilelayer url.</li><li>Highlight selected feature. Add 'zoom home extent' button.</li></ul></div></div><div><br></div><div>Regards,</div></div><div>Xuri Gong</div></div>