GeoTools

OSGeo

Showing posts with label docs. Show all posts
Showing posts with label docs. Show all posts

Friday, November 16, 2012

FeatureCollection cleanup

The FeatureCollection cleanup proposal is now complete. The first batch of work went into the GeoTools 8.0 release, this second phase removes several methods from FeatureCollection. These methods were not widely implemented, and as a result not adopted by client code.
Upgrade instructions are available: As part of this work Andrea provided an extensive review of the existing FeatureCollection implementations and a number of utility methods have been introduced to make working with features easier:
  • DataUtilities.visit( FeatureCollection, FeatureVisitor, ProgerssListener )
  • DataUtilities.bounds( FeatureCollection ) // Already existed
  • DataUtilities.bounds( FeatureIterator )
  • DataUtilities.count( FeatureCollection )
  • DataUtilities.count( FeatureIterator )
  • DataUtilities.close( Iterator )
  • DataUtilities.first( SimpleFeatureCollection ): SimpleFeature
  • DataUtilities.first( FeatureCollection ): F
  • DataUtilities.list( FeatureCollection ): List  // Already existed 
  • DataUtilities.list( FeatureCollection, int ): List
  • DataUtilities.iterator( FeatureIterator ): Iterator // also Closable 
  • DataUtilities.collectionCast( FeatureCollection ): Collection
For additional information, and an overview of the FeatureCollection implementations please review the detailed change proposal.
If you cannot make the transition today:
  • A milestone 9.0-M0 release has been deployed to maven. 
  • To switch your maven pom.xml over to 9.0-M0:
    <properties>
       <geotools.version>9.0-M0</geotools.version>
    </properties>
    ...
    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt-main</artifactId>
      <version>${geotools.version}</version>
    </dependency>
    
  • You can use this milestone release as a rest area until you have time to upgrade.
One of the joys of working on a large stable project such as GeoTools is the gradual change of pace, and the careful planning that goes into keeping projects working together:
  • The initial GeoTools 2.0 rewrite provided a clear FeatureResults API acting in a fashion similar to a JDBC ResultSet.
  • GeoTools 2.1 introduced FeatureCollection as a superclass of FeatureResults, bringing in the java.util.Collection methods being removed today. This was motivated by an amusing Bring Back FeatureCollection rant from our founder James MacGill - well we tried James and it was a bad idea.
  • The transition to Java 5 forced us to remove direct use of the java.util.Collection interface, however we kept the methods for backwards compatibility. It was too easy to introduce a resource leak with the Java 5 for-each syntax:
for( Feature feature : featureCollection ){
    System.out.println( feature.getID() );
}
  • With todays change GeoTools programs are ready for the Java 7 try-with-resource syntax as shown below:
try( FeatureIterator iter=featureCollection.features() ){
   while( iter.hasNext() ){
        Feature feature = iter.next();
        System.out.println( feature.getID() );
   }
}

Monday, October 3, 2011

GeoTools FOSS4G 2011

GeoTools had a great showing at the recent FOSS4G Conference (Free and Open Source Software for Geospatial) which was held in Denver last month. Presentations at the conference highlighted how the hard work of the GeoTools developers is paying off in terms of the wide adoption of the library, and its use in some amazing applications.

There were a number of talks directly on GeoTools this year:

GeoServer as always provides an excellent example of GeoTools in action:

These presentations are a great way to see what is possible with GeoTools. Often it is easier to understand the capabilities of the library by seeing it in use, and both the State of GeoServer and Advanced cartographic map rendering presentations are excellent examples of this.

A special mention to GeoScript which is building a bridge between GeoTools functionality and a range of scripting languages, with the emphasis on providing a concise and simple API:

Geomajas had a strong showing this year with several presentations plus a hands-on workshop:

We are hoping to attract more direct participation of Geomajas developers in the GeoTools project (for now we just have a welcome page).

Did I miss you project in this roll call? Contribute a welcome page to the GeoTools User Guide in order to be included in promotional activities!

GeoTools Codesprint

Finally a big thanks to those taking part in the GeoTools code sprint!
  • Looked into why sorting is turned off for MemoryDataStore!
  • Put together a Process Tutorial (OctagonalEnvelope in 5 lines!)
  • A couple great volunteers (shown below) updated the Eclipse Quickstart to work with the included copy of Maven
  • Looked into Neo4j - but got stuck on AGPL license (grrr!)

Tuesday, May 3, 2011

New User Guide

Today brings to an end a three month journey in "porting" the User Guide from from the GeoTools wiki over to the same Sphinx build system we use for our website. This was a journey fraught with peril (having to reinstall my machine from backup halfway through), epic in length (at one point 1100 00 words but I have not looked in a bit) and ultimately rewarding:

GeoTools User Guide

It is hard to express the extent of this change; much of the content has been rewritten; and more importantly updated to reflect the latest GeoTools. More importantly the "update" will be *sticky* as code examples are pulled from live source code; which is compiled as part of the publication process.
Rather than try and offer a summery - here is a round up of blog posts and tweets linking into the new docs:
Thanks to those who assisted in this process:
  • Michael Bedward for continuing to inspire on the geotools user list; a large portion of the documentation has been assembled based on his email over the years. He has also been great with ongoing reviews and feedback.
  • Justin DeOlivera for taking time to set up the sphinx build system; and also to the company he works for (OpenGeo) for providing the build box which publishes the documentation after every commit
  • Lee Breisacher for launching into GeoTools development with a review of the AbstractDataStore tutorial. This was the original tutorial for GeoTools 2, first start in DocBook (just like PostGIS docs)
The wiki used to hold the user guide will be shut off by CodeHaus in the coming weeks; thanks to CodeHaus for allowing us the extra breathing room.

Tuesday, September 21, 2010

GeoSpatial for Java Workbooks available

It has now been a couple of weeks since foss4g and life is returning to normal. Thanks to everyone who contributed to a great experience. Part of that great experience was the workshop program; facilities were excellent; that staff helpful and due to a bit of scheduling fun the GeoSpatial for Java workshop was packed.

Justin and Jody were on hand for an intensive hands-on workshop "GeoSpatial for Java". This workshop offered an introduction to GIS concepts for Java developers - which is a really nice introduction since you can try out ideas and see how they work using running code.

The workshop materials have been published here:

These workbooks are detailed step by step instructions written in a "code first" style. This allows you to carefully go through the steps required to produce runnable code. If you have any questions about the concepts or ideas covered you can continue reading for the background information.

Geospatial for Java
View more presentations from jgarnett.

This tutorial information has been gathered up in the "sphinx" documentation system; and pulls directly from Java source code examples that are built as part of our GeoTools nightly build.

Thanks to Justin for his help in setting up the sphinx nightly build; and if anyone is good at sphinx "rst2pdf" I would love to get this content out in printable form.

Friday, April 30, 2010

A faster, better GeoTools 2.7

GeoTools 2.7.x is current development branch (or "trunk"). Consider this a sneak peak of some of the ideas that are taking shape for the future.

First up we have speed. One of the common use-cases we have on the geotools-gt2-users email list is displaying a Map in a Java Swing application. Still it is nice to see something; especially when learning. With this in mind we have recast our initial introduction tutorials to be a bit more visual.

Out of the box GeoTools focus on providing a standard compliant SLD rendering engine. This engine is not specific to display - and actually never loads data into memory (it simply streams it off disk onto the screen).

In the interest of performance Andrea has donated a wrapper that will cache data in memory (storing it in a JTS spatial index).

File file = JFileDataStoreChooser.showOpenFile("shp", null);

FileDataStore store = FileDataStoreFinder.getDataStore(file);

FeatureSource featureSource = store.getFeatureSource();


CachingFeatureSource cache = new CachingFeatureSource(featureSource);


MapContext map = new DefaultMapContext();

map.setTitle("Using cached features");

map.addLayer(cache, null);


JMapFrame.showMap(map);


For more details please see the updated (and aptly named) Quickstart. This functionality has been back ported to 2.6.x and we are soliciting feedback (and test cases) from users.

Returning to 2.7 we have two great usability improvements:
  • For the longest time we have had a Query interface and a DefaultQuery implementation. These have been combined making code examples just that much readable.
  • We introduced the use of Generics to support application schema work. While we now have a happy team working on application schema; it did impact readably.
    Specifically FeatureCollection < SimpleFeatureType, SimpleFeature > gets tiring.
    Introducing SimpleFeatureCollection to the rescue.
With this in mind a couple of recent proposals have allowed us to write the following:


SimpleFeatureSource source = dataStore.getFeatureSource( typeName );

Query query = new Query( typeName, filter, attributes );

SimpleFeatureCollection features = source.getFeatures(query);


It is all good!

If you are using maven switch to 2.7-SNAPSHOT to try out these improvements today; we will issue a milestone release laster this month.