Greenstone tutorial exercise
An image collection with GPS metadata
In this tutorial, we'll be looking at building a collection that takes advantage of the GPS metadata embedded in image files. Using this data, we can plot the images on a map based on where they were taken.
- Create a new collection in GLI called Images-GPS. In the Gather panel, drag and drop the 4 folders in sample_files → images_gps from the Workspace view on the left into the Collection view on the right.
- Since the images are organised by folder, we can easily assign folder-level metadata to the images which will help with classifying them. In the Enrich panel, select the eiffel-tower folder, and in its dc.Title field type Eiffel Tower. Since this metadata is assigned at folder level, it is inherited as dc.Title metadata by all the images in the folder.When setting folder-level metadata like this, the default setting in GLI is to produce a popup window alerting you to the fact that the assigned metadata will be assigned
to all files and sub-folders contained in the selected folder. For this collection, this is what we want, so press OK for the action to proceed.Note: if you prefer this popup not to appear each time you assign folder-level metadata, there is a tick-box in the lower left-hand corner of the popup window ("do not show this warning again") that allows you to control this. If you choose to suppress the popup, then it can be turned back on through File → Preferences and then clicking on the Warnings tab. The various options are alphabetically sorted, with the option that controls this popup: "About to add folder level metadata".
- Now select each of the remaining folders of images in turn, and assign the appropriate values for their dc.Title: Parc de Luxembourg, Musée d'Orsay and Panthéon district.
- Go to the Design panel. In the Browsing Classifiers section, choose AZCompactList from the Select classifier to add dropdown box and press <Add Classifier...>. In the configuration dialog that appears, set the metadata field to dc.Title and tick the buttonname option and set its value to locations. This will create a classifier labelled locations that groups all images under Eiffel Tower into one bookshelf and similarly creates bookshelves for the other 3 categories. Click <OK> to close the plugin configuration dialog.
- Now go to the Create panel and press Build Collection.
- Preview the collection and click the Locations tab in the web browser. Expand the bookshelf icons displayed in the web browser to see thumbnail pictures of the photos gathered under the displayed metadata heading. Explore further, and click on a thumbnail photo or two to view larger versions of the photos in the document view.
Extracting embedded metadata
Each of these image files has metadata embedded in it—including GPS data—generated by the smartphone when the photo was taken. We can extract this metadata when the collection is built, and in particular, make use of the GPS metadata to provide map-based views of the collection to the user.In the Document Plugins section of the Design panel, go down to the Select plugin to add: and choose the EmbeddedMetadataPlugin. Press the <Add Plugin...> button, and then click <OK> to add it to the plugin list. Select this plugin in the list, then use the <Move Up> button to shift it upwards until it comes just after the GreenstoneXMLPlugin.
- Go to the Create panel and press <Build Collection>.
- Now go to the Enrich panel, expand the eiffel-tower folder and select the first image. Scroll down to see the metadata extracted during the building process. Among the extracted metadata, you will find several pieces of Latitude and Longitude metadata, which we will be taking advantage of shortly: ex.Latitude, ex.Longitude, ex.LatShort, and ex.LngShort.
Adding in a map view to browsing
Greenstone has a map view, based on the Google Maps API, that can make use of this location metadata. The map view can be controlled to appear in different parts of the interface: as part of a collection's search results page; when browsing the collection; when viewing a document. For this view to be operational in a Greenstone, it is necessary for the collection to index the GPS metadata.
- In the Search Indexes section of the Design panel, press the <New Index> button. Scroll down and tick the box for ex.LatShort and press <Add Index> to create an index on it. In like manner, create an index on ex.Latitude. Then another on ex.LngShort. And finally one on ex.Longitude.
- Now go to the Create panel and press <Build Collection>.
- To enable the map, go to the Format Features section of the Format panel. Select the browse format feature in the drop down for Choose Feature. In the editor below it, enter the following format statement above the documentNode template:
<gsf:option name="mapEnabled" value="true" />
- Also in the Choose Feature section, select the searchType feature. Add raw to the comma-separated searchType list.
By adding the <gsf:option name="mapEnabled" value="true" /> statement
to the browse format feature, all of the classifiers built will have the map
view enabled. It is also possible to activate the map view on individual classifiers,
and on the search results page by adding the mapEnabled statement to the search
- In the Format panel press <Preview Collection>, and click on the new browsing classifier (locations) and then click on a bookshelf icon (not the plus next to each bookshelf icon). The page that opens up shows a Google map, with the locations of the images in the collection pinpointed on it. The map view can also scroll through all the images, locating each place and associated image in turn.
Adding in a map view to a document
To activate a map view when viewing the document, go to the Format Features section of the Format panel, and select the display format feature in the Choose Feature dropdown. In the editor below, enter the following format statement after the line <gsf:option name="TOC" value="true" />:
<gsf:option name="mapEnabled" value="true" />
- If you want the map to display nearby documents, then add the mapEnabled option to the search format feature also.
- Still in the Format panel press the <Preview Collection> button, browse or search to locate a document, and then view the document. The page that opens up shows a Google map, shows the location of the document (where the photo was taken), in addition to the screen-sized photo.