|
@@ -5,22 +5,19 @@ import com.vividsolutions.jts.io.ParseException;
|
|
|
import com.vividsolutions.jts.io.WKTReader;
|
|
|
import com.vividsolutions.jts.operation.valid.IsValidOp;
|
|
|
import com.vividsolutions.jts.operation.valid.TopologyValidationError;
|
|
|
-import com.zjugis.gis.consts.GeometryType;
|
|
|
import com.zjugis.gis.entity.MdbTable;
|
|
|
import com.zjugis.gis.entity.MultiPolygon;
|
|
|
import com.zjugis.gis.entity.Polygon;
|
|
|
-import com.zjugis.gis.reader.mdb.MdbReader;
|
|
|
-import com.zjugis.nature.gis.exception.BusinessException;
|
|
|
+import com.zjugis.nature.gis.exception.MdbNullDataException;
|
|
|
+import com.zjugis.nature.gis.exception.MdbSridErrorException;
|
|
|
|
|
|
import javax.validation.ConstraintViolation;
|
|
|
import javax.validation.Validation;
|
|
|
import javax.validation.Validator;
|
|
|
-import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
-import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -45,36 +42,32 @@ public class MdbUtils {
|
|
|
"环未关闭"
|
|
|
};
|
|
|
|
|
|
- public static final List<Integer> ignores = new ArrayList<Integer>(){{
|
|
|
+ public static final List<Integer> ignores = new ArrayList<Integer>() {{
|
|
|
// add(5); // 自相交
|
|
|
// add(6); // 环形自相交
|
|
|
add(7); // 嵌套的洞
|
|
|
}};
|
|
|
|
|
|
- public static final List<String> ignoresInspect = new ArrayList<String>(){{
|
|
|
+ public static final List<String> ignoresInspect = new ArrayList<String>() {{
|
|
|
add("MultiLineString");
|
|
|
add("MultiPoint");
|
|
|
add("Point");
|
|
|
add("LineString");
|
|
|
}};
|
|
|
|
|
|
- public static <T extends MdbBaseDTO> List<String> mdbInspect(MdbTable mdbTable, List<String> existColumns, Class<T> clazz) {
|
|
|
+ public static <T extends MdbBaseDTO> List<String> mdbInspect(MdbTable mdbTable, List<String> existColumns, Class<T> clazz) throws MdbNullDataException, MdbSridErrorException {
|
|
|
List<String> inspect = new ArrayList<>();
|
|
|
- try {
|
|
|
- if (mdbTable == null || mdbTable.getSize() == 0) {
|
|
|
- throw new BusinessException("mdb数据为空");
|
|
|
- }
|
|
|
- if (mdbTable.getSRID() == -1 || "unknow".equals(mdbTable.getSRIDInfo()) || !"4490".equals(mdbTable.getEpsg())) {
|
|
|
- throw new BusinessException("请检查坐标系是否为CGCS2000大地坐标系,wkid为4490,请务必使用模板进行数据导入");
|
|
|
- }
|
|
|
- //检查mdb图形列表字段是否包含必须字段
|
|
|
- inspect.addAll(inspectMdbColumns(mdbTable, existColumns));
|
|
|
- //检查列表数据是否符合规范
|
|
|
- List<String> vaildMdbMessage = inspectMdbTableData(mdbTable, clazz);
|
|
|
- inspect.addAll(vaildMdbMessage);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ if (mdbTable == null || mdbTable.getSize() == 0) {
|
|
|
+ throw new MdbNullDataException("mdb数据为空");
|
|
|
+ }
|
|
|
+ if (mdbTable.getSRID() == -1 || "unknow".equals(mdbTable.getSRIDInfo()) || !"4490".equals(mdbTable.getEpsg())) {
|
|
|
+ throw new MdbSridErrorException("请检查坐标系是否为CGCS2000大地坐标系,wkid为4490,请务必使用模板进行数据导入");
|
|
|
}
|
|
|
+ //检查mdb图形列表字段是否包含必须字段
|
|
|
+ inspect.addAll(inspectMdbColumns(mdbTable, existColumns));
|
|
|
+ //检查列表数据是否符合规范
|
|
|
+ List<String> vaildMdbMessage = inspectMdbTableData(mdbTable, clazz);
|
|
|
+ inspect.addAll(vaildMdbMessage);
|
|
|
return inspect;
|
|
|
}
|
|
|
|
|
@@ -120,9 +113,9 @@ public class MdbUtils {
|
|
|
}
|
|
|
try {
|
|
|
IsValidOp isValidOp = new IsValidOp(new WKTReader().read(wkt));
|
|
|
- if(!isValidOp.isValid()) {
|
|
|
+ if (!isValidOp.isValid()) {
|
|
|
TopologyValidationError error = isValidOp.getValidationError();
|
|
|
- if(!ignores.contains(error.getErrorType())) {
|
|
|
+ if (!ignores.contains(error.getErrorType())) {
|
|
|
detailMessage.append("\n存在图形错误" + errMsg[error.getErrorType()]);
|
|
|
}
|
|
|
}
|