private void parseInput() { inputType = TYPE_UNKNOWN; int fcSrcSize = fcSrc.size(); int fcDestSize = fcDest.size(); // error - # geoms must match if (fcSrcSize != fcDestSize) { parseErrMsg = "Control point collections must be same size"; return; } // for now only handling pair of geoms to define control points if (fcSrcSize != 1) { parseErrMsg = "Control points must be a single geometry"; return; } geomSrc[0] = ((Feature) fcSrc.iterator().next()).getGeometry(); geomDest[0] = ((Feature) fcDest.iterator().next()).getGeometry(); if (geomSrc[0].getClass() != geomDest[0].getClass()) { parseErrMsg = "Control points must be LineStrings"; return; } // for now only handling LineStrings if (!(geomSrc[0] instanceof LineString)) { parseErrMsg = "Control points must be LineStrings"; return; } parseLines(); return; }
/** * 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; }