Skip to content

Commit

Permalink
Deals with caching issues in reading shapefiles
Browse files Browse the repository at this point in the history
1) Clarifies the message behind the preference for mapping/caching
shapefiles in memory to make sure people disable it when dealing with
frequently changing shapefiles

2) Links mapping and caching of shapefiles (i.e. when one is disabled,
resp. enabled, the other one is as well).
  • Loading branch information
AlexisDrogoul committed Jun 5, 2024
1 parent 54f06cb commit 27de854
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************************************
*
* GamaPreferences.java, in gama.core, is part of the source code of the
* GAMA modeling and simulation platform (v.2024-06).
* GamaPreferences.java, in gama.core, is part of the source code of the GAMA modeling and simulation platform
* (v.2024-06).
*
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, ESPACE-DEV, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
*
********************************************************************************************************/
package gama.core.common.preferences;

Expand Down Expand Up @@ -861,7 +861,7 @@ public static class External {

/** The Constant SHAPEFILE_IN_MEMORY. */
public static final Pref<Boolean> SHAPEFILES_IN_MEMORY = create("pref_shapefiles_in_memory",
"In-memory shapefile mapping (optimizes access to shapefile data in exchange for increased memory usage)",
"Mapping and caching of shapefiles in memory (optimises access to shapefile data in exchange for increased memory usage). Disable this property if you are dealing with shapefiles that change frequently",
true, IType.BOOL, true).in(NAME, OPTIMIZATIONS);

/**
Expand Down
11 changes: 6 additions & 5 deletions gama.core/src/gama/core/util/file/GamaShapeFile.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************************************
*
* GamaShapeFile.java, in gama.core, is part of the source code of the GAMA modeling and simulation platform
* .
* GamaShapeFile.java, in gama.core, is part of the source code of the
* GAMA modeling and simulation platform (v.2024-06).
*
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, ESPACE-DEV, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
*
********************************************************************************************************/
package gama.core.util.file;

Expand Down Expand Up @@ -39,10 +39,10 @@
import org.opengis.feature.type.GeometryType;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

import gama.annotations.precompiler.IConcept;
import gama.annotations.precompiler.GamlAnnotations.doc;
import gama.annotations.precompiler.GamlAnnotations.example;
import gama.annotations.precompiler.GamlAnnotations.file;
import gama.annotations.precompiler.IConcept;
import gama.core.common.geometry.GamaGeometryFactory;
import gama.core.common.geometry.GeometryUtils;
import gama.core.common.preferences.GamaPreferences;
Expand Down Expand Up @@ -436,6 +436,7 @@ static FileDataStore getDataStore(final URL url) {
if (fds instanceof ShapefileDataStore store) {
store.setGeometryFactory(GeometryUtils.GEOMETRY_FACTORY);
store.setMemoryMapped(GamaPreferences.External.SHAPEFILES_IN_MEMORY.getValue());
store.setBufferCachingEnabled(GamaPreferences.External.SHAPEFILES_IN_MEMORY.getValue());
store.setCharset(Charset.forName("UTF8"));
}
return fds;
Expand Down

0 comments on commit 27de854

Please sign in to comment.