| Wraps a
Feature in the freemarker
BeansWrapper interface
allowing a template to be directly applied to a
Feature or
FeatureCollection .
When a
FeatureCollection is being processed by the template, it is
available via the $features variable, which can be broken down into single features and attributes following this hierarchy:
- features -> feature
- fid (String)
- typeName (String)
- attributes -> attribute
- value (String), a default String representation of the attribute value
- rawValue (Object), the actual attribute value if it's non null, the empty string otherwise
- name (String)
- type (String)
- isGeometry (Boolean)
Example of a template processing a feature collection which will print
out the features id of every feature in the collection.
<#list features as feature>
FeatureId: ${feature.fid}
</#list>
To use this wrapper,use the
Configuration.setObjectWrapper(freemarker.template.ObjectWrapper) method:
//features we want to apply template to
FeatureCollection features = ...;
//create the configuration and set the wrapper
Configuration cfg = new Configuration();
cfg.setObjectWrapper( new FeatureWrapper() );
//get the template and go
Template template = cfg.getTemplate( "foo.ftl" );
template.process( features, System.out );
author: Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org author: Andrea Aime, TOPP |