Skip to content

Commit c247cbd

Browse files
Fix Axis.getDirection() to never return null (#81)
1 parent ae8b388 commit c247cbd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/org/osgeo/proj/Axis.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ public String getAbbreviation() {
6969
@Override
7070
public AxisDirection getDirection() {
7171
final String dir = impl.getStringProperty(Property.DIRECTION);
72-
return search(AxisDirection.class, dir);
72+
AxisDirection direction = search(AxisDirection.class, dir);
73+
// Ensure a non-null return; default to UNSPECIFIED if unknown
74+
return (direction != null) ? direction : AxisDirection.valueOf("UNSPECIFIED");
75+
76+
// TODO: Use AxisDirection.UNSPECIFIED in GeoAPI 3.1.
77+
// The "Unspecified" axis direction has been added in ISO 19111:2019.
78+
// GeoAPI has not yet been updated for that revision, but this change anticipates it.
7379
}
7480

7581
/**
@@ -79,7 +85,7 @@ public AxisDirection getDirection() {
7985
* @param <T> compile-time value of {@code type}.
8086
* @param type class of the code to search.
8187
* @param code name of the code that we are searching.
82-
* @return the code list for the given UML identifier.
88+
* @return the code list for the given UML identifier, or null if not found.
8389
*/
8490
private static <T extends CodeList<T>> T search(final Class<T> type, final String code) {
8591
return CodeList.valueOf(type, new CodeList.Filter() {

0 commit comments

Comments
 (0)