[qgis-qwc2] Address Search

Rayner Howard raynerhoward at gmail.com
Sat Dec 15 08:10:09 PST 2018


Hello,

Excellent web app.  While getting my own project set up in QWC2, I've
learned quite a bit of Linux, Apache2 and PostGIS/PostgreSQL in the
process.  My background is ESRI and I've been working with their Web
AppBuilder for a few years.  During these cold short winter days, I've been
spending quite a bit of time with QWC2 and really enjoying the challenge of
getting everything set up and working.  Good stuff.

So I managed to get my own feature search working by adding to
SearchProviders.js and following examples provided in the usterSearch
functions.  I set up a PostGIS database and figured out how to get search
working from my own searchtable.  Very cool, very fast response time, works
great on a free-tier Amazon EC2 instance running Ubuntu 18.04.  Brilliant.

Now on to the next challenge, search by address.  I've found 2 possible
ways to go.  One is to set up a search by address within QWC2 using
Nominatim.  It seems to work pretty well from the new QGIS 3 locator bar.
Since I haven't got the foggiest idea how to get this working in QWC2, even
though Nominatum is very well documented, I decided to set up a working
PostGIS Tiger Geocoder using the procedure here (note I'm running Linux
Mint 19 and Ubuntu 18.04):

https://experimentalcraft.wordpress.com/2017/11/01/how-to-make-a-postgis-tiger-geocoder-in-less-than-5-days/

So I have 2 U.S. states set up in the geocoder database:  Tennessee and
Georgia.  If I execute this:

SELECT g.rating, ST_AsText(ST_SnapToGrid(g.geomout,0.00000001)) As
wktlonlat,
(addy).address As stno, (addy).streetname As street,
(addy).streettypeabbrev As styp, (addy).location As city,
(addy).stateabbrev As st,(addy).zip
FROM geocode('1250 Market St, Chattanooga, TN 37401',1) As g;

it returns:

 rating |            wktlonlat            | stno | street | styp |    city
   | st |  zip
--------+---------------------------------+------+--------+------+-------------+----+-------
      2 | POINT(-85.30800056 35.04065209) | 1250 | Market | St   |
Chattanooga | TN | 37402
(1 row)

Beautiful.  And fast.  A free geocoder to use with QWC2 for searching
addresses.  Only thing is I have no idea how to set this up from within
QWC2.  No examples to follow.  Ideally, you type the address into the
search bar, it passes the address to the geocoder database, then parses the
search result and places a marker and an address label at the returned
location.

Here's what I've done so far:

Added a new "address" service to themesConfig.json

        "searchProviders": ["coordinates", "cha", "address", "layers"],

Added a new addressSearch function to SearchProviders.js

function addressSearch(text, requestId, searchOptions, dispatch) {
}

And that's pretty much it.  The usterSearch functions and the search.wsgi
are set up for an attribute search but not an address search.  search.wsgi
uses the connection string in qwc_connect.py

DB_CONN_STRING="host='localhost' dbname='sanitary' port='5432'
user='postgres' password='password'"

So I'm thinking I'll need to write a custom addressSearch.wsgi which would
use a different DB_CONN_STRING (since geocoder is a separate database)

DB_CONN_STRING="host='localhost' dbname='geocoder' port='5432'
user='postgres' password='password'"

Then it's on to figuring out the new searchAddress functions in
SearchProvider.js to get this to work.

I'm not asking for a step by step procedure, just some hints to get this
working within the QWC2 framework.  Any guidance you can provide would be
appreciated.

Regards,

Rayner Howard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-qwc2/attachments/20181215/ea064116/attachment.html>


More information about the qgis-qwc2 mailing list