gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

Pedestrian: RuntimeException while Saving geometry #3555

Closed benoitgaudou closed 1 year ago

benoitgaudou commented 1 year ago

Describe the bug The launch of the model: Generate pedestrian paths.gaml triggers a RuntimeException.

To Reproduce Steps to reproduce the behavior:

  1. Launch the model Generate pedestrian paths.gaml
  2. Observe the error:
    1 occurence in Simulation 0 at cycle 0: Java error: RuntimeException
    in Simulation 0
    in save open_area type: shp to: '../includes/open area.shp' ;
    RuntimeException: Unexpected Error
    org.geotools.data.shapefile.ShapefileFeatureWriter.write(ShapefileFeatureWriter.java:374)
    org.geotools.data.shapefile.IndexedShapefileFeatureWriter.write(IndexedShapefileFeatureWriter.java:98)
    org.geotools.data.shapefile.ShapefileFeatureWriter.close(ShapefileFeatureWriter.java:229)
    org.geotools.data.shapefile.IndexedShapefileFeatureWriter.close(IndexedShapefileFeatureWriter.java:103)
    org.geotools.data.store.EventContentFeatureWriter.close(EventContentFeatureWriter.java:157)
    org.geotools.data.InProcessLockingManager$1.close(InProcessLockingManager.java:308)
    msi.gaml.statements.save.ShapeSaver.internalSave(ShapeSaver.java:88)
    in save open_area type: shp to: '../includes/open area.shp' ;
    in agent Simulation 0

Desktop (please complete the following information):

lesquoyb commented 1 year ago

Edit: my bad the error is happening here too, I just thought it would crash gama but it actually just prints the error message in eclipse console. I tested with the git version on windows and everything is working fine. So maybe it's platform related, do you have an open area.shp file in your include folder ? If not maybe create one, even if empty, some writing operators are not able to create files themselves.

AlexisDrogoul commented 1 year ago

The actual "complete" exception stack is:

java.lang.RuntimeException: Unexpected Error
    at org.geotools.data.shapefile.ShapefileFeatureWriter.write(ShapefileFeatureWriter.java:374)
    at org.geotools.data.shapefile.IndexedShapefileFeatureWriter.write(IndexedShapefileFeatureWriter.java:98)
    at org.geotools.data.shapefile.ShapefileFeatureWriter.close(ShapefileFeatureWriter.java:229)
    at org.geotools.data.shapefile.IndexedShapefileFeatureWriter.close(IndexedShapefileFeatureWriter.java:103)
    at org.geotools.data.store.EventContentFeatureWriter.close(EventContentFeatureWriter.java:157)
    at org.geotools.data.InProcessLockingManager$1.close(InProcessLockingManager.java:308)
    at msi.gaml.statements.save.ShapeSaver.internalSave(ShapeSaver.java:88)
    at msi.gaml.statements.save.AbstractShapeSaver.save(AbstractShapeSaver.java:106)
    at msi.gaml.statements.save.AbstractShapeSaver.save(AbstractShapeSaver.java:61)
    at msi.gaml.statements.SaveStatement.privateExecuteIn(SaveStatement.java:378)
    at msi.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:46)
    at msi.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:498)
    at msi.gama.runtime.IScope.execute(IScope.java:439)
    at msi.gama.runtime.IScope.execute(IScope.java:410)
    at msi.gaml.statements.AbstractStatementSequence.privateExecuteIn(AbstractStatementSequence.java:69)
    at msi.gaml.architecture.reflex.ReflexStatement.privateExecuteIn(ReflexStatement.java:90)
    at msi.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:46)
    at msi.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:498)
    at msi.gama.runtime.IScope.execute(IScope.java:439)
    at msi.gama.runtime.IScope.execute(IScope.java:410)
    at msi.gaml.architecture.reflex.ReflexArchitecture.init(ReflexArchitecture.java:137)
    at msi.gama.metamodel.agent.AbstractAgent.init(AbstractAgent.java:166)
    at msi.gama.metamodel.agent.MinimalAgent._init_(MinimalAgent.java:258)
    at msi.gama.kernel.simulation.SimulationAgent._init_(SimulationAgent.java:387)
    at msi.gama.metamodel.agent.MinimalAgent.init(MinimalAgent.java:223)
    at msi.gama.runtime.ExecutionScope.init(ExecutionScope.java:590)
    at msi.gama.metamodel.agent.AbstractAgent.schedule(AbstractAgent.java:296)
    at msi.gama.kernel.simulation.SimulationAgent.schedule(SimulationAgent.java:366)
    at msi.gama.kernel.simulation.SimulationPopulation.initSimulation(SimulationPopulation.java:167)
    at msi.gama.kernel.simulation.SimulationPopulation.createAgents(SimulationPopulation.java:121)
    at msi.gama.metamodel.population.IPopulation.createAgents(IPopulation.java:229)
    at msi.gama.kernel.experiment.ExperimentAgent.createSimulation(ExperimentAgent.java:362)
    at msi.gama.kernel.experiment.ExperimentAgent._init_(ExperimentAgent.java:320)
    at msi.gama.metamodel.agent.MinimalAgent.init(MinimalAgent.java:223)
    at msi.gama.kernel.experiment.ExperimentAgent.init(ExperimentAgent.java:338)
    at msi.gama.runtime.ExecutionScope.init(ExecutionScope.java:590)
    at msi.gama.kernel.experiment.ExperimentController.schedule(ExperimentController.java:287)
    at msi.gama.kernel.experiment.ExperimentAgent.schedule(ExperimentAgent.java:385)
    at msi.gama.kernel.experiment.ExperimentPlan.open(ExperimentPlan.java:670)
    at msi.gama.kernel.experiment.ExperimentPlan.open(ExperimentPlan.java:725)
    at msi.gama.kernel.experiment.ExperimentController.lambda$2(ExperimentController.java:124)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.geotools.data.shapefile.shp.ShapefileException: Cannot handle geometry type : org.locationtech.jts.geom.GeometryCollection
    at org.geotools.data.shapefile.shp.JTSUtilities.getShapeType(JTSUtilities.java:357)
    at org.geotools.data.shapefile.ShapefileFeatureWriter.write(ShapefileFeatureWriter.java:362)
    ... 43 more

Meaning there is a shape of type GeometryCollection it cannot handle. It might be related to a bug introduced in #3552 -- I will check !