Table of Contents

Geographic Features

properties
Page Ownerlmgonzales

VuFind® contains modules for displaying geographic data at the record level, as well as a geographic search interface.

Features:

  1. Can display multiple geographic features (points and/or rectangles) for a record.
  2. Provides a geographic search interface.
  3. Includes configuration options for the geographic search and display interfaces.

To properly configure the Geographic Search & Display modules, you will need to ensure that your data is indexed properly, and then you will need to configure the module options in the associated .ini files.

This functionality was first introduced in VuFind® 3.1; it has subsequently evolved, as described in the geographic features changelog.

Indexing Geographic Data

Each record can have one or more point and/or rectangle features with labels.

Coordinates

The coordinate data will go into field 034 of your MARC record, in subfields $d,$e,$f, and $g. You can format your coordinates as decimal degrees (DD) or degrees minutes seconds (DMS), and you can assign hemispheres by using either letters (N,S,E,W) or symbols (+,-). If you omit the + sign, it is considered the default. Note that the order for coordinates in the MARC 034 field, is: $d: West; $e: East; $f: North; $g: South

If malformed coordinates are detected during indexing, an error message containing the record ID, coordinate values, and problems with the coordinate values will be displayed. Malformed coordinates will not be included in the indexed record.

Labels

Labels can be stored in the Solr database, and if you opt to do this, then put the labels in field 034 subfield $z. Alternatively, you have the option to use a look-up table to assign labels on the fly. If you use a look-up table, put the look-up table in your local/config/vufind/ directory.

Examples of MARC 034 field

Some examples of what the MARC record 034 field could look like are as follows:

Decimal degrees:

=034  0\$aa$d+46.4$e+40.4$f+31.5$g+28.50$zSite 447
=034  0\$aa$dE46.4$eE40.4$fN31.5$gN28.50$zSite 447

=034  0\$aa$dW10.1$eW10.1$fS5.7$gS5.7$zSite 440
=034  0\$aa$d-10.1$e-10.1$f-5.7$g-5.7$zSite 440

Degrees-minutes-seconds:

=034  0\$aa$dW1172630$eW1172630$fN661503$gN661503$zSite 393
=034  0\$aa$d+1172630$e+1172630$f+661503$g+661503$zSite 393

=034  0\$aa$dW0762630$eE0521915$fN051023$gS061503$zSite 980
=034  0\$aa$d-0762630$e+0521915$f+051023$g-061503$zSite 980

Solr fields and files

Starting in VuFind® 4.0, the following Solr fields are used store geographic data:

See the Solr Schema Changelog for details on how this changed from earlier versions.

The following files handle the indexing of geographic data:

Displaying Geographic Data

Underlying Technology

Starting with VuFind® 5.0, geographic features are displayed with Leaflet. For historical information about earlier implementations using OpenLayers and GoogleMaps, click the “Old revisions” button below to find earlier versions of this page.

Leaflet provides a light-weight code base for displaying point and rectangle features, as well as their labels and coordinates. Features can be clicked on to show a popup window that will display the label and/or coordinates of that feature depending on how the [MapTab] section is configured in the geofeatures.ini file.

General Configuration Notes

Configuration options for geographic feature display in the record's Map Tab from the geofeatures.ini file:

[Basemap]
basemap_url : the tileserver URL for the basemap
basemap_attribution: the attribution text for the basemap.

[MapTab]
recordMap = true ; OR false 
mapLabels = driver ; OR file:filename
displayCoords = true; OR false
graticule = true; OR false

Labels can be read from the long_lat_label field if they are stored in Solr, or assigned on the fly with a look-up table. If you use a look-up table, put it in your local/config/vufind/ directory, and in the geofeatures.ini file, set mapLabels = file:filename.

:!: Note: Starting in VuFind® 7.0., the contentsecuritypolicy.ini file was implemented. You will need to modify this file to include the basemap tileserver domain. The following is an example if you are using CARTO basemap server:

img-src[] =  "http://basemaps.cartocdn.com" 

Notes on Map Tiles

Map display depends on access to a tile set to allow zooming and scrolling around the world. The geofeatures.ini file includes some example tile URLs, but tile sets from free providers come with significant limitations on usage. If you wish to use this feature in production, you may need to subscribe to a commercial map provider or else run your own local tile server.

One way to help reduce the amount of map tile server calls is to configure the defaultRecordTab setting in the config.ini file to something other than “Map”.

Geographic Searching

The geographic search interface can be accessed from the Search bar by clicking on the Geographic Search link. When the Geographic Search link is clicked, a default Solr bounding box query will run and will display the search box and the search results clustered on the map interface. You can zoom in to uncluster or zoom out to cluster the points.

You can also click on the Draw Search Box button, and then click and drag to create the search box query. (Note that the previous query box and results will persist as you draw your new search box. This is done on purpose to give you a reference point relative to the previous query.)

If you need help, just click on the Need Help? link next to the Draw Search Box button. The help text for geographic searching has been integrated into the VuFind® help system so that the help is easier to maintain for translation purposes.

Starting in VuFind® 4.0, the geographic search queries against the long_lat field and returns the data from the following fields: long_lat, title, id.

Configurable Options

To turn on the geographic search functionality, uncomment the MapSelection line in the Top Recommendations section of the searches.ini file:

default_top_recommend[] = MapSelection ; see [MapSelection] in geofeatures.ini

You can set the default search box coordinates and the height of the map search interface in the [MapSelection] section of the geofeatures.ini file.

When setting your default search coordinates, try to focus the search on either an area with the most results or an area of high interest. Don’t make the search area too large or too small. You’ll probably have to play with the search interface to find the right setting.

[MapSelection]
; default_coordinates:  The default coordinates specified below are in decimal
;            degrees, and are ordered as WENS (west, east, north, south). Ranges of
;            valid values are:; -180 to 180 (longitude) and -85 to 85 (latitude).
;            Note, to search from and to the international date line, use
;            west = -179 and east = -180.
;
; height:    Height in pixels of the map selection interface.
default_coordinates = "-95, 30, 72, 15"
height = 320

Searching by Coordinate String

Another feature that is include in the Geographic Search code is the ability to search for records by entering a coordinate string. This will query against the long_lat_display field.

To configure this, you’ll need to turn on this feature in the searches.ini file in the Basic Searches and Advanced Searches sections, and if you want, the Autocomplete section as well.

[Basic_Searches]
;Coordinate = Coordinates

[Advanced_Searches]
;Coordinate = Coordinates

[Autocomplete_Types]
Coordinate = "None"

If you wish to change the configuration of the Coordinate field, update the corresponding section in the searchspecs.yaml file:

Coordinate:
  DismaxFields:
    - long_lat_display
DismaxHandler: edismax

Customizing the Geographic Search & Display Code

The geographic search & display features was first implemented in pull request #722. The code was significantly revised in pull request #1129.

The notes below refer to the code as it has existed since release 5.0; for notes on earlier versions, see the “Old revisions” button below.

If you want to customize the Geographic Display code, you will need to modify these files:

If you want to customize the Geographic Search code, you will need to modify these files:

The following files support both the Geographic Display and Geographic Search code:

Leaflet code:

configuration file:

Helper methods:

RecordDriver/SolrDefault.php methods:

CSS styling – add geoItem class for pop-ups to these files:

Additional Resources

For an overview of these features as they were originally developed for VuFind® 3.1, you can download the presentation slides from the VuFind® 2016 Summit for more information.