[JPP-Devel] SVN: [6590] core/trunk/src/com/vividsolutions/jump/workbench/ui/toolbox
Revision: 6590 http://sourceforge.net/p/jump-pilot/code/6590 Author: edso Date: 2020-10-09 12:43:10 + (Fri, 09 Oct 2020) Log Message: --- deprecated ToolboxPlugIn introduce ToolboxPlugInV2, mainly a cleaner version of the above with easier error handling Modified Paths: -- core/trunk/src/com/vividsolutions/jump/workbench/ui/toolbox/ToolboxPlugIn.java Added Paths: --- core/trunk/src/com/vividsolutions/jump/workbench/ui/toolbox/ToolboxPlugInV2.java Modified: core/trunk/src/com/vividsolutions/jump/workbench/ui/toolbox/ToolboxPlugIn.java === --- core/trunk/src/com/vividsolutions/jump/workbench/ui/toolbox/ToolboxPlugIn.java 2020-10-08 15:08:04 UTC (rev 6589) +++ core/trunk/src/com/vividsolutions/jump/workbench/ui/toolbox/ToolboxPlugIn.java 2020-10-09 12:43:10 UTC (rev 6590) @@ -47,6 +47,11 @@ import com.vividsolutions.jump.workbench.plugin.PlugInContext; import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller; +import jdk.internal.misc.InnocuousThread; + +/** + * @deprecated future implementations should use {@link ToolboxPlugInV2} instead + */ public abstract class ToolboxPlugIn extends AbstractPlugIn implements CheckBoxed { // just one toolbox instance for plugins switching the same toolbox private static HashMap toolboxMap = new HashMap(); Added: core/trunk/src/com/vividsolutions/jump/workbench/ui/toolbox/ToolboxPlugInV2.java === --- core/trunk/src/com/vividsolutions/jump/workbench/ui/toolbox/ToolboxPlugInV2.java (rev 0) +++ core/trunk/src/com/vividsolutions/jump/workbench/ui/toolbox/ToolboxPlugInV2.java 2020-10-09 12:43:10 UTC (rev 6590) @@ -0,0 +1,98 @@ +/* + * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI + * for visualizing and manipulating spatial features with geometry and attributes. + * + * Copyright (C) 2003 Vivid Solutions + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * For more information, contact: + * + * Vivid Solutions + * Suite #1A + * 2328 Government Street + * Victoria BC V8T 5G5 + * Canada + * + * (250)385-6040 + * www.vividsolutions.com + */ + +package com.vividsolutions.jump.workbench.ui.toolbox; + +import java.util.HashMap; + +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JComponent; + +import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn; +import com.vividsolutions.jump.workbench.plugin.CheckBoxed; +import com.vividsolutions.jump.workbench.plugin.EnableCheck; +import com.vividsolutions.jump.workbench.plugin.PlugInContext; + +/** + * pretty much {@link ToolboxPlugIn} but cleaned up plus propagating errors + * from initializeToolbox() -> getToolbox() -> execute() making implementations + * easier and more failsafe + */ +public abstract class ToolboxPlugInV2 extends AbstractPlugIn implements CheckBoxed { + // just one toolbox instance for plugins switching the same toolbox + private static HashMap toolboxMap = new HashMap(); + + /** + * @return the toolbox for this plug-in class. + */ + public ToolboxDialog getToolbox() throws Exception{ +String name = getName(); +ToolboxDialog toolbox = (ToolboxDialog) toolboxMap.get(name); +if (toolbox == null) { + // allow implementation to return null or throw errors + toolbox=initializeToolbox(); + toolbox.finishAddingComponents(); + toolboxMap.put(name, toolbox); +} +return toolbox; + } + + protected abstract ToolboxDialog initializeToolbox() throws Exception; + + /** + * Toolbox subclasses can override this method to implement their own + * behaviour when the plug-in is called. Remember to call super.execute to + * make the toolbox visible. + */ + public boolean execute(PlugInContext context) throws Exception { +reportNothingToUndoYet(context); +ToolboxDialog tb = getToolbox(); +tb.setVisible(!tb.isVisible()); +return true; + } + + public EnableCheck getEnableCheck() { +return new EnableCheck() { + // switch checkbox menu item on/off, depending on current visibility + public String check(JComponent component) { + do not initialize toolbox here, it delay
[JPP-Devel] SVN: [6591] core/trunk/src/org/openjump/core/ui/plugin/customize/ PythonToolsPlugIn.java
Revision: 6591 http://sourceforge.net/p/jump-pilot/code/6591 Author: edso Date: 2020-10-09 12:44:57 + (Fri, 09 Oct 2020) Log Message: --- find resourcefiles by classpath, which works in distro as well when multiple extension dirs are defined in devel environment extend ToolboxPluginV2 for better error handling Modified Paths: -- core/trunk/src/org/openjump/core/ui/plugin/customize/PythonToolsPlugIn.java Modified: core/trunk/src/org/openjump/core/ui/plugin/customize/PythonToolsPlugIn.java === --- core/trunk/src/org/openjump/core/ui/plugin/customize/PythonToolsPlugIn.java 2020-10-09 12:43:10 UTC (rev 6590) +++ core/trunk/src/org/openjump/core/ui/plugin/customize/PythonToolsPlugIn.java 2020-10-09 12:44:57 UTC (rev 6591) @@ -37,6 +37,8 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.io.File; +import java.net.URL; +import java.nio.file.Paths; import java.util.Properties; import javax.swing.Icon; @@ -50,6 +52,9 @@ import org.python.core.PySystemState; import com.vividsolutions.jump.I18N; +import com.vividsolutions.jump.JUMPException; +import com.vividsolutions.jump.workbench.JUMPWorkbench; +import com.vividsolutions.jump.workbench.WorkbenchContext; import com.vividsolutions.jump.workbench.plugin.EnableCheck; import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory; import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck; @@ -59,11 +64,11 @@ import com.vividsolutions.jump.workbench.ui.images.IconLoader; import com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller; import com.vividsolutions.jump.workbench.ui.toolbox.ToolboxDialog; -import com.vividsolutions.jump.workbench.ui.toolbox.ToolboxPlugIn; +import com.vividsolutions.jump.workbench.ui.toolbox.ToolboxPlugInV2; import bsh.util.JConsole; -public class PythonToolsPlugIn extends ToolboxPlugIn { +public class PythonToolsPlugIn extends ToolboxPlugInV2 { private static final ImageIcon icon = IconLoader .icon("famfam/application_python.png"); @@ -77,7 +82,35 @@ FeatureInstaller.getInstance().addMainMenuPlugin(this, new String[] { MenuNames.CUSTOMIZE }); } - protected void initializeToolbox(ToolboxDialog toolbox) { + protected ToolboxDialog initializeToolbox() throws Exception { +WorkbenchContext context = JUMPWorkbench.getInstance().getContext(); + +// setup the interpreter +ClassLoader classLoader = context.getWorkbench() +.getPlugInManager().getClassLoader(); +Properties preProperties = new Properties(System.getProperties()); +String homepath = preProperties.getProperty("user.home"); + +String sep = File.separator; + +// find files via classloader which works even when lib/ext/ is not -plug-in-dir +String startupfile, startuppath, extPath, libPath = ""; + +URL res = classLoader.getResource("jython/startup.py"); +if (res == null) + throw new JUMPException("missing jython/startup.py in classpath."); +File file = Paths.get(res.toURI()).toFile(); + +startupfile = file.getPath(); +// make sure folder string end w/ path separator as startup.py does assume they do +startuppath = file.getParentFile().getPath() + sep; +extPath = file.getParentFile().getParent() + sep; +libPath = file.getParentFile().getParentFile().getParent() + sep; + +// files found? let's get ready to rumble +ToolboxDialog toolbox = new ToolboxDialog(context); +toolbox.setTitle(getName()); + final JConsole console = new JConsole(); console.setPreferredSize(new Dimension(450, 120)); console @@ -89,33 +122,14 @@ toolbox.setIconImage(icon.getImage()); -// setup the interpreter -ClassLoader classLoader = toolbox.getContext().getWorkbench() -.getPlugInManager().getClassLoader(); -Properties preProperties = new Properties(System.getProperties()); -String homepath = preProperties.getProperty("user.home"); -File empty = new File(""); -String sep = File.separator; -// -- [sstein] - old */ -/* - * String WORKING_DIR = empty.getAbsoluteFile().getParent() + sep; String - * jarpathX = new String(WORKING_DIR + "lib"); String startuppathX = new - * String(WORKING_DIR + "lib" + sep + "ext" + sep + "jython" + sep); - */ -// -- [sstein] - new -File plugInDirectory = toolbox.getContext().getWorkbench() -.getPlugInManager().getPlugInDirectory(); -String jarpath = plugInDirectory.getPath(); -String startuppath = plugInDirectory.getPath() + sep + "jython" + sep; - Properties postProperties = new Properties(); postProperties.put("python.home", homepath); postProperties.put("python.path", startuppath); PySystemState.initialize(preProperties, postProperties, new String[] { "" }, classLoader); -String startupfile = startuppath + "startup.py"; -PySystemState.add_extdir(jarpath); -
Re: [JPP-Devel] 6506 loading raster test
hey Rob, any news wrt. the below? ..ede On 10/2/2020 14:33, edgar.sol...@web.de wrote: > no problemo Rob, got a day job still ;) > > please try the latest snapshot r6563+ with Peppe's change. > > additionally please try your routine with r6564 but instead of Sextante image > use the "Open->File->(Select your tifs, click Next)->(keep Use same settings > for *.tif enabled, Select *Buffered Image (Commons Imaging)*, Click > Finished). this merely is a rendering test, raster tools will not work on it. > please comment on speed, memory usage and overall performance incl. bugs. > > thanks.. ede > > On 10/2/2020 0:28, Roberto Rossi wrote: >> Hi Ede, >> sorry for the late answer. >> I tested the release 6562, and I continue to have the visualization problems >> in the continuous file (just after having used 500-600 Mb of Memory, for >> example loading the big SHP and some rasters). >> The continuos raster are all the ones called DTMxx and Depitxx, Aspect, Slope >> What I see is something like this: >> >> While I should see something like this: >> >> I noticed that the discrete raster (like CN, rasterizza, UsoSuolo), when >> this problem arises, become white instead than something like this: >> >> >> >> Roberto >> >> Il 30/09/2020 13:10, edgar.sol...@web.de ha scritto: >>> On 9/29/2020 16:41, Roberto Rossi wrote: Il 29/09/2020 15:00, edgar.sol...@web.de ha scritto: > Rob, > > does that happen with all files or can you pinpoint a specific > layer/image? Ede, I noticed it for the continuos raster ad Digital terrain models (DTM), slope, hillshade. >>> Rob, >>> >>> can you point out which files in your RasterRefrontolo test set are DTM or >>> the other kinds files? i am actually not GIS-guy at all ;) >>> >>> also. please try snapshot r6562 wrt. the "discrete rendering look" issue. >>> >>> thx ..ede >> >> >> > > > > ___ > Jump-pilot-devel mailing list > Jump-pilot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel > ___ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
[JPP-Devel] SVN: [6592] core/trunk/src/org/openjump/core/rasterimage
Revision: 6592 http://sourceforge.net/p/jump-pilot/code/6592 Author: ma15569 Date: 2020-10-09 12:55:48 + (Fri, 09 Oct 2020) Log Message: --- remove building of double arrays in raster creation. This saves a lot of memory and helps OJ to save larger files (850 Gb) Modified Paths: -- core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java core/trunk/src/org/openjump/core/rasterimage/sextante/rasterWrappers/GridExtent.java Modified: core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java === --- core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java 2020-10-09 12:44:57 UTC (rev 6591) +++ core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java 2020-10-09 12:55:48 UTC (rev 6592) @@ -17,7 +17,6 @@ import org.openjump.core.rasterimage.RasterImageIO; import org.openjump.core.rasterimage.sextante.rasterWrappers.GridCell; import org.openjump.core.rasterimage.sextante.rasterWrappers.GridExtent; -import org.openjump.core.rasterimage.sextante.rasterWrappers.GridRasterWrapper; import org.openjump.core.ui.util.LayerableUtil; import com.vividsolutions.jts.geom.Coordinate; @@ -45,7 +44,6 @@ */ - public class RasterizeAlgorithm { private static Double noData = -9.0D; @@ -57,31 +55,19 @@ private static WritableRaster raster; private static FeatureCollection featureCollection; private static String attrName; -private static double[][] values; -private static Envelope env; +private static Envelope envelope; public RasterizeAlgorithm(Envelope limitEnvelope, FeatureCollection fCollection, String attributeName, double CellSize) throws OutOfMemoryError, Exception { featureCollection = fCollection; - env=limitEnvelope; + envelope=limitEnvelope; attrName=attributeName; cellSize=CellSize; m_Extent= new GridExtent(); - m_Extent.setCellSize(CellSize, CellSize); - double minX = limitEnvelope.getMinX(); - double minY = limitEnvelope.getMinY(); - double maxX = limitEnvelope.getMaxX(); - double maxY = limitEnvelope.getMaxY(); - m_Extent.setXRange(minX, maxX); - m_Extent.setYRange(minY, maxY); - m_iNX = m_Extent.getNX(); + m_Extent.setValuesAndRaster(CellSize, CellSize, limitEnvelope, noData); + m_iNX = m_Extent.getNX(); m_iNY = m_Extent.getNY(); - values= new double[m_iNX][m_iNY]; - for (int x = 0; x < m_iNX; x++){ - for (int y = 0; y < m_iNY; y++){ - values[x][y]=noData; - } - } + raster = m_Extent.getRaster(); } @@ -91,20 +77,21 @@ // The code below simplefies the access to the the method /** * Convert a feature collection to a raster according to a numeric attribute, a limit envelope - * and a cell size. Feature are first selected by the envelope and merged according + * and a cell size. Feature are first chosen according if they overlap the limit envelope. Then they are merged according * the chosen attribute, then converted to a grid + * Methods saveToFile(File) and getRaster() and getEnvelope() allows to save to file + * or to get raster and envelope for further manipulations */ public void process() throws OutOfMemoryError, Exception { - -FeatureCollection fc2 = getFeaturesOverlappingEnvelope(); + + FeatureCollection fc2 = getFeaturesOverlappingEnvelope(); FeatureCollection fc3 = unionByAttributeValue(fc2); if (!LayerableUtil.isPolygonalLayer(fc3)) { RasterizeAlgorithm.RasterizeAdbToolbox(fc3); } else { - RasterizeAlgorithm.RasterizeSextante(fc3); + RasterizeAlgorithm.RasterizeSextante(fc3); } - -} + } /** * Method to save results to a TIFF file @@ -126,45 +113,20 @@ private static void RasterizeAdbToolbox(FeatureCollection fCollection) throws OutOfMemoryError, Exception { - final Iterator iter = fCollection.iterator(); - while (iter.hasNext()) { -Feature feature = (Feature) iter.next(); + final Iterator it = fCollection.iterator(); + while (it.hasNext()) { +Feature feature = (Feature) it.next(); try { dValue = Double.parseDouble(feature.getAttribute(attrName).toString()); } catch (Exception e) { dValue = noData;
[JPP-Devel] SVN: [6593] core/trunk/src/org/openjump/core/rasterimage/algorithms/ RasterizeAlgorithm.java
Revision: 6593 http://sourceforge.net/p/jump-pilot/code/6593 Author: ma15569 Date: 2020-10-09 15:24:04 + (Fri, 09 Oct 2020) Log Message: --- few extra notes on java doc Modified Paths: -- core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java Modified: core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java === --- core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java 2020-10-09 12:55:48 UTC (rev 6592) +++ core/trunk/src/org/openjump/core/rasterimage/algorithms/RasterizeAlgorithm.java 2020-10-09 15:24:04 UTC (rev 6593) @@ -44,6 +44,7 @@ */ + public class RasterizeAlgorithm { private static Double noData = -9.0D; @@ -76,7 +77,7 @@ // b) From Sextante, almost faster but still not working with ponts and linestrings // The code below simplefies the access to the the method /** - * Convert a feature collection to a raster according to a numeric attribute, a limit envelope + * process a feature collection to create a raster according to a numeric attribute, a limit envelope * and a cell size. Feature are first chosen according if they overlap the limit envelope. Then they are merged according * the chosen attribute, then converted to a grid * Methods saveToFile(File) and getRaster() and getEnvelope() allows to save to file ___ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
Re: [JPP-Devel] 6506 loading raster test
Here I am, sorry for he delay. I tested the 6589 release. After having loaded 2 shapefile (the bigger shp is 95 Mb), I load the rasters, the 3rd o 4th raster loaded, present the visualization problems: This how the Digital Terrain Model appears This how it should appear I noticed that with the same dataset the release 1.15 at first (when the zoom is pointing to the whole raster) shows the Digital Terrain Model all white, when you zoom in draws the raster correctly. Do you need the log file? Roberto Il 09/10/2020 14:48, edgar.sol...@web.de ha scritto: hey Rob, any news wrt. the below? ..ede On 10/2/2020 14:33, edgar.sol...@web.de wrote: no problemo Rob, got a day job still ;) please try the latest snapshot r6563+ with Peppe's change. additionally please try your routine with r6564 but instead of Sextante image use the "Open->File->(Select your tifs, click Next)->(keep Use same settings for *.tif enabled, Select *Buffered Image (Commons Imaging)*, Click Finished). this merely is a rendering test, raster tools will not work on it. please comment on speed, memory usage and overall performance incl. bugs. thanks.. ede On 10/2/2020 0:28, Roberto Rossi wrote: Hi Ede, sorry for the late answer. I tested the release 6562, and I continue to have the visualization problems in the continuous file (just after having used 500-600 Mb of Memory, for example loading the big SHP and some rasters). The continuos raster are all the ones called DTMxx and Depitxx, Aspect, Slope What I see is something like this: While I should see something like this: I noticed that the discrete raster (like CN, rasterizza, UsoSuolo), when this problem arises, become white instead than something like this: Roberto Il 30/09/2020 13:10, edgar.sol...@web.de ha scritto: On 9/29/2020 16:41, Roberto Rossi wrote: Il 29/09/2020 15:00, edgar.sol...@web.de ha scritto: Rob, does that happen with all files or can you pinpoint a specific layer/image? Ede, I noticed it for the continuos raster ad Digital terrain models (DTM), slope, hillshade. Rob, can you point out which files in your RasterRefrontolo test set are DTM or the other kinds files? i am actually not GIS-guy at all ;) also. please try snapshot r6562 wrt. the "discrete rendering look" issue. thx ..ede ___ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel ___ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel