Database Reference
In-Depth Information
Line String)4: multipolygons (Multi
Polygon)
5: other_relations (Geometry Collection)
2. Exportthelines'OSMfeaturestoaPostGIStableusing ogr2ogr ( ogr2ogr ,
as always, will implicitly create the GiST index that is needed by the
pg_trgm module to run):
$ ogr2ogr -f PostgreSQL -lco
GEOMETRY_NAME=the_geom -nln
chp08.osm_roads
PG:"dbname='postgis_cookbook' user='me'
password='mypassword'" lazio.pbf lines
3. Now try a trigram matching to identify the road names similar to a given
searchtextstring)usingaquerylikethefollowing.Notethatthe similar-
ity function returns a value that decreases from 1 to 0 as the similarity of
theworddecreases(with 1 ,thestringsareidentical;with 0 ,theyaretotally
different):
postgis_cookbook=# SELECT name,
similarity(name, 'via benedetto croce')
AS sml, ST_AsText(ST_Centroid(the_geom))
AS the_geomFROM chp08.osm_roadsWHERE name
% 'via benedetto croce'ORDER BY sml DESC,
name;
name | sml |
the_geom-------------------------------+----------+------------------------------------------Via
Benedetto Croce | 1 | POINT(13.4323581
41.3558496)Via Benedetto Croce
| 1 | POINT(12.067122592122
41.9587406015601)Via Benedetto
Croce | 1 |
POINT(14.0540279250186 41.4805402269014)
...
4. Asavariant,youwillusethefollowingqueryforcompletingtherecipe(inthis
case, when the weight is0, the strings are identical):
Search WWH ::




Custom Search