wiki:CodeSnippets

Version 2 (modified by jbirch, 16 years ago) ( diff )

--

Introduction

This is a central location for users to share useful code snippets for FDO. Make sure that you read the FDO Cookbook chapter of the FDO Developers Guide as well.

Snippets

Creating New Snippets

Page Title

When creating a new page, please use the following convention for the page location:

CodeSnippets/YourPageName

for example: CodeSnippets/AJAXViewerEventHooking

This is to ensure that pages are easily found via the TitleIndex, and may allow for an automated index at some point.

You can easily do this by editing this CodeSnippets page, copying another entry, and then modifying it to fit your title. Once you have saved the page, you will have a handy link to follow to edit your own snippet.

Header Section

Please include the following on every Code Snippet page. It allows users to easily navigate the page, and if they come from a search engine they can get to the snippets index more easily.

[[PageOutline]]

This page is an FDO Code Snippet.  Visit the CodeSnippets page to view more!

Syntax Highlighting

Trac has some really cool syntax highlighting built into it. The FDO Trac doesn't have all of these set up, but at least the C++ one works (add #!cpp to the top of your code block), and does a reasonable job with typical FDO code highlighting. For example:

while (reader.ReadNext()) {
        extentAsByteArr = reader.GetExtent();
      // if extent type is dynamic and no geometries have been added
      // the extent can be null
      if (extentAsByteArr != null)
      {
        geom = geomFactory.CreateGeometryFromFgf(extentAsByteArr);
        extentAsText = geom.Text;
      }
      else
      {
        extentAsText = "No extent found";
      }
}

Please use this where possible to make your inline examples more readable.

Note: See TracWiki for help on using the wiki.