Skip to content

Commit

Permalink
Make projection list accessible (#31)
Browse files Browse the repository at this point in the history
* Added method to retrieve projections list

Signed-off-by: Michele Noberasco <michele.noberasco@tiscali.it>
  • Loading branch information
noberasco authored and echeipesh committed Jul 31, 2019
1 parent b716606 commit bcc1317
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/org/locationtech/proj4j/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/
package org.locationtech.proj4j;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.locationtech.proj4j.datum.Datum;
Expand Down Expand Up @@ -135,12 +137,27 @@ public Projection getProjection(String name) {
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
System.err.println("Cannot instantiate projection " + name + " [" + cls.getName() + "]");
e.printStackTrace();
}
}
return null;
}

public List<Projection> getProjections() {
List<Projection> projections = new ArrayList<>();

for (String name : projRegistry.keySet()) {
Projection projection = getProjection(name);

if (projection != null) {
projections.add(projection);
}
}

return projections;
}

private synchronized void initialize() {
// guard against race condition
if (projRegistry != null)
Expand Down

0 comments on commit bcc1317

Please sign in to comment.