Hi Stefan, > a few questions and a bug report: > > (i) What does "dynamic" attribute, actually mean? > I understand it will be re-calculated when I change a value in its > source (as with Excel). But what happens when I save (and re-load) the > layer? Dynamic attributes are only dynamic during the session. I don't know a standard way to save dynamic attributes in a gis format like shapefile. Formulas could be saved instead of values as strings (but it would be lost for other gis) or maybe in the project file (jmp) like styles. > (ii) The field called "CALC", is a i18n key error? ... and should be > "Attribute Name"? I believe... I intentionally made it short because it is generally changed by the user and added to the end of the new layer name. But if you don't like, I can change ;-) > (iii) What does "Test Expression do"? Sorry, there is a bug (already fixed). I was waiting some feedbak before a new commit. It evaluates a few features to check there is no syntax error before applying to the whole layer. > (iv) I did load the bdgs layer from the OJ test data. Then I had in the > expression field I think you set the atribute type as DOUBLE, not STRING as I get this error with DOUBLE but no error with STRING (which is the normal behaviour). By the way, the error is not catched in this case so I have something to fix.
Beanshell let the user write anything he wants and it will be hard to prevent any syntax error Thanks for the quick feedback, Michaël > >> "Nb Pts = " + GEOMETRY.getNumPoints() > with the attribute type declared as String. > When I pressed "Test Expression", I got this error thrown: > > Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: > For input string: "Nb Pts = 5" > at > sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1222) > at java.lang.Double.valueOf(Double.java:475) > at java.lang.Double.<init>(Double.java:567) > at > org.openjump.core.ui.plugin.tools.BeanshellAttributeCalculatorPlugIn$BeanshellExpression.evaluate(BeanshellAttributeCalculatorPlugIn.java:350) > at > org.openjump.core.ui.plugin.tools.BeanshellAttributeCalculatorPlugIn.checkExpression(BeanshellAttributeCalculatorPlugIn.java:450) > at > org.openjump.core.ui.plugin.tools.BeanshellAttributeCalculatorPlugIn.access$1(BeanshellAttributeCalculatorPlugIn.java:429) > at > org.openjump.core.ui.plugin.tools.BeanshellAttributeCalculatorPlugIn$1.actionPerformed(BeanshellAttributeCalculatorPlugIn.java:194) > > > stefan > > Am 14.10.12 10:37, schrieb Michaël Michaud: >> Hi, >> >> I just committed a new attribute calculator plugin, adding very powerful >> capabilities to OJ. >> (available from r3048 in >> http://sourceforge.net/projects/jump-pilot/files/OpenJUMP_snapshots/) >> I have used this plugin for a long time for personal use, but extensive >> tests and true dynamic >> capability were still missing to make it part of OpenJUMP. >> Hopefully, it is now good enough to be part of the distribution, let me >> know... >> >> You'll find the plugin in >> *Tools > Edit Attributes >**Beanshell Attribute Calculator* >> >> *It can calculate a new attribute value using a beanshell script*, which >> makes it >> possible to use all java math functions + all jts geometry functions + >> all java string >> functions etc. Here are some examples you can test : >> >> get a uppercase version of attribute NAME >> NAME.toUpperCase() >> >> replace null values by 'Unknown' string from NAME attribute : >> NAME == null ? "Unknown" : NAME >> >> convert an 'orientation' attribute from radian (counterclockwise) to >> degree (clockwise) >> -Math.toDegrees(orientation) >> >> or with geometry, compute the circularity indice of polygonal features >> / 4*Math.PI*(GEOMETRY.area/(GEOMETRY.length*GEOMETRY.length)) >> >> /Of course, you need to know a bit of java/beanshell, but there are some >> snippets in >> the right panel to help beginners and to avoid typos (double click to >> copy an attribute >> name or a function name). >> >> *The second news is that it can calculate attributes _dynamically_* >> To do that, I had to modify some core classes (like FeatureSchema and >> BasicFeature) >> I found a way to modify these classes so that it should not break >> compatibility, >> but it's hard to say it's 100% safe without more extensive test. Please, >> report any >> bug. >> To define a dynamic attribute, check the dynamic checkbox. It will add a >> "read-only" >> attribute (grayed in editable mode) which will be evaluated "on-demand". >> You can test it with the same scripts as above. This time, changing the >> source >> attribute will automatically change the derived attribute, a bit like >> formulas in an >> excel spreadsheet. >> >> There are a few pre-defined functions to be able to use the selection >> or another dataset in the script. I will give some examples later. >> >> Dynamic attributes may be used for other purposes (maybe to link a layer to >> an external table dynamically). Not sure it can be done without >> modification, >> but I had also this idea in mind. Let's see. >> >> Have fun with OpenJUMP >> >> Michaël >> >> >> / >> / >> >> >> ------------------------------------------------------------------------------ >> Don't let slow site performance ruin your business. Deploy New Relic APM >> Deploy New Relic app performance management and know exactly >> what is happening inside your Ruby, Python, PHP, Java, and .NET app >> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >> http://p.sf.net/sfu/newrelic-dev2dev >> >> >> >> _______________________________________________ >> Jump-pilot-devel mailing list >> Jump-pilot-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel >> > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > > ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel