On Thu, Apr 28, 2011 at 11:36 AM, Jason Ferguson <[email protected]>wrote:
> Here are some questions that have been on my mind since I started
> using Geotools, and was wondering about the design decisions in two
> areas:
>
> 1. Why does a FeatureCollection require me to call the features()
> method to get a FeaturesIterator, instead of a regular Iterator so
> that it could be used in a for-each loop?
>
I had hoped the documentation answered this (since it provides the same
information repeatedly):
http://docs.geotools.org/latest/userguide/library/main/collection.html
Because the for-each loop was introduced; we had to remove iterator() :-(
We need to ensure that the iterator is closed once it is no longer in use;
as many of the feature collections
are backed by a live data stream (or database result set).
>
> 2. Why does the SimpleFeature interface not implement getAttribute(String
> name)? Currently, this has to be cast to SimpleFeatureImpl to read string
> attributes in a Shapefile?
>
I think you can do what you want; let me check:
-
http://docs.geotools.org/latest/userguide/library/main/feature.html#accessing
You can get access to simple feature content using both:
- values (is this what you wanted?)
Object value = feature.getAttribute( "name" )
- or as a property (ie name / value pair)
Property property = feature.getProperty( "name" );
String name = property.getName();
Object value = property.getValue();
In answering you email I think we could have SimpleFeature.getProperty(
"name" ) explictly return an Attribute (as SimpleFeature does not support
associations).
This isn't meant as a criticism, only a chance to increase my own knowledge.
>
And a chance for me to test the documentation; do the above documentation
links work for you?
I will try and add your question to the FAQ :-)
>
> Jason
>
>
> ------------------------------------------------------------------------------
> WhatsUp Gold - Download Free Network Management Software
> The most intuitive, comprehensive, and cost-effective network
> management toolset available today. Delivers lowest initial
> acquisition cost and overall TCO of any competing solution.
> http://p.sf.net/sfu/whatsupgold-sd
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users