The answer is actually the subject of the work I did last week on geotools 
trunk (MapContext Refactor) :-)

So on 2.7-SNAPSHOT you can perform an:
- layer instanceof GridCoverageLayer (loaded into memory)
- layer instanceof GridReaderLayer (direct access to disk)

Other then that I did learn what happens on 2.6.x - and the answer is that the 
gridcoverage/gridreader is packaged up as a feature!

There is a method: FeatureUtilities.wrapGridCoverage(coverage)

That creates a feature using the following feature type:

        SimpleFeatureTypeBuilder ftb = new 
SimpleFeatureTypeBuilder(getTypeFactory());
        ftb.setName("GridCoverage");
        ftb.add("geom", Polygon.class, sourceCRS);
        ftb.add("grid", GridCoverage.class);
        SimpleFeatureType schema = ftb.buildFeatureType();

Perhaps you could test for this feature type to detect grid coverage layersin 
2.6.x?


On 17/06/2010, at 2:33 AM, S Dille wrote:

> 
> Hi,
>    I'm pretty new to geotools, so excuse me if this is a really simple
> question, but I have searched everywhere and I can't find an answer:
> 
> How can I determine if a MapLayer object contains a GridCoverage object, and
> if it does contain a GridCoverage, how can I extract it out?   I am adding a
> lot of image layers to a MapContext  using the
> addLayer(AbstractGridCoverage2DReader gridCoverage, Style style) method from
> the DefaultMapContext class.  I am also adding Shapefiles using another some
> of the other overloaded addLayer methods.  When I go back to manipulate a
> layer in which I inserted an image, I am having trouble detecting that it is
> a GridCoverage2D object that is within the MapLayer object.  I can detect if
> they are shapefiles just fine.  Is this something right in front of me that
> I can't see?
> 
> Thanks in advance!
> 
> S Dille
> -- 
> View this message in context: 
> http://osgeo-org.1803224.n2.nabble.com/MapLayer-s-and-GridCoverage2D-s-tp5187306p5187306.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
> 
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate 
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
> lucky parental unit.  See the prize list and enter to win: 
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to