Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .qpj and .qmd Extensions to Shapefile Handling #8134 #10305

Merged
merged 5 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/release-notes/8134-add-qpj-qmd-extensions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add .qpj and .qmd Extensions to Shapefile Handling

- Support for `.qpj` and `.qmd` files in shapefile uploads has been introduced, ensuring that these files are properly recognized and handled as part of geospatial datasets in Dataverse.
2 changes: 1 addition & 1 deletion doc/sphinx-guides/source/developers/geospatial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For example:
Upon recognition of the four required files, the Dataverse installation will group them as well as any other relevant files into a shapefile set. Files with these extensions will be included in the shapefile set:

- Required: ``.shp``, ``.shx``, ``.dbf``, ``.prj``
- Optional: ``.sbn``, ``.sbx``, ``.fbn``, ``.fbx``, ``.ain``, ``.aih``, ``.ixs``, ``.mxs``, ``.atx``, ``.cpg``, ``shp.xml``
- Optional: ``.sbn``, ``.sbx``, ``.fbn``, ``.fbx``, ``.ain``, ``.aih``, ``.ixs``, ``.mxs``, ``.atx``, ``.cpg``, ``.qpj``, ``.qmd``, ``shp.xml``

Then the Dataverse installation creates a new ``.zip`` with mimetype as a shapefile. The shapefile set will persist as this new ``.zip``.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class ShapefileHandler{
public final static List<String> SHAPEFILE_MANDATORY_EXTENSIONS = Arrays.asList("shp", "shx", "dbf", "prj");
public final static String SHP_XML_EXTENSION = "shp.xml";
public final static String BLANK_EXTENSION = "__PLACEHOLDER-FOR-BLANK-EXTENSION__";
public final static List<String> SHAPEFILE_ALL_EXTENSIONS = Arrays.asList("shp", "shx", "dbf", "prj", "sbn", "sbx", "fbn", "fbx", "ain", "aih", "ixs", "mxs", "atx", "cpg", SHP_XML_EXTENSION);
public final static List<String> SHAPEFILE_ALL_EXTENSIONS = Arrays.asList("shp", "shx", "dbf", "prj", "sbn", "sbx", "fbn", "fbx", "ain", "aih", "ixs", "mxs", "atx", "cpg", "qpj", "qmd", SHP_XML_EXTENSION);

public boolean DEBUG = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,40 @@ public void testCreateZippedNonShapefile() throws IOException{

msg("Passed!");
}





@Test
public void testShapefileWithQpjAndQmd() throws IOException {
msgt("(4) testShapefileWithQpjAndQmd");

// Create mock files for the new extensions
List<String> fileNames = Arrays.asList("testShape.shp", "testShape.shx", "testShape.dbf", "testShape.prj", "testShape.qpj", "testShape.qmd");

// Create a zip file with these files
File zipFile = createAndZipFiles(fileNames, "testShapeWithNewExtensions.zip");

// Pass the zip to the ShapefileHandler
ShapefileHandler shpHandler = new ShapefileHandler(new FileInputStream(zipFile));
shpHandler.DEBUG = true;

// Check if it is recognized as a shapefile
assertTrue(shpHandler.containsShapefile(), "The zip should contain a shapefile with the new extensions");

// Get file groups map and verify presence
Map<String, List<String>> fileGroups = shpHandler.getFileGroups();
assertFalse(fileGroups.isEmpty(), "The file groups map should not be empty");

// Ensure the specific extensions are present
assertTrue(fileGroups.containsKey("testShape"), "The file group should contain the key 'testShape'");
assertTrue(fileGroups.get("testShape").containsAll(Arrays.asList("shp", "shx", "dbf", "prj", "qpj", "qmd")), "The file group should include the new extensions .qpj and .qmd");

// Delete the test zip file
zipFile.delete();

msg("Test passed successfully!");
}


@Test
public void testZippedTwoShapefiles() throws IOException{
msgt("(2) testZippedTwoShapefiles");
Expand Down
Loading