Simple Query of Postgis Posgresql database?

I need to make a simple read-only web query page that allows the user to
enter in a
longitude and latitude and get a list of areas within which those
coordinates occur.

I have a postgis (postgresql) databases that contain shape files for
county, township, range and section.

I can query these databases in the following way from within postgresql

in the database county

county=# SELECT name_lc FROM counties WHERE
distance(the_geom,‘POINT(-89.85139 42.73806)’) = 0;
name_lc

Lafayette
(1 row)

in the database section

section=# SELECT twp FROM secrdtrs_wgs84 WHERE
distance(the_geom,‘POINT(-89.85139 42.73806)’) = 0;
twp

3
(1 row)

also in the database section

section=# SELECT sec FROM secrdtrs_wgs84 WHERE
distance(the_geom,‘POINT(-89.85139 42.73806)’) = 0;
sec

13
(1 row)

How do create a web interface for these queries via rails?

I have looked through the rails postgres and various geo query postings
here and elsewhere but I am unable to figure out what how to do what
seems to be a relatively simple query.

I have been able to get rails to work with postgresql with some rails
demos

The databases are on another machine and I would like to make simple
queries like those above
from a postgres user account that will have read-only privileges.

The section database has the following tables

               List of relations

Schema | Name | Type | Owner
--------±-----------------------±---------±---------
public | geometry_columns | table | postgres
public | secrdtrs_wgs84 | table | pdevries
public | secrdtrs_wgs84_gid_seq | sequence | pdevries
public | spatial_ref_sys | table | postgres

The county database has the following tables

            List of relations

Schema | Name | Type | Owner
--------±-----------------±---------±---------
public | counties | table | pdevries
public | counties_gid_seq | sequence | pdevries
public | geometry_columns | table | postgres
public | spatial_ref_sys | table | postgres
(4 rows)

Any suggestions would be greatly appreciated :slight_smile:

  • Pete