I would like to submit the following patch (based on the trunk) to allow 
the "link" field in the GeoRSS feeds to be templated with a file name 
link.ftl. This allows the link to be stored as a field in the database 
and then used as the link in the georss feed. Thanks, David

Index: 
src/wms/src/main/java/org/geoserver/wms/featureinfo/FeatureTemplate.java
===================================================================
--- 
src/wms/src/main/java/org/geoserver/wms/featureinfo/FeatureTemplate.java    
(revision 16782)
+++ 
src/wms/src/main/java/org/geoserver/wms/featureinfo/FeatureTemplate.java    
(working copy)
@@ -120,6 +120,26 @@
      }

      /**
+     * Executes the link template for a feature writing the results to an
+     * output stream.
+     * <p>
+     * This method is convenience for:
+     * <code>
+     * link( feature, new OutputStreamWriter( output ) );
+     * </code>
+     * </p>
+     *
+     * @param feature The feature to execute the template against.
+     * @param output The output to write the result of the template to.
+     *
+     * @throws IOException Any errors that occur during execution of 
the template.
+     */
+    public void link(SimpleFeature feature, OutputStream output)
+        throws IOException {
+        link(feature, new OutputStreamWriter(output, 
Charset.forName("UTF-8")));
+    }
+
+    /**
       * Executes the description template for a feature writing the 
results to an
       * output stream.
       * <p>
@@ -153,6 +173,19 @@
      }

      /**
+     * Executes the link template for a feature writing the results to a
+     * writer.
+     *
+     * @param feature The feature to execute the template against.
+     * @param writer The writer to write the template output to.
+     *
+     * @throws IOException Any errors that occur during execution of 
the template.
+     */
+    public void link(SimpleFeature feature, Writer writer) throws 
IOException {
+        execute(feature, feature.getFeatureType(), writer, 
"link.ftl",null);
+    }
+
+    /**
       * Executes the description template for a feature writing the 
results to a
       * writer.
       *
@@ -182,6 +215,21 @@
      }

      /**
+     * Executes the link template for a feature returning the result as a
+     * string.
+     *
+     * @param feature The feature to execute the template against.
+     *
+     * @throws IOException Any errors that occur during execution of 
the template.
+     */
+    public String link(SimpleFeature feature) throws IOException {
+        caw.reset();
+        link(feature, caw);
+
+        return caw.toString();
+    }
+
+    /**
       * Executes the description template for a feature returning the 
result as a
       * string.
       *
Index: src/wms/src/main/java/org/geoserver/wms/georss/AtomUtils.java
===================================================================
--- src/wms/src/main/java/org/geoserver/wms/georss/AtomUtils.java    
(revision 16782)
+++ src/wms/src/main/java/org/geoserver/wms/georss/AtomUtils.java    
(working copy)
@@ -85,18 +85,22 @@

      //TODO: use an html based output format
      public static String getEntryURL(WMS wms, SimpleFeature feature, 
WMSMapContent context){
-        String nsUri = feature.getType().getName().getNamespaceURI();
-        String nsPrefix = wms.getNameSpacePrefix(nsUri);
+        try {
+            return featureTemplate.link(feature);
+        } catch (IOException ioe){
+            String nsUri = feature.getType().getName().getNamespaceURI();
+            String nsPrefix = wms.getNameSpacePrefix(nsUri);

-        HashMap<String,String> params = new HashMap<String,String>();
-        params.put("format", "application/atom+xml");
-        params.put("layers",  nsPrefix + ":" + 
feature.getType().getTypeName());
-        params.put("featureid", feature.getID());
+            HashMap<String,String> params = new HashMap<String,String>();
+            params.put("format", "application/atom+xml");
+            params.put("layers",  nsPrefix + ":" + 
feature.getType().getTypeName());
+            params.put("featureid", feature.getID());

-        return ResponseUtils.buildURL(context.getRequest().getBaseUrl(),
-             "wms/reflect",
-             params,
-             URLType.SERVICE);
+            return 
ResponseUtils.buildURL(context.getRequest().getBaseUrl(),
+                "wms/reflect",
+                params,
+                URLType.SERVICE);
+        }
      }

      public static String getEntryURI(WMS wms, SimpleFeature feature, 
WMSMapContent context){

-- 

David R Robison
Open Roads Consulting, Inc.
103 Watson Road, Chesapeake, VA 23320
phone: (757) 546-3401
e-mail: [email protected]
web: http://openroadsconsulting.com
blog: http://therobe.blogspot.com
book: http://www.xulonpress.com/bookstore/bookdetail.php?PB_ISBN=9781597816526



This email communication (including any attachments) may contain confidential 
and/or privileged material intended solely for the individual or entity to 
which it is addressed.
If you are not the intended recipient, please delete this email immediately.


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to