Hi, Here after, the script with one more line which should solve the envelop problem.
About performance, it would be interesting to compare with a pure java solution (probably much faster). This is difficult to estimate script efficiency because it includes time spent in the script itself (I think beanshell loop are quite slow) and time spent to execute pure JTS code (which is generally very fast). I'll include this script in beantools, as it is a good example for those who want to learn scripting with OpenJUMP. Michaël //Inverse longitude and latitude - Michael Michaud 2011-11-16 import com.vividsolutions.jump.workbench.model.Layer; // Create the filter public CoordinateFilter switchLatLon = new CoordinateFilter() { void filter(Coordinate coord) { t = coord.x; coord.x = coord.y; coord.y = t; } }; // apply for (Layer lyr : wc.layerNamePanel.selectedLayers) { for (Feature f : lyr.featureCollectionWrapper.features) { f.geometry.apply(switchLatLon); f.geometry.geometryChanged(); } Layer.tryToInvalidateEnvelope(lyr); } // refresh wc.layerViewPanel.repaint(); > Tested with > > - linestrings, count 153742, total count of vertises 1 million, processing > rate 7300 vertises/second > - polygons, count 362, total count of vertises 2 million, processing rate > 9500 vertises/second > > Computer is a 2.8 GHz single core Pentium from year 2004. Java memory > consumption does not raise during the process at all. I consider this script > is effective enough for any production. > > -Jukka- > > Rahkonen Jukka wrote: >> Hi, >> >> The tool does the job fast and obviously correctly. Course >> speed estimate is 10000 vertises per second but I need to >> test with some bigger datasets later. Tool baffles something >> in OJ, you cannot zoom to layer when it is flipped and it is >> having perhaps some invisible style or something. It is >> possible to see that converted features exist by opening the >> attribute table, selecting and zooming to selected. The >> selection shows highlighted as usual. After saving to disk >> and opening the result everything is naturally OK. >> >> Thanks for the nice little tool which is once again just what >> I like in OpenJUMP: light, fast, gives correct result and >> even it is simple, such tool probably does not exist in other >> open source GIS. Perhaps soon will, but OJ was the first. >> >> -Jukka Rahkonen- >> >>> -----Alkuperäinen viesti----- >>> Lähettäjä: Michaël Michaud [mailto:michael.mich...@free.fr] >>> Lähetetty: 15. marraskuuta 2011 2:04 >>> Vastaanottaja: OpenJump develop and use >>> Aihe: Re: [JPP-Devel] Tool for swithing x and y coordinates >>> of features >>> >>> Hi Jukka, >>> >>>> After this introduction I wonder if it could be possible to >>> convert the whole layer with OpenJUMP so that the result >>> would keep all the attributes but have all the coordinates in >>> reversed x and y coordinate order? So this >>>> LINESTRING (6610069.234 170739.665, 6606506.505 184937.743) >>> would become >>>> LINESTRING (170739.665 6610069.234, 184937.743 >>> 6606506.505). Perhaps it could be handled by some BeanShell >>> or Python tool? >>> Try to copy paste the following script in beantools folder >>> Should switch longitude and latitude for all the selected layers >>> >>> //Inverse longitude and latitude - Michael Michaud 2011-11-15 >>> import com.vividsolutions.jump.workbench.model.Layer; >>> >>> // Create the filter >>> public CoordinateFilter switchLatLon = new CoordinateFilter() { >>> void filter(Coordinate coord) { >>> t = coord.x; >>> coord.x = coord.y; >>> coord.y = t; >>> } >>> }; >>> // apply >>> for (Layer lyr : wc.layerNamePanel.selectedLayers) { >>> for (Feature f : lyr.featureCollectionWrapper.features) { >>> f.geometry.apply(switchLatLon); >>> f.geometry.geometryChanged(); >>> } >>> } >>> // refresh >>> wc.layerViewPanel.repaint(); >>> >>>> -Jukka Rahkonen- >>>> >>> -------------------------------------------------------------- >>> ---------------- >>>> RSA(R) Conference 2012 >>>> Save $700 by Nov 18 >>>> Register now >>>> http://p.sf.net/sfu/rsa-sfdev2dev1 >>>> _______________________________________________ >>>> Jump-pilot-devel mailing list >>>> Jump-pilot-devel@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >>>> >>>> >>> >>> -------------------------------------------------------------- >>> ---------------- >>> RSA(R) Conference 2012 >>> Save $700 by Nov 18 >>> Register now >>> http://p.sf.net/sfu/rsa-sfdev2dev1 >>> _______________________________________________ >>> Jump-pilot-devel mailing list >>> Jump-pilot-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >>> >> -------------------------------------------------------------- >> ---------------- >> RSA(R) Conference 2012 >> Save $700 by Nov 18 >> Register now >> http://p.sf.net/sfu/rsa-sfdev2dev1 >> _______________________________________________ >> Jump-pilot-devel mailing list >> Jump-pilot-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >> > ------------------------------------------------------------------------------ > RSA(R) Conference 2012 > Save $700 by Nov 18 > Register now > http://p.sf.net/sfu/rsa-sfdev2dev1 > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel