I got one more idea Niels.
Make your Collection wrapper; pass the collection into the code that does the
work. But ...
Make sure the wrapper keeps an internal list of all the iterators that have
been created.
After control returns to your code; call a perge() method that goes through and
closes any iterarors that were created.
This is the thinking behind the feature collection perge method you can see in
some of the implementation.
Jody
On 27/01/2011, at 6:29 PM, Niels wrote:
> The alternative is to simply stick with the method of copying the featuring
> to a list in memory.
>
> Like Andrea said earlier, GetFeatureInfo isn't meant to get a long list of
> Features. Usually even just one.
>
> *Normally* there shouldn't be a problem. I guess I'll just give up on trying
> to do it otherwise :/
>
> Niels
>
> On 25/01/11 17:22, Jody Garnett wrote:
>>
>> One thing you can do (do you control the html template that is looping over
>> features?) You could add some logic to check if the iterator implements
>> FeatureIterator and if so close it at the end?
>>
>> Jody
>>
>> On 25/01/2011, at 6:18 PM, Niels wrote:
>>
>>> This works fine, but what is a pity is that in theory there is no absolute
>>> guarantee that the iterator will be closed.
>>> It is possible to do a break inside a collection loop in your template, and
>>> not finishing with the last item. I don't see why you would do that with
>>> features, and it is not done in any of the existing template I think, but...
>>> can we maybe include in the documentation that it is not advised to a break
>>> when looping over the features in a HTML template?
>>>
>>> On 25/01/11 15:34, Niels wrote:
>>>>
>>>>
>>>>> Well one evil thing to do would be to scan through once and collect the
>>>>> feature ids (perhaps you could do that efficiently?); and then make a
>>>>> collection that produces an iterator that fetches the matching feature
>>>>> for each feature id in turn?
>>>>>
>>>>> Not the best idea; but something.
>>>>
>>>> The problem with that would be performance again.
>>>>
>>>> But I'm looking at something now that might work. Textmarker actually has
>>>> its own Iterator model, and what I am doing is implementing that one,
>>>> which wraps a FeatureIterator and automatically closes after the last
>>>> read. Something like this:
>>>>
>>>> public TemplateModel next() throws TemplateModelException {
>>>> if (!hasNext) {
>>>> return null;
>>>> }
>>>> Object o = iterator.next();
>>>> hasNext = iterator.hasNext();
>>>> if (!hasNext) {
>>>> iterator.close();
>>>> }
>>>> return new BeanModel(o, wrapper);
>>>> }
>>>>
>>>> --
>>>> Niels Charlier
>>>>
>>>> Software Engineer
>>>> CSIRO Earth Science and Resource Engineering
>>>> Phone: +61 8 6436 8914
>>>>
>>>> Australian Resources Research Centre
>>>> 26 Dick Perry Avenue, Kensington WA 6151
>>>
>>>
>>> --
>>> Niels Charlier
>>>
>>> Software Engineer
>>> CSIRO Earth Science and Resource Engineering
>>> Phone: +61 8 6436 8914
>>>
>>> Australian Resources Research Centre
>>> 26 Dick Perry Avenue, Kensington WA 6151
>>> ------------------------------------------------------------------------------
>>> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
>>> Finally, a world-class log management solution at an even better price-free!
>>> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
>>> February 28th, so secure your free ArcSight Logger TODAY!
>>> http://p.sf.net/sfu/arcsight-sfd2d_______________________________________________
>>> Geotools-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>>
>
>
> --
> Niels Charlier
>
> Software Engineer
> CSIRO Earth Science and Resource Engineering
> Phone: +61 8 6436 8914
>
> Australian Resources Research Centre
> 26 Dick Perry Avenue, Kensington WA 6151
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel