#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)
by , 13 years ago
by , 13 years ago
Attachment: | JMapViewer.java added |
---|
by , 13 years ago
Attachment: | OsmMercator.java added |
---|
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Summary: | Added JMapViewerEventListener and getMeterPerPixel() to JMapViewer → [patch] Added JMapViewerEventListener and getMeterPerPixel() to JMapViewer |
---|
follow-up: 4 comment:3 by , 13 years ago
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 by , 13 years ago
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.
follow-up: 6 comment:5 by , 13 years ago
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.
by , 13 years ago
Attachment: | JMapViewer.zip added |
---|
comment:6 by , 13 years ago
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 by , 13 years ago
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.
by , 13 years ago
Attachment: | jmapviewer.2.diff added |
---|
comment:10 by , 13 years ago
The scale doesn't update when the map is moved. (Please don't use tabs, it's hard to read the patch otherwise.)
follow-up: 13 comment:11 by , 13 years ago
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,
by , 13 years ago
Attachment: | jmapviewer.diff added |
---|
comment:12 by , 13 years ago
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.
follow-up: 14 comment:13 by , 13 years ago
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.
follow-up: 15 comment:14 by , 13 years ago
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 by , 13 years ago
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? :)
by , 13 years ago
Attachment: | jmapviewer.3.diff added |
---|
comment:16 by , 13 years ago
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.
by , 13 years ago
Attachment: | JMapViewer.2.zip added |
---|
comment:17 by , 13 years ago
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 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
In [o26701]. (applied josm 6869 - scale and event listeners for JMapViewer (patch by Jason Huntley))
Sounds good, can you make a patch?