Customization

exportGge plugin is coupled to modified "tables" and "query" coreplugins
based on cartoweb version mentionned in "install.txt". This might change in the
future if possible. exportGge supports different EPSG projections
(for the mapfile, not for the individual layers). For now exportGge won't
perform well on layers with a great amount of features (=shapes).

To use exportGge in your own project you need to:

  • use EPSG syntax for declaring the projection of your mapfile
  • set persistentQueries = false in YOUR_PROJECT/client_conf/query.ini
  • copy demoCW3gge "tables" and "query" coreplugins inside the "coreplugins" directory of your project. If they allready exist then you need to merge them with the demoCW3gge ones.
  • copy demoCW3gge "exportGge" plugin in your projects "plugins" directory
  • copy demoCW3gge/client_conf/exportGge.ini to YOUR_PROJECT/client_conf/ and modify the "fileName" value if you want that generated KML files come with a different file name
  • copy demoCW3gge "cartoclient.tpl" template file to your project "templates" directory or insert :

{if $exportgge_active|default:''}
<script type="text/javascript" src="/kml/{r plugin=exportGge type=js}exportGge.js{/r}">
</script> <style type="text/css">
A#googleearth_icon {
ldelim:
}
UNKNOWN {
r: gfx plugin=exportGge
}
googleearth.png {
r:
}
UNKNOWN {
r: gfx plugin=exportGge
}
googleearth_act.png {
r:
}
UNKNOWN {
r: gfx plugin=exportGge
}
googleearth_act.png {
r:
}</style><a href="javascript:void(0);" onclick="exportgge_headerlocation()" id="googleearth_icon"></a>{/if}

wherever you want the google earth icon to appear in your templates.

  • deploy your project again using command line
  • make a php cw3setup.php --clean --project YOUR_PROJECT

exportGge uses smarty templates to customize the rendering of layers in geoRSS and KML. Since 0.92 each layer can have it's own template but it is also possible to specify the template dynamically by setting the value of the "ggetpl" parameter in the URL.
Templates for geoRSS rendering are found under exportGge/templates/dataformat/georss .
Templates for KML rendering are found under exportGge/templates/dataformat/kml .
By default exportGge will use georss.tpl, georss_point.tpl, georss_line.tpl and georss_polygon.tpl for geoRSS rendering and kml.tpl, kml_point.tpl, kml_line.tpl and kml_polygon.tpl for KML rendering.
The following example illustrates the flexibility for rendering different layers in KML in different ways ( same things count for geoRSS). Let's suppose we want to render the lake layer ( CartoWeb layer name ) which is a polygon layer differently then the other polygon layers. To do this we just need to create a file called kml_lake_polygon.tpl. Once created this template will be used instead of kml_polygon.tpl. It might also be that on certain pages we want all polygons layers to be rendered differently. By passing for example ggetpl=mytemplate in the url, exportGge will try to use templates with _mytemplate in the template name. For the lake layer with ggetpl=mytemplate in the URL, exportGge will first look for : kml_mytemplate_lake_polygon.tpl. If the file can't be found it will try to use kml_mytemplate_polygon.tpl . If still not available it will try kml_lake_polygon.tpl and finally drop to kml_polygon.tpl, the default template. The naming convention is the same for line and point templates and also for the main template kml.tpl.
Having a look under exportGge/templates/dataformat/ might help to understand the trick.

 

geoJSON rendering is not using templates and is generated directly in the exportGge plugin client Class.

 

For KML:
<Networklink> may be changed in exportGge/templates/dataformat/kml/wms.tpl
<GroundOverlay> may be changed in exportGge/templates/dataformat/kml/groundoverlay.tpl
wms.tpl and groundoverlay.tpl are globally used and can't be specific to a layer by renaming them. KML styles may be defined in exportGge/templates/dataformat/kml/kml.tpl

 

The way data is accessed in the templates tries to be close to the
Mapscript API syntax (ex : $line->numpoints, $shape->line($i) .. )
but the objects are no mapscript objects.

Differences between default demoCW3 and demoCW3gge:

  • persistentQueries is set to false in client_conf/query.ini
  • maxResults and ignoreQueryThreshold are set to 100000000 in server_conf/demoCW3gge/mapquery.ini
  • TRANSPARENCY is set to 100 in demoCW3gge.map for layers that support queries