Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Array index out of bounds exception

2012-02-10
2013-06-05
  • Hi, i receive the following error message when I try this postgis datastore query:

    select ST_NPoints(ST_SimplifyPreserveTopology(the_geom,100)) As  np100_stillsquare
    FROM (SELECT ST_Buffer('POINT(1 3)', 10,12) As the_geom) As foo;

    The details are:
    java.lang.ArrayIndexOutOfBoundsException: -1
    at com.vividsolutions.jump.feature.BasicFeature.getAttribute(BasicFeature.java:99)
    at com.vividsolutions.jump.feature.AbstractBasicFeature.getGeometry(AbstractBasicFeature.java:163)
    at com.vividsolutions.jump.feature.FeatureDataset.getEnvelope(FeatureDataset.java:92)
    at com.vividsolutions.jump.feature.FeatureDataset.query(FeatureDataset.java:116)
    at com.vividsolutions.jump.feature.FeatureCollectionWrapper.query(FeatureCollectionWrapper.java:138)
    at com.vividsolutions.jump.workbench.ui.renderer.LayerRenderer.layerToFeaturesMap(LayerRenderer.java:162)
    at com.vividsolutions.jump.workbench.ui.renderer.FeatureCollectionRenderer.createRunnable(FeatureCollectionRenderer.java:55)
    at com.vividsolutions.jump.workbench.ui.renderer.LayerRenderer.createRunnable(LayerRenderer.java:87)
    at com.vividsolutions.jump.workbench.ui.renderer.RenderingManager.render(RenderingManager.java:207)
    at com.vividsolutions.jump.workbench.ui.renderer.RenderingManager.render(RenderingManager.java:187)
    at com.vividsolutions.jump.workbench.ui.LayerViewPanel.layerChanged(LayerViewPanel.java:388)
    at com.vividsolutions.jump.workbench.model.LayerManager$3.run(LayerManager.java:432)
    at com.vividsolutions.jump.workbench.ui.GUIUtil.invokeOnEventThread(GUIUtil.java:582)
    at com.vividsolutions.jump.workbench.model.LayerManager.fireLayerEvent(LayerManager.java:396)
    at com.vividsolutions.jump.workbench.model.LayerManager.fireLayerChanged(LayerManager.java:430)
    at com.vividsolutions.jump.workbench.model.LayerManager.fireLayerChanged(LayerManager.java:454)
    at com.vividsolutions.jump.workbench.model.Category.add(Category.java:132)
    at com.vividsolutions.jump.workbench.model.LayerManager.addLayerable(LayerManager.java:164)
    at com.vividsolutions.jump.workbench.ui.plugin.datastore.AbstractAddDatastoreLayerPlugIn$1.run(AbstractAddDatastoreLayerPlugIn.java:40)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.WaitDispatchSupport$2.run(Unknown Source)
    at java.awt.WaitDispatchSupport$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(Unknown Source)
    at java.awt.Dialog.show(Unknown Source)
    at java.awt.Component.show(Unknown Source)
    at java.awt.Component.setVisible(Unknown Source)
    at java.awt.Window.setVisible(Unknown Source)
    at java.awt.Dialog.setVisible(Unknown Source)
    at com.vividsolutions.jump.workbench.ui.task.TaskMonitorManager.execute(TaskMonitorManager.java:114)
    at org.openjump.core.ui.plugin.AbstractUiPlugIn.actionPerformed(AbstractUiPlugIn.java:136)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.AbstractButton.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    The same query executes without error in pgAdmin.
    Any help would be greatly appreciated as I frequently encounter this error. I am using OJ 1.4.2, postgres 9.3 and postgis 1.5 under Windows 7 pro, 64-bit
    Meny thanks
    Bill

     
  • I forgot to add that adding st_asbinary as in the following:

    select ST_NPoints(st_asbinary(ST_SimplifyPreserveTopology(the_geom,100))) As  np100_stillsquare FROM (SELECT ST_Buffer('POINT(1 3)', 10,12) As the_geom) As foo;

    makes no difference, in any case I am using Openjump 1.4.2

    Bill

     
  • Hi,

    Sorry for late answer.
    Your query does not work because it only return an int (number of points in your geometry).
    A query should always return a geometry column to be transformed to a FeatureCollection.
    Try
    SELECT
      ST_SimplifyPreserveTopology(the_geom,100) as geom,
      ST_NPoints(ST_SimplifyPreserveTopology(the_geom,100)) As np100_stillsquare
    FROM (SELECT ST_Buffer('POINT(1 3)', 10,12) As the_geom) As foo;

    Michaël

     
  • Many thanks Michael, your answer was more than worth the short waiting, it also explains why I was getting that error message so frequently….
    Many thanks again, OpenJump in conjunction with Postgis is absolutely great.
    Bill

     
  • Thanks for positive feedback.
    I just added a feature request to get a more comprehensive error message in this case.

    Michaël