Hi! 

Strange situation: 

Step 1: loading tiff file - everything ok 
http://picasaweb.google.com/114734604830173067405/Tst#5452254491194358850
(I zoomed out) 

Step 2: loading shape file, which contains information about another region
- and there are something wrong with a tiff area. It displayed rotated. 
http://picasaweb.google.com/114734604830173067405/Tst#5452254492562585266

Step 3: mapPane.reset() - all displayed fine. 
http://picasaweb.google.com/114734604830173067405/Tst#5452254496206668802

Step 4, 5, etc: another shape file - same situation, tiff again displayed
rotated... 

Situation are very stable. 
I tested it with gt 2.6.1 and 2.6-SNAPSHOT 
Could somebody take a look at my code, maybe there are something wrong? 

private void loadShapeFile(File file) throws IOException,
TransformException, FactoryException { 
        FileDataStore store = FileDataStoreFinder.getDataStore(file); 
        FeatureSource<SimpleFeatureType, SimpleFeature> featureSource =
store.getFeatureSource(); 

        FeatureType schema = featureSource.getSchema(); 
        Class geomType =
schema.getGeometryDescriptor().getType().getBinding(); 
        Style style = null; 
        if (Polygon.class.isAssignableFrom(geomType) 
                        || MultiPolygon.class.isAssignableFrom(geomType)) { 
                style = DrawStyles.getPolygonStyle(); 
                } else if (LineString.class.isAssignableFrom(geomType) 
                        || MultiLineString.class.isAssignableFrom(geomType))
{ 
                style = DrawStyles.getLineStyle(); 
                } else { 
                style = DrawStyles.getPointStyle(); 
        } 

        if (getMapContext().getCoordinateReferenceSystem() == null) { 
                CoordinateReferenceSystem crs =
schema.getCoordinateReferenceSystem(); 
                getMapContext().setCoordinateReferenceSystem(crs); 
        } 

        MapLayer layer = new DefaultMapLayer(featureSource, style); 
        getMapContext().addLayer(layer); 
        getMapContext().setAreaOfInterest(getMapContext().getLayerBounds()); 
} 


private void loadTiffFile(File file) throws IOException, TransformException,
FactoryException, SchemaException { 
        GeoTiffFormat format = new GeoTiffFormat(); 
        if (!format.accepts(file)) { 
                logger.warn("Wrong format of TIF File: " +
file.getAbsolutePath()); 
                JOptionPane.showMessageDialog(null, "wrong TIFF file"); 
                return; 
        } 

        AbstractGridCoverage2DReader rdr = new GeoTiffReader(file); 
        CoordinateReferenceSystem crs =
getMapContext().getCoordinateReferenceSystem(); 
        if (crs == null) { 
                crs = rdr.getCrs(); 
                getMapContext().setCoordinateReferenceSystem(crs); 
        } 

        Style style = DrawStyles.getRasterStyle(); 
        MapLayer layer = new DefaultMapLayer(rdr.read(null), style); 

        getMapContext().addLayer(layer); 
        getMapContext().setAreaOfInterest(getMapContext().getLayerBounds()); 

} 


Thank you! 
Michael
-- 
View this message in context: 
http://n2.nabble.com/loading-shape-file-after-tiff-tp4792761p4792761.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to