#6869 closed enhancement (fixed)
[patch] Added JMapViewerEventListener and getMeterPerPixel() to JMapViewer
Reported by: | jhuntley | Owned by: | jhuntley |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core | Version: | latest |
Keywords: | JMapViewer | Cc: | bastiK |
Description
The scale can now be retrieved in real-time vs looking off referenced wiki pages:
http://wiki.openstreetmap.org/wiki/Height_and_width_of_a_map
I've updated the Demo application to demonstrate this feature.
I've also added a special eventlistener mechanism to the the JMapViewer so external UI components can register and receive notifications when the user interacts with the Map Viewer. Right now I'm only demoing with the zoom feature. However, I could see additional actions added for other operations in the Viewer. Please see demo.
I've tested the accuracy of the meter/pixel calculation with all the major airport runways in the US. The calculation is extremely close to scale. I can generate runway overlays for airports using this function. I may even have more enhancements coming later for adding object and shape overlays to the map.
I do you hope you consider this functionality for the project. I'm attaching the source. Thanks for your time.
Attachments (8)
Change History (27)
Changed 12 years ago by
Changed 12 years ago by
Attachment: | JMapViewer.java added |
---|
Changed 12 years ago by
Attachment: | OsmMercator.java added |
---|
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Summary: | Added JMapViewerEventListener and getMeterPerPixel() to JMapViewer → [patch] Added JMapViewerEventListener and getMeterPerPixel() to JMapViewer |
---|
comment:3 follow-up: 4 Changed 12 years ago by
Sounds good, can you make a patch?
If you like, certainly. However, I am new to the project. I've been reading through your wiki here
https://josm.openstreetmap.de/wiki/DevelopersGuide/SVN_Account
Do I need any special permissions granted to my account? I guess you may have already taken care of this? Any info is greatly appreciated.
comment:4 Changed 12 years ago by
Replying to jhuntley:
Sounds good, can you make a patch?If you like, certainly. However, I am new to the project. I've been reading through your wiki here
https://josm.openstreetmap.de/wiki/DevelopersGuide/SVN_Account
Do I need any special permissions granted to my account? I guess you may have already taken care of this? Any info is greatly appreciated.
What I meant: Please attach a single file in diff format. You can use svn diff
to generate the patch. Don't forget to svn add
the new files. This makes it easier to discuss and apply the changes.
You don't necessarily need an account, we can check in the changes for you. Anyway, the jmapviewer component is in the osm repository. To apply your changes directly, you need an account for svn.openstreetmap.org/. The jmapviewer is an important part of JOSM, so it would be nice to discus any major changes in advance.
comment:5 follow-up: 6 Changed 12 years ago by
As per your request, I'm attaching the diff with the latest enhancements. I'm also including a new build for those wanting to demo the updates.
Changed 12 years ago by
Attachment: | JMapViewer.zip added |
---|
comment:6 Changed 12 years ago by
Replying to jhuntley:
As per your request, I'm attaching the diff with the latest enhancements. I'm also including a new build for those wanting to demo the updates.
Thanks, there are some classes missing, e.g. JMVCommandEvent.
Why did you remove this section?
- if (rectangles) { - for (MapRectangle rectangle : mapRectangleList) { - x_max = Math.max(x_max, OsmMercator.LonToX(rectangle.getBottomRight().getLon(), mapZoomMax)); - y_max = Math.max(y_max, OsmMercator.LatToY(rectangle.getTopLeft().getLat(), mapZoomMax)); - x_min = Math.min(x_min, OsmMercator.LonToX(rectangle.getTopLeft().getLon(), mapZoomMax)); - y_min = Math.min(y_min, OsmMercator.LatToY(rectangle.getBottomRight().getLat(), mapZoomMax)); - } - }
Your scale code might fail, when the size of the component is 10x10. No big deal, but the formula on the linked wiki page looks easier. :)
Paul
comment:7 Changed 12 years ago by
Why did you remove this section?
I'm sorry, I wasn't aware I had. I must have accidentally left it out in the merge between my branch and openstreetmap's. I'll fix. I'll add the missing class.
Changed 12 years ago by
Attachment: | jmapviewer.2.diff added |
---|
comment:10 Changed 12 years ago by
The scale doesn't update when the map is moved. (Please don't use tabs, it's hard to read the patch otherwise.)
comment:11 follow-up: 13 Changed 12 years ago by
The scale doesn't update when the map is moved.
The scale doesn't actually have to update when the map is moved or paned. The size of the map and zoom are still the same. The scale only changes if you zoom in and out.
Please don't use tabs, it's hard to read the patch otherwise.)
Thought i had it set in the CodeStyle, guess not. I'll update to use spaces. Thanks,
Changed 12 years ago by
Attachment: | jmapviewer.diff added |
---|
comment:12 Changed 12 years ago by
I've converted tabs to spaces . Settings should be correct in my IDE and the patch. I also opened the patch and checked and the tabs are all spaces now.
comment:13 follow-up: 14 Changed 12 years ago by
Replying to jhuntley:
The scale doesn't update when the map is moved.The scale doesn't actually have to update when the map is moved or paned. The size of the map and zoom are still the same. The scale only changes if you zoom in and out.
At small scale, it changes. E.g. open http://www.openstreetmap.org/?lat=47.78&lon=11.82&zoom=6&layers=M and move the map up and down. You'll see the bar in the lower left gets smaller/larger.
comment:14 follow-up: 15 Changed 12 years ago by
Replying to bastiK:
Replying to jhuntley:
The scale doesn't update when the map is moved.The scale doesn't actually have to update when the map is moved or paned. The size of the map and zoom are still the same. The scale only changes if you zoom in and out.
At small scale, it changes. E.g. open http://www.openstreetmap.org/?lat=47.78&lon=11.82&zoom=6&layers=M and move the map up and down. You'll see the bar in the lower left gets smaller/larger.
I see what you are referring too, but the change is so subtle. I did have the demo updating like that, but I just didn't think the the difference was enough to warrant calculating every move. However, if you would prefer it that way, I can make the adjustment. Shouldn't take long.
comment:15 Changed 12 years ago by
Replying to jhuntley:
Replying to bastiK:
Replying to jhuntley:
The scale doesn't update when the map is moved.The scale doesn't actually have to update when the map is moved or paned. The size of the map and zoom are still the same. The scale only changes if you zoom in and out.
At small scale, it changes. E.g. open http://www.openstreetmap.org/?lat=47.78&lon=11.82&zoom=6&layers=M and move the map up and down. You'll see the bar in the lower left gets smaller/larger.
I see what you are referring too, but the change is so subtle.
Not that subtle: if you start at the equator and move to Siberia, it grows by factor 5. Reason enough to not have a scale on the osm main site for years.
I did have the demo updating like that, but I just didn't think the the difference was enough to warrant calculating every move.
The computer won't mind.
However, if you would prefer it that way, I can make the adjustment. Shouldn't take long.
I don't want to nag and keep you busy, but wouldn't it be a nice addition to your event framework? :)
Changed 12 years ago by
Attachment: | jmapviewer.3.diff added |
---|
comment:16 Changed 12 years ago by
Hello Bastik, I've made the updates you've requested. The Demo now updates scale when you pan as well as zoom. Please use jmapviewer.3.diff for your patch. For some reason, I no longer have the option to replace when I attach files. Sorry for the list.
Changed 12 years ago by
Attachment: | JMapViewer.2.zip added |
---|
comment:17 Changed 12 years ago by
The computer won't mind. I don't want to nag and keep you busy, but wouldn't it be a nice addition to your event framework? :)
Haha, I like your sense of humor :P I was tinkering around with the demo some more, and I see what you're referring to. It does change quite a bit when you pan up and down. I don't mind helping out or the constructive criticisms for that matter. I'm very particular to the details as well. I understand. Let me know if you see any other issues.
comment:18 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
In [o26701]. (applied josm 6869 - scale and event listeners for JMapViewer (patch by Jason Huntley))
comment:19 Changed 12 years ago by
Removed unnecessary unit conversion and added "official" earth radius.
Sounds good, can you make a patch?