/** * Find the generic geometry type of the feature collection. Simple method - find the 1st non null * geometry and its type is the generic type. returns 0 - all empty/invalid <br> * 1 - point <br> * 2 - line <br> * 3 - polygon <br> * * @param fc feature collection containing tet geometries. */ int findBestGeometryType(FeatureCollection fc) { Geometry geom; for (Iterator i = fc.iterator(); i.hasNext(); ) { geom = ((Feature) i.next()).getGeometry(); if (geom instanceof Point) { return 1; } if (geom instanceof MultiPoint) { return 1; } if (geom instanceof Polygon) { return 3; } if (geom instanceof MultiPolygon) { return 3; } if (geom instanceof LineString) { return 2; } if (geom instanceof MultiLineString) { return 2; } } return 0; }
/** * look at all the data in the column of the featurecollection, and find the largest string! * * @param fc features to look at * @param attributeNumber which of the column to test. */ int findMaxStringLength(FeatureCollection fc, int attributeNumber) { int l; int maxlen = 0; Feature f; for (Iterator i = fc.iterator(); i.hasNext(); ) { f = (Feature) i.next(); l = f.getString(attributeNumber).length(); if (l > maxlen) { maxlen = l; } } return maxlen; }