From: Oliver G. <ol...@dr...> - 2009-11-25 21:40:43
|
Rob, Not sure if the below will help you. I just put out an example with question for: Feature Reference - Better Way? In the following code I drill down from the layer to the Point. In the below line I have "route" set as my attribute name for Point at FeatureCollection creation. Point p = (Point)sf.getAttribute("route"); You could use Point p = (Point)sf.getAttribute(0); but I'm not sure how safe that is. I assume you can swap out MultiLineString for Point on attribute extraction. You may want to look at my example to see how i brought everything together. Oliver @SuppressWarnings("unchecked") public static void getCoordinates(double cx, double cy) throws IOException { MapLayer[] layers = map.getLayers(); for (int i=0; i<layers.length; i++){ FeatureSource<SimpleFeatureType, SimpleFeature> fs =(FeatureSource<SimpleFeatureType, SimpleFeature>)layers[i].getFeatureSource(); FeatureCollection<SimpleFeatureType, SimpleFeature> fc = fs.getFeatures(); Iterator<SimpleFeature> f = fc.iterator(); while (f.hasNext()){ SimpleFeature sf = (SimpleFeature)f.next(); Point p = (Point)sf.getAttribute("route"); double xi = p.getX(); double yi = p.getY(); if(checkFeatureReference(cx,cy,xi,yi)){ System.out.println("x: "+xi+" y: "+yi+" IN FEATURE REFERENCE CIRCLE"); } else { System.out.println("x: "+xi+" y: "+yi+" NOT IN FEATURE REFERENCE CIRCLE"); } } } } -----Original Message----- From: "Heise, Robert" <Rob...@ra...> Sent: Wednesday, November 25, 2009 4:23pm To: "Michael Bedward" <mic...@gm...> Cc: "geo...@li..." <geo...@li...> Subject: Re: [Geotools-gt2-users] Converting MultiLineString to Linestring Thanks for the response. If I am iterating over FeatureCollection, how do I get the MultiLineString from SimpleFeature? Thanks Rob -----Original Message----- From: Michael Bedward [mailto:mic...@gm...] Sent: Tuesday, November 24, 2009 6:29 PM To: Heise, Robert Cc: geo...@li... Subject: Re: [Geotools-gt2-users] Converting MultiLineString to Linestring Hi Robert MultiLineString mls = ... int N = mls.getNumGeometries(); LineString lines[] = new LineString[ N ]; for ( int i = 0; i < N; i++ ) { lines[ i ] = mls.getGeometryN( i ); } Hope this helps, Michael Thisemail and any files transmitted with it are confidential and intendedsolely for the use of the individual or entity to whom they areaddressed. If you have received this email in error please notify thesystem manager. This message contains confidential information and isintended only for the individual named. If you are not the namedaddressee you should not disseminate, distribute or copy this e-mail. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Geotools-gt2-users mailing list Geo...@li... https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users |