Opened 15 years ago
Closed 15 years ago
#2799 closed enhancement (wontfix)
Add new library (Apache Commons Lang)
Reported by: | dmuecke | Owned by: | dmuecke |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | Core | Version: | |
Keywords: | library | Cc: | Claudius |
Description
I foresee benefits in code quality if we would add following library into josm lib directory
Attachments (0)
Change History (4)
comment:1 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → needinfo |
comment:2 by , 15 years ago
Cc: | added |
---|---|
Status: | needinfo → new |
Summary: | New library → Add new library (Apache Commons Lang) |
comment:3 by , 15 years ago
Most of the functions are handy helper to write cleaner and easier readable code.
One is Validate which I used to use in other applications.
public static double calcDistance(LatLon p1, LatLon p2){ double lat1, lon1, lat2, lon2; double dlon, dlat; Validate.notNull(p1,"P1 may not null"); Validate.notNull(p2,"P2 may not null"); lat1 = p1.lat() * Math.PI / 180.0; lon1 = p1.lon() * Math.PI / 180.0; lat2 = p2.lat() * Math.PI / 180.0; lon2 = p2.lon() * Math.PI / 180.0; dlon = lon2 - lon1; dlat = lat2 - lat1; double a = (Math.pow(Math.sin(dlat/2), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(dlon/2), 2)); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); return 6367000 * c; }
If this function gets invoked and p1 or p2 is null an IllegalArgument exception gets raised instead a NullPointer exception.
I wouldn't go and rewrite existing running code. I would start to use it when I had to fix bugs or if I want work on a new feature.
comment:4 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I don't see real benefits from my side. Most programmers wont know that library and also don't use it thus.
Could you please provide some of the direct benefits that you see? I could theoretically see some value arising when this library would be added *AND* the existing could would make use of some of the new Utils classes for example. But it would require someone to rewrite that stuff.
Would you be able to provide the code changes that would make these come to effect?
(btw. Apache Lang API 2.4 seems to be the current one).