1

I am having an issue with the below exception being thrown, not sure how to solve it.

Measure distance = .....
Unit<Length> unit = distance.getUnit();

CoordinateReferenceSystem origCRS  = CRS.decode("EPSG:3785")
unit = (Unit<Length>) origCRS.getCoordinateSystem().getAxis(0).getUnit();

exception:

class tec.uom.se.unit.BaseUnit cannot be cast to class javax.measure.unit.Unit (tec.uom.se.unit.BaseUnit and javax.measure.unit.Unit are in unnamed module of loader 'app')
    at com.vanitysoft.canada.boundaries.domain.dao.impl.CAPostalDAOImpl.createCircleRadis(CAPostalDAOImpl.java:131)

the return type of .getUnit() is javax.measure.Unit so I'm not understanding why this being thrown(I don't understand the stack trace).

I'm using GeoTools 22.4

1 Answer 1

0

With out seeing the actual imports you are using it's hard to be sure but GeoTools units library has changed at version 20.x and again at 24.x, see the upgrades page for specific details.

In general it's wise to stay on the supported branches so I would upgrade to 24.x and try again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.