Hi Martin, Thanks for the hints, Now the question is : do we prefer speed or robustness in case of weird polygons Or should we add options to our shapefile reader : In this case, weird polygons are polygons where some shells are described as if they were holes... > There's a few fixes required: > 1. if only one shell is present, do not run the PIP code, but simply > assign the holes to the shell. (This fix has been made in the current > GeoTools PolygonHandler code, and could be copied from there) Currently, we check if holes are inside a shell with a PIP test and in case a hole don't find any shell, it is considered itself as a shell. Not sure how often it happens and how arcgis would read such a polygon. Also I don't remember what happens if we let holes which happen to be out of the shell in a Polygon. Would need to create such a shapefile to test, as I don't think I have one. > 2. this can be extended to checking for only one *candidate* shell (a > candidate shell is one whose envelope contains the hole envelope). This > code is not yet developed. Same case as above. If a single candidate shell is found, do we still make a PIP test to be sure the hole is included ? Currently, we do. > 3. the code uses ArrayList.indexOf. This is inefficient, since it uses > equals(), which does a full equality comparison. Instead, an iterator > and == should be used instead (code below) Thanks, will test that as soon as I could create a monstruous polygon. > The performance improvement from just #1 was dramatic - reading a 1M > feature shapefile went from over 1000 s to 32 s. Wow, your polygon should be really complex ! Will do some test and I'll report my results on this list.
Michaël > > ---------------------------- > > PolygonHandler change: > > ((ArrayList) holesForShells.get(findIndex(shells, > minShell))).add(testHole); > > > /** > * Finds a object in a list. Should be much faster than indexof > * > * @param list > * @param o > * @return > */ > private static int findIndex(ArrayList list, Object o) > { > int n = list.size(); > for (int i = 0; i< n; i++) { > if (list.get(i) == o) > return i; > } > return -1; > } > > > > ------------------------------------------------------------------------------ > For Developers, A Lot Can Happen In A Second. > Boundary is the first to Know...and Tell You. > Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! > http://p.sf.net/sfu/Boundary-d2dvs2 > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > ------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2 _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel