Skip to content

Commit

Permalink
Add .qpj and .qmd Extensions to Shapefile Handling #8134 (#10305)
Browse files Browse the repository at this point in the history
* Added qpj and qmd extensions to handle shapefiles

* Include .qpj and .qmd in Shapefile Ingest Documentation #8134

* Add release note for .qpj and .qmd shapefile support

* Update doc/release-notes/8134-add-qpj-qmd-extensions.md

Co-authored-by: Philip Durbin <[email protected]>

* Add test for .qpj and .qmd file handling in ShapefileHandler

---------

Co-authored-by: Philip Durbin <[email protected]>
  • Loading branch information
Saixel and pdurbin authored Mar 1, 2024
1 parent c8363f2 commit aa9c6b0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
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

0 comments on commit aa9c6b0

Please sign in to comment.