return (Point) geom;
}
@JSFunction
public Geometry transform(Object projObj) {
Projection fromProj = projection;
if (fromProj == null) {
throw new RuntimeException("Geometry must have a projection before transforming.");
}
Projection toProj = null;
if (projObj instanceof Projection) {
toProj = (Projection) projObj;
} else if (projObj instanceof String) {
toProj = new Projection(getParentScope(), (String) projObj);
} else {
throw new RuntimeException("Argument must be a Projection instance or string identifier.");
}
GeometryCoordinateSequenceTransformer gt = new GeometryCoordinateSequenceTransformer();
try {
gt.setMathTransform(CRS.findMathTransform(fromProj.unwrap(), toProj.unwrap()));
} catch (FactoryException e) {
throw new RuntimeException("Failed to find transform.", e);
}
com.vividsolutions.jts.geom.Geometry transGeom;
try {