Configuring the Spatial Portal - AtlasOfLivingAustralia/documentation GitHub Wiki
We try to describe some extra steps in order to customize and adapt the Spatial service, like changing the menu items, base layers, WMS servers, and the skin.
The preferred way to change the spatial bounding box area in using the la-toolkit, but if you prefer to do it manually:
- open config in
/data/spatial-hub/config/spatial-hub-config.yml - see the default_areas section and specify your own coordinates, name, etc. These can be configured via some ansible var. Then
service tomcat7 restart(or 8 or 9). You can see the result by clicking on "Tools -> Add area report".
Add your own WMS servers - (see presetWMSServers in the config in /data/spatial-hub/config/spatial-hub-config.yml)
If your json request ends with a 401-Unauthorized error, add your server host to the allowproxy line in spatial-hub-config.yml:
allowProxy:
server:"spatial.l-a.site;data.auscover.org.au;data.auscover.org.au:80;geoserver.imos.org.au;www.ga.gov.au/gis;geofabric.bom.gov.au"
- create a custom version of portal.gsp (as portal-yoursite.gsp)
- put that custom skin file in
/data/spatial-hub/views/layouts/portal-yoursite.gsp - point to that file in
/data/spatial-hub/config/spatial-hub-config.ymlwith eg.skin.layout=portal-yoursite - restart spatial and see how looks like
See the spatial-hub README for skinning options for the Spatial Portal.
Some messages in spatial-hub hava [email protected] on them. You can overwrite them adding to /var/opt/atlas/i18n/spatial-hub/messages.properties:
292=Please send feedback to <a href="mailto:[email protected]">[email protected]</a>
540=An error occurred. Please try again and if the same error occurs, send an email to [email protected] and include the URL to this page, the error message and what steps you performed that triggered this error.
And to other languages, like: /var/opt/atlas/i18n/spatial-hub/messages_es.properties:
292=Por favor, envíe sus comentarios a <a href\="mailto\:[email protected]">[email protected]</a>
540=Se ha producido un error. Por favor, inténtelo de nuevo y si ocurre el mismo error, envíe un correo electrónico a [email protected] e incluya la URL a esta página, el mensaje de error y los pasos que realizó y que desencadenaron este error.
The area report can be customized as described on the README of spatial-service in other to translate it, or to change the header and footer,...
But to make some queries work you need to setup your portal species lists in order to work properly, like threatened species, invasive species, iconic species and migratory species, and add the drID of the list to the `AreaReportDetails.json'.
Three features of the spatial portal (spatial-hub) use the field set in gazField (ansible variable gaz_field, default cl2123):
-
Tools > Nearest locality: lists the closest places to a point, using
GET <spatial-service>/ws/objects/<gazField>/<lat>/<lng>?limit=10. -
Area report > Gazetteer Points: counts the places inside the area, using
/ws/objects/inarea/<gazField>. -
Add to Map > Areas > Gazetteer polygon: this option only appears when
gazFieldis set. Its search covers every field with namesearch enabled.
- It must be a contextual layer of points, one point per place (town, village, locality). spatial-service only returns objects whose
GeometryType(the_geom) = 'POINT', so a polygon layer (for example municipalities) returns nothing in "Nearest locality". - It must be in WGS84 (EPSG:4326).
- It needs a column with the place name, and optionally one for the description (for example the province).
- Set the field's
snameto the name column andsdescto the description column. Turn namesearch on and intersect off: intersecting points makes no sense.
FieldCreation in spatial-service does not support point layers yet (checked in 2.1.5, 3.1.0 and develop). It casts every geometry to Polygon, so a point layer fails on its first object. No objects are inserted, and the task still reports finished. You can confirm this with:
SELECT count(*) FROM objects WHERE fid = '<FIELD_ID>'; -- 0Until this is fixed, do the following:
-
Add the layer and its field as usual (see Adding Layers). Keep the shapefile as
<spatial data dir>/layer/<layer name>.shp. -
Load the points into the
objectstable the wayFieldCreationwould, inlayersdbon the spatial-service host:# add -oo ENCODING=ISO-8859-1 (or whatever it is) if the .dbf has no .cpg file; ogr2ogr exits with 0 even if the COPY fails, so check stderr sudo -u postgres ogr2ogr -f PostgreSQL PG:dbname=layersdb <spatial data dir>/layer/<layer name>.shp \ -nln tmp_gazetteer -overwrite -lco GEOMETRY_NAME=the_geom -nlt POINT -t_srs EPSG:4326
BEGIN; DELETE FROM objects WHERE fid = '<FIELD_ID>'; INSERT INTO objects (pid, name, "desc", fid, the_geom, namesearch, area_km) SELECT nextval('objects_id_seq'::regclass), coalesce(<name column>, ''), coalesce(<desc column>, ''), '<FIELD_ID>', ST_SetSRID(the_geom, 4326), true, 0 FROM tmp_gazetteer WHERE the_geom IS NOT NULL AND coalesce(<name column>, '') <> ''; -- the degenerate bbox FieldCreation gives to points UPDATE objects SET bbox = 'POLYGON((' || st_x(the_geom) || ' ' || st_y(the_geom) || ',' || st_x(the_geom) || ' ' || st_y(the_geom) || ',' || st_x(the_geom) || ' ' || st_y(the_geom) || ',' || st_x(the_geom) || ' ' || st_y(the_geom) || ',' || st_x(the_geom) || ' ' || st_y(the_geom) || '))' WHERE fid = '<FIELD_ID>'; UPDATE fields SET sname = '<name column>', sdesc = '<desc column>', namesearch = true, "intersect" = false WHERE id = '<FIELD_ID>'; DROP TABLE tmp_gazetteer; COMMIT;
-
Set
gaz_field = <FIELD_ID>in the[spatial-hub:vars]of your inventory, so that a redeploy keeps it. Alternatively setgazField: <FIELD_ID>in/data/spatial-hub/config/spatial-hub-config.yml. Then restart spatial-hub. -
Check
<spatial-service>/ws/objects/<FIELD_ID>/<lat>/<lng>?limit=3: it returns the three closest places withdistance(m) anddegrees. Then try Tools > Nearest locality in the portal.
Warning: saving that field again from the spatial-service admin (Manage Layers > field) re-runs FieldCreation, which deletes the field's objects. Run step 2 again afterwards. It is worth keeping step 2 as a script or ansible task so that it can be repeated. GBIF Spain, for example, loads the IGN municipalities gazetteer this way.
Currently the spatial portal does not handle different kinds of projections well. If you encounter issues with adding layers, you should try to change them to use WGS84 projection before adding them.