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

Use of GIS file result in an exception in a comodeling context #3872

Closed LucasGrjs closed 1 year ago

LucasGrjs commented 1 year ago

Describe the bug In a co-modeling context (a model A controlling a submodel B), using GIS data from file result in an exception. Loading a GIS file works, but using the GIS data to create agents or setup the world shape result in an exception. This bug appears only on developer version as it works well on GAMA 1.9.2 and GAMA 1.9.1 released version.

To Reproduce Steps to reproduce the behavior:

Most simple models reproducing the bug :
issue.zip

  1. Go to the linked archive
  2. Unzip it
  3. Import the folder "issue" to your workspace
  4. Go to \models
  5. Start comodel_issue.gaml
  6. See error

Library model reproducing the bug :

  1. Go to "Library models\Toy Models\Comodels\Flood and Evacuation\Flood Evacuation Comodel.gaml"
  2. Start the experiment "simple"
  3. See error

Expected behavior Both examples should work

Desktop (please complete the following information):

Additional context Eclipse logs of the exception

java.lang.NullPointerException: Cannot invoke "msi.gama.kernel.simulation.SimulationAgent.getProjectionFactory()" because the return value of "msi.gama.kernel.experiment.IExperimentAgent.getSimulation()" is null
    at msi.gama.util.file.GamaGisFile.computeProjection(GamaGisFile.java:205)
    at msi.gama.util.file.GamaGisFile.computeEnvelope(GamaGisFile.java:366)
    at msi.gama.common.geometry.GeometryUtils.computeEnvelopeFrom(GeometryUtils.java:1152)
    at msi.gaml.operators.Spatial$Creation.envelope(Spatial.java:2036)
    at gaml.additions.core.GamlAdditions.lambda$964(GamlAdditions.java:1018)
    at msi.gaml.expressions.operators.UnaryOperator._value(UnaryOperator.java:106)
    at msi.gaml.expressions.AbstractExpression.value(AbstractExpression.java:81)
    at msi.gaml.statements.LetStatement.privateExecuteIn(LetStatement.java:140)
    at msi.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:47)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:510)
    at msi.gama.runtime.IScope.execute(IScope.java:440)
    at msi.gama.runtime.IScope.execute(IScope.java:411)
    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:47)
    at msi.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:510)
    at msi.gama.runtime.IScope.execute(IScope.java:440)
    at msi.gama.runtime.IScope.execute(IScope.java:411)
    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:279)
    at msi.gama.kernel.simulation.SimulationAgent._init_(SimulationAgent.java:431)
    at msi.gaml.statements.CreateStatement.createAgents(CreateStatement.java:539)
    at msi.gaml.statements.CreateStatement.privateExecuteIn(CreateStatement.java:467)
    at msi.gaml.statements.CreateStatement.privateExecuteIn(CreateStatement.java:1)
    at msi.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:47)
    at msi.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:510)
    at msi.gama.runtime.IScope.execute(IScope.java:440)
    at msi.gama.runtime.IScope.execute(IScope.java:411)
    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:47)
    at msi.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:510)
    at msi.gama.runtime.IScope.execute(IScope.java:440)
    at msi.gama.runtime.IScope.execute(IScope.java:411)
    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:279)
    at msi.gama.kernel.simulation.SimulationAgent._init_(SimulationAgent.java:431)
    at msi.gama.metamodel.agent.MinimalAgent.init(MinimalAgent.java:244)
    at msi.gama.runtime.ExecutionScope.init(ExecutionScope.java:602)
    at msi.gama.metamodel.agent.AbstractAgent.schedule(AbstractAgent.java:296)
    at msi.gama.kernel.simulation.SimulationAgent.schedule(SimulationAgent.java:410)
    at msi.gama.kernel.simulation.SimulationPopulation.initSimulation(SimulationPopulation.java:196)
    at msi.gama.kernel.simulation.SimulationPopulation.createAgents(SimulationPopulation.java:148)
    at msi.gama.metamodel.population.IPopulation.createAgents(IPopulation.java:229)
    at msi.gama.kernel.experiment.ExperimentAgent.createSimulation(ExperimentAgent.java:467)
    at msi.gama.kernel.experiment.ExperimentAgent._init_(ExperimentAgent.java:360)
    at msi.gama.metamodel.agent.MinimalAgent.init(MinimalAgent.java:244)
    at msi.gama.kernel.experiment.ExperimentAgent.init(ExperimentAgent.java:423)
    at msi.gama.runtime.ExecutionScope.init(ExecutionScope.java:602)
    at msi.gama.kernel.experiment.ExperimentController.schedule(ExperimentController.java:286)
    at msi.gama.kernel.experiment.ExperimentAgent.schedule(ExperimentAgent.java:490)
    at msi.gama.kernel.experiment.ExperimentPlan.open(ExperimentPlan.java:700)
    at msi.gama.kernel.experiment.ExperimentPlan.open(ExperimentPlan.java:757)
    at msi.gama.kernel.experiment.ExperimentController.lambda$2(ExperimentController.java:123)
    at java.base/java.lang.Thread.run(Thread.java:833)
Adding exception 1 occurence in Simulation 0 at cycle 0: Java error: nil value detected
in Simulation 0
in geometry buildings_shape <- envelope(buildings);
NullPointerException: Cannot invoke "msi.gama.kernel.simulation.SimulationAgent.getProjectionFactory()" because the return value of "msi.gama.kernel.experiment.IExperimentAgent.getSimulation()" is null
msi.gama.util.file.GamaGisFile.computeProjection(GamaGisFile.jav
[issue.zip](https://github.com/gama-platform/gama/files/12620864/issue.zip)
a:205)
msi.gama.util.file.GamaGisFile.computeEnvelope(GamaGisFile.java:366)
msi.gama.common.geometry.GeometryUtils.computeEnvelopeFrom(GeometryUtils.java:1152)
msi.gaml.operators.Spatial$Creation.envelope(Spatial.java:2036)
gaml.additions.core.GamlAdditions.lambda$964(GamlAdditions.java:1018)
msi.gaml.expressions.operators.UnaryOperator._value(UnaryOperator.java:106)
msi.gaml.expressions.AbstractExpression.value(AbstractExpression.java:81)
when applying the envelope operator on msi.gama.util.file.GamaShapeFile@1bf3036a
in geometry buildings_shape <- envelope(buildings);
in agent Simulation 0
AlexisDrogoul commented 1 year ago

Should be fixed in the latest commit

LucasGrjs commented 1 year ago

The fix is working !