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

Rezip shape files with upper case extension #11170

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.zip.ZipFile;
import java.util.HashMap;
import java.util.*;
Expand Down Expand Up @@ -561,7 +562,7 @@ private boolean isShapefileExtension(String ext_name){
if (ext_name == null){
return false;
}
return SHAPEFILE_ALL_EXTENSIONS.contains(ext_name);
return SHAPEFILE_ALL_EXTENSIONS.contains(ext_name.toLowerCase());
}
/*
Does a list of file extensions match those required for a shapefile set?
Expand All @@ -570,7 +571,10 @@ private boolean doesListContainShapefileExtensions(List<String> ext_list){
if (ext_list == null){
return false;
}
return ext_list.containsAll(SHAPEFILE_MANDATORY_EXTENSIONS);
var lowerCaseExtensions = ext_list.stream()
.map(String::toLowerCase)
.toList();
return lowerCaseExtensions.containsAll(SHAPEFILE_MANDATORY_EXTENSIONS);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void testZippedTwoShapefiles() throws IOException{
msgt("(2) testZippedTwoShapefiles");

// Create files and put them in a .zip
List<String> file_names = Arrays.asList("shape1.shp", "shape1.shx", "shape1.dbf", "shape1.prj", "shape1.fbn", "shape1.fbx", // 1st shapefile
List<String> file_names = Arrays.asList("shape1.shp", "shape1.shx", "shape1.DBF", "shape1.prj", "shape1.fbn", "shape1.fbx", // 1st shapefile
"shape2.shp", "shape2.shx", "shape2.dbf", "shape2.prj", // 2nd shapefile
"shape2.txt", "shape2.pdf", "shape2", // single files, same basename as 2nd shapefile
"README.MD", "shp_dictionary.xls", "notes" ); //, "prj"); // single files
Expand Down Expand Up @@ -211,7 +211,7 @@ public void testZippedTwoShapefiles() throws IOException{
assertTrue(file_groups.containsKey("shape2"), "verify key existance of 'shape2'");

// Verify the values
assertEquals(file_groups.get("shape1"), Arrays.asList("shp", "shx", "dbf", "prj", "fbn", "fbx"), "verify value of key 'shape1'");
assertEquals(file_groups.get("shape1"), Arrays.asList("shp", "shx", "DBF", "prj", "fbn", "fbx"), "verify value of key 'shape1'");
assertEquals(file_groups.get("shape2"), Arrays.asList("shp", "shx", "dbf", "prj", "txt", "pdf", ShapefileHandler.BLANK_EXTENSION), "verify value of key 'shape2'");

// Rezip/Reorder the files
Expand Down Expand Up @@ -240,7 +240,7 @@ public void testZippedShapefileWithExtraFiles() throws IOException{
msgt("(3) testZippedShapefileWithExtraFiles");

// Create files and put them in a .zip
List<String> file_names = Arrays.asList("shape1.shp", "shape1.shx", "shape1.dbf", "shape1.prj", "shape1.pdf", "shape1.cpg", "shape1." + SHP_XML_EXTENSION, "README.md", "shape_notes.txt");
List<String> file_names = Arrays.asList("shape1.shp", "shape1.shx", "shape1.dbf", "shape1.prj", "shape1.pdf", "shape1.cpg", "shape1." + SHP_XML_EXTENSION, "README.md", "shape_notes.txt");
File zipfile_obj = createAndZipFiles(file_names, "shape-plus.zip");

// Pass the .zip to the ShapefileHandler
Expand Down
Loading