I added a hook for retrieving coordinates but even my example module still uses the MODS datastream. Then it parses the new coordinates.
Perhaps it would be better to use 2 hooks.
The existing hook_islandora_simple_map_get_coordinates(AbstractObject $object)
to extract from new locations (ie. alternate datastreams) and the module provides the MODS XPath one.
Then add a new hook hook_islandora_simple_map_parse_coordinates()
to allow for custom parsing functions.
This new hook would return (for example)
function example_islandora_simple_map_parse_coordinates() {
return array(
'match_regex' => 'a regular expression string to match against this coordinate type',
'function' => 'the name of the function to call with the coordinate(s) as the only argument',
'file' => 'the file in the hook implementing module to find the above function',
'weight' => 'some way to order the parsing so more common types appear first.',
);
}
The called function above would return a string or array of strings with one or more coordinates parsed into decimal coordinates. This would be what my example module should be called for.
So once we get an array of coordinate strings from the old hook_islandora_simple_map_get_coordinates()
, we can run them through the functions returned by the new hook.
Once one matches we use that result (hence the weight
ordering).
Might be overkill, but otherwise if you have multiple coordinate systems used in your MODS, you'll have multiple modules parsing your MODS for each set of XPaths just to get the results and then parse them differently.
What I'm not sure about is should we pass the full array of coordinates to the function and let it parse those it matches on or do loop through the coordinates and process each against all hook implementations in order.
thoughts?