From: Oliver G. <ol...@dr...> - 2009-10-20 20:56:26
|
jody, Thank you for the quick response. I added the line: FeatureSource featureSource = DataUtilities.source(collection); under: //Display FeatureCollection ?? Should I use something like the below to actually display the featureSource or is there a different/better approach? MapContext map = new DefaultMapContext(); map.setTitle("Feature selection tool example"); Style style = createDefaultStyle(); map.addLayer(featureSource, style); mapFrame = new JMapFrame(map); mapFrame.setSize(600, 600); mapFrame.setVisible(true); I think my version of gt-main may be off for the MapDisplayLab (pulled code from above). I get compiliation errors. Currently I'm using gt-main-2.5.4.jar for the example. Do you know what the proper mavin dependency is? ======================================================================= There is a DataUtilities method to make you a feature source from a feature collection; details in the user guide. Jody On 21/10/2009, at 5:35 AM, Oliver Gottwald wrote: Hi, I'm new to giotools and worked my way through a number of the example sets. Ihave the FeatureCollection coordinates defined but now I'm lost on howto define the FeatureSource(i think) and display the coordinates viaswing. Any help on this would be greatly appreciated. Oliver The following is my main: public static void main(String[] args) throws Exception { final SimpleFeatureType TYPE = DataUtilities.createType("Location", "location:Point,name:String"); FeatureCollection collection = FeatureCollections.newCollection(); double lon[] = {123.31, 0}; double lat[] = {48.4, 52}; String nam[] = { "Point1", "Point2", "Point3" }; GeometryFactory factory = JTSFactoryFinder.getGeometryFactory(null); for(int i=0;i<=1;i++){ double longitude = lon[i]; double latitude = lat[i]; String name = nam[i]; Point point = factory.createPoint( new Coordinate(longitude,latitude)); SimpleFeature feature = SimpleFeatureBuilder.build( TYPE, new Object[]{point, name}, null ); collection.add( feature ); } FeatureIterator iterator = collection.features(); try { while (iterator.hasNext()) { SimpleFeature feature = (SimpleFeature)iterator.next(); Geometry geometry = (Geometry) feature.getDefaultGeometry(); Coordinate[] coords = geometry.getCoordinates(); for( int i = 0; i < coords.length; i++ ) { System.out.println(coords[i]); } } } finally { if( iterator != null ){ // YOU MUST CLOSE THE ITERATOR! iterator.close(); } } //Display FeatureCollection ?? } ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! [http://p.sf.net/sfu/devconference_______________________________________________] http://p.sf.net/sfu/devconference_______________________________________________ Geotools-gt2-users mailing list Geo...@li... https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users |