CGXP

In recent versions of GeoMapFish, CGXP has been replaced by ngeo to propose a more modern interface to the end user. It is still possible to keep using CGXP though.

Use the CGXP interface

If you are currently upgrading your application and want to keep using CGXP, the following changes are required.

index.html and viewer.js files need to be renamed to desktop.html and desktop.js respectively.

git mv <package>/templates/index.html <package>/templates/desktop.html
git mv <package>/templates/viewer.js <package>/templates/desktop.js

Then apply the following changes in the <package>/templates/desktop.html file:

- % for script in Merger.from_fn(jsbuild_cfg, root_dir=jsbuild_root_dir).list_run(['app.js', 'lang-%s.js' % lang]):
+ % for script in Merger.from_fn(jsbuild_cfg, root_dir=jsbuild_root_dir).list_run(['desktop.js', 'lang-%s.js' % lang]):

- <script type="text/javascript" src="${request.static_url('<package>_geoportal:static/build/app.js')}"></script>
+ <script type="text/javascript" src="${request.static_url('<package>_geoportal:static/build/desktop.js')}"></script>
...
- <script type="text/javascript" src="${request.route_url('viewer', _query=extra_params)}"></script>
+ <script type="text/javascript" src="${request.route_url('desktop.js', _query=extra_params)}"></script>

Finally apply the following change in jsbuild/app.cfg.mako:

- [app.js]
+ [desktop.js]
  ...
  include =
    CGXP/tools/tools.js
+   GeoExt/Lang.js
    ...

  [edit.js]
  ...
  include =
    CGXP/tools/tools.js
+   GeoExt/Lang.js
    ...

  [routing.js]
  ...
  include =
    CGXP/tools/tools.js
+   GeoExt/Lang.js
    ...

To configure the build of the interface you should set the CGXP_INTERFACES (and the NGEO_INTERFACES) in your project makefile, e.g.:

CGXP_INTERFACES = desktop edit routing
NGEO_INTERFACES = mobile

You will also need to enable the CGXP checker. To do so, add this to your project vars file:

vars:
    ...
    checker:
        ...
        lang:
            files: [cgxp]
        ...
update_paths:
...
- checker.lang.files

externalWFSTypes does not exist anymore so you should remove the following line from <package>/templates/desktop.js

externalWFSTypes: ${externalWFSTypes | n},

Do the following change in the <package>/templates/desktop.html file:

- % if not no_redirect and mobile_url is not None:
+ % if "no_redirect" not in request.params:
  <script>
-     if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
+     var small_screen = window.matchMedia ? window.matchMedia('(max-width: 1024px)') : false;
+     if (small_screen && ((ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch)) {
-         window.location = "${mobile_url}";
+         window.location = "${request.route_url('mobile', _query=dict(request.GET)) | n}";
      }
  </script>
  % endif

The OGC proxy is deprecated because with modern browsers it is not required anymore. You can simply remove the following line in desktop.js, edit.js and routing.js (in <package>/templates).

OpenLayers.ProxyHost = "${request.route_url('ogcproxy') | n}?url=";

Add the new oldPassword field: You should add the following line in desktop.html, edit.html and routing.html (in <package>/templates).

  <input id="password" name="password" type="password" autocomplete="on"/>
+ <input id="oldPassword" name="oldPassword" type="password" />
  <input id="newPassword" name="newPassword" type="password" />

More information about how to configure the interface when using CGXP can be found in Advanced configuration examples.

Back to the ngeo interface

Follow the above instructions if you want to use ngeo instead of CGXP.

git rm <package>/templates/desktop.html
git rm <package>/templates/desktop.js

Remove the related section in the jsbuild/app.cfg.mako file.

Update the interface in your <package>/__init__.py file by removing these following lines if one of them exists:

add_interface(config, "desktop", [INTERFACE_TYPE_CGXP])
# or
add_interface(config)

To add an ngeo interface, see also Adding a new user interface.

If you remove all the CGXP interface, remove the vars.checker.lang.files from your project vars file, and the checker.lang.files from your update_paths.

Adding features in CGXP

Adding a feature requires adding a plugin (CGXP plugin) to the user interface’s viewer. It may also require additional steps, like adding and populating tables in the database.

A c2cgeoportal project may define multiple viewers. By default a project includes two viewers: the main viewer and the editing viewer. The main viewer is defined in the <package>/templates/viewer.js file, while the editing viewer is defined in the <package>/templates/edit.js file. Each viewer includes a number of plugins by default; adding/removing features involve adding/removing plugins to/from the viewer.

See http://docs.camptocamp.net/cgxp/2.2/lib/plugins.html for the list of available CGXP plugins.

Enabling FullTextSearch plugin

Enabling the full-text search feature involves adding a FullTextSearch plugin to the viewer, and creating and populating a dedicated table in the database.

The viewer should include a FullTextSearch plugin for the text search feature to be available in the user interface.

See the FullTextSearch API doc for the list of options the plugin can receive.

The main viewer includes a FullTextSearch plugin by default.

The Print plugin

Adding the print feature to a c2cgeoportal project involves adding a cgxp.plugins.Print plugin to the viewer, and configuring the MapFish Print.

The viewer should include a Print plugin for the print feature to be available in the user interface.

See the Print API doc for the list of options the plugin can receive.

The main viewer includes a Print plugin by default.