Modify

Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#7017 closed defect (fixed)

SCANEX in Download-dialog misaligned

Reported by: stoecker Owned by: glebius
Priority: normal Milestone:
Component: JMapViewer Version:
Keywords: Cc: The111, glebius

Description

The TMS scanex entries are misaligned in download dialog and downloading data yields to wrong position. Works in normal JOSM map.

Attachments (5)

osm.png (253.6 KB ) - added by stoecker 11 years ago.
bing.png (1.1 MB ) - added by stoecker 11 years ago.
scanexirs.png (694.4 KB ) - added by stoecker 11 years ago.
mapnik-grid.png (173.4 KB ) - added by The111 11 years ago.
scanex-grid.png (462.5 KB ) - added by The111 11 years ago.

Change History (24)

comment:1 by skyper, 12 years ago

Owner: changed from Upliner to team

comment:2 by skyper, 12 years ago

Component: CoreCore imagery

comment:3 by stoecker, 11 years ago

Component: Core imageryJMapViewer

comment:4 by stoecker, 11 years ago

Cc: The111 added

comment:5 by The111, 11 years ago

To be honest, I don't know what scanex means. Searching the web for that term yields very little. I haven't used JOSM much (yet), but it appears that the download dialog only pulls OSM data (along with some other possible layers, but not anything about scanex), and does it with perfect alignment. I see in JMV there is a ScanexTileSource class, but if I try to make a map panel using that tile source, it fails to load any tiles at all, and I'm not sure why. The JMV demo class also does not illustrate an example of that tile source, though it does for all the other options available.

Could you please explain what scanex is, and give a brief walkthrough of how to trigger this misaligned download bug in JOSM? Thanks.

by stoecker, 11 years ago

Attachment: osm.png added

by stoecker, 11 years ago

Attachment: bing.png added

by stoecker, 11 years ago

Attachment: scanexirs.png added

comment:6 by stoecker, 11 years ago

In Maps are all our tile and wms sources. One of the is the SCANEX service. All Tile based systems are available in JOSM downloader as well, when they got activated in the preferences.

SCANEX uses a special tile source:

[osm:source:applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java]

JOSM simply calls that class with either irs or spot as argument.

Scanex is only available in Russia - Use this as entry in download dialog (coordinates page) to get the an avaible area: http://www.openstreetmap.org/?lat=54.754&lon=19.989&zoom=10

As said - problem is it works fine in normal map, but not in the downloader. Maybe a josm error or a JMapViewer error - no idea.

I'll attach pictures showing the offset:


Displacement to north:

by The111, 11 years ago

Attachment: mapnik-grid.png added

by The111, 11 years ago

Attachment: scanex-grid.png added

comment:7 by The111, 11 years ago

Thanks for the explanation.

As said - problem is it works fine in normal map, but not in the downloader. Maybe a josm error or a JMapViewer error - no idea.


Actually, it doesn't work fine in a normal map either. Now that I realize there are only very limited tiles rendered in Russia area at certain zoom levels, I was able to zoom in on my modified JMV Demo class (with extra option for Scanex) and find some Russian tiles, and the problem as you describe it is there just as it is in JOSM. And as far as I can tell, the problem is neither with JMapViewer nor JOSM, but instead with the Scanex tile server, or more accurately their tile grid offset. So... blame the Russians. :-)

See the images below. For once the "visible grid lines" function of JMV comes in handy. :-) It is impossible to line up a Scanex tile with a tile from any of the other TMS providers, because the Scanex tile grid does not align with the standard grid used by every single other provider out there. This is probably because they don't grid the entire planet, so they just arbitrarily started their grid somewhere I guess.



I suppose it would be possible to "fix" this problem in JMV, it would require modification to the panel painting method, and would place the grid on screen differently for Scanex than for all other tile sources (the grid placement would be offset vertically by some amount depending on the zoom level probably). I am not sure if this is a good approach though. It would be a lot of messy hacky code in JMV just to fix a problem with Scanex server design... also the hack may need to be duplicated into other methods besides the main paint method, and possibly even into JOSM code as well depending what JOSM does with that data. If Scanex wants their service usable in JMV, it seems they should conform to standards. How necessary is it to use Scanex with JOSM? If it was very necessary, I guess an argument could be made for the hacky fix described above, but as far as I can tell (not a JOSM user yet), there are many other options to use in the download dialog, layers which do conform to global standards. But I'm new here. What do you think?

comment:8 by stoecker, 11 years ago

Probably they simply use another coordinate system - WGS is American, so why should Russia use it?

Maybe it is possible to make a "rebuild" image inside the SCANEX tile source (if there aren't totally different projections used).

You're sure it does not work in JOSM main map? I thought it was aligned there when I tested it.

I guess what is needed would be to support different projections for JMapViewer also. Probably that is too much, as projection support is not a minor task.

comment:9 by stoecker, 11 years ago

Hmm. Looking at the images. Could it be they simply have an offset of half an tile in vertical direction? That should be easy fixable.

comment:11 by stoecker, 11 years ago

This is the old name of the above file.

in reply to:  11 ; comment:12 by bastiK, 11 years ago

Replying to stoecker:

This is the old name of the above file.

Ok right. :)

But there is no doubt they use a different projection because it is implemented in that file...

@The111: The TMS standard does not specify one particular projection, so I don't think there is anything wrong with Scanex server design.

in reply to:  12 comment:13 by The111, 11 years ago

Replying to stoecker:

You're sure it does not work in JOSM main map? I thought it was aligned there when I tested it.

I was mistaken, by "main map" I thought you just meant a JMV instance that wasn't in the JOSM downloader. I now realize you mean the JOSM map edit screen (which I hadn't even really used up until now), and I see that yes, it is aligned there.

Probably they simply use another coordinate system - WGS is American, so why should Russia use it?

Well, I don't know much about projection systems, but I did a small test which led me to believe that it is indeed a different projection system than the other tile sources. I measured the difference (in pixels) of vertical offset at different latitudes, and this difference varied based on latitude (it was larger at higher latitudes and smaller at lower latitudes). So a coordinate offset would not be enough. :-( And I think this implies different projection systems.

However, another thought confused me more. If the two maps use different projection systems, with the offset varying based on latitude as I found above, I would think that it would be impossible to perfectly align two world maps on screen (super low zoom level) since they'd be distorted differently at different latitudes. In JMapViewer it is only possible with Scanex to view parts of Russia at high zoom levels so of course everything lines up. However, at this site (http://maps.kosmosnimki.ru/api/index.html) you can get the Scanex world map at low zoom levels (whole world on screen), and it does align perfectly with other tile sources including OSM. This would seem to disagree with my conclusion above that different projections are used.

But again, I don't know much about projection system details. Am I missing something?

I guess what is needed would be to support different projections for JMapViewer also. Probably that is too much, as projection support is not a minor task.

Well, the funny thing is that the ScanexTileSource class has a lot of math that the other tile source classes don't have. I haven't taken the time to dig into this math, but it would seem to imply that the creator of this class was aware that some different projections were needed (note: I just realized while typing response to bastiK below that none of these methods are even used). And yeah I agree a new projection would not be trivial, and I may not have time for it now, but it actually sounds fun to get into all that math if I could find the time. Another interesting fact is that since the JOSM main map does seem to align everything properly, there must therefore be code in JOSM which solves this somehow, so presumably we could port that could to JMapViewer somehow?

Replying to bastiK:

@The111: The TMS standard does not specify one particular projection, so I don't think there is anything wrong with Scanex server design.

Ok, I understand and agree now.

But there is no doubt they use a different projection because it is implemented in that file...

I alluded to that briefly above, but on closer inspection, none of those lat<->coord conversion methods are ever actually called. The only one actually used is the getTilePath() method which is nothing more than an offset.

I suspect still that it is a different projection system, but in my responses above to stoecker you can see I made two different observations which seem to contradict each other (high zoom level tiles have offset varying on latitude, but yet entire world maps can be aligned perfectly)... what are your thoughts on that?

comment:14 by stoecker, 11 years ago

I alluded to that briefly above, but on closer inspection, none of those lat<->coord conversion methods are ever actually called. The only one actually used is the getTilePath() method which is nothing more than an offset.

I checked it - these are called from JOSM when reading or settings lat/lon coordinates. So probably there lies the error. The main map calls it correctly, in the downloader somehow it is called incorrectly. But on short inspection also the downloader code looks logical to me :-)

The display offset itself is not the issue, but the wrong handling of coordinates when handling the map.

in reply to:  14 comment:15 by The111, 11 years ago

Replying to stoecker:

I checked it - these are called from JOSM when reading or settings lat/lon coordinates. So probably there lies the error. The main map calls it correctly, in the downloader somehow it is called incorrectly. But on short inspection also the downloader code looks logical to me :-)

After spending way too many hours on this today, I've concluded it is beyond my expertise right now. Here is what I did learn for sure though. JMapViewer does not use lat/lon at all. When it first constructs the map, it puts you down at a random lat/lon, converts those to tilex/tiley, and then for the rest of the application run you are always using tile and pixels only. No lat/lon references at all.

The Russian tilex/tiley apparently work totally differently than all others, and these lines in ScanexTileSource.getTilePath somehow do a tile->tile conversion which almost works perfectly (except for y being slightly off).

int tmp = (int)Math.pow(2.0, zoom - 1);

tilex = tilex - tmp;
tiley = tmp - tiley - 1;

However, it would seem to make more sense to do something like this with the included coord/tile conversion methods:

double lon = OsmMercator.XToLon(tilex * 256, zoom);
double lat = OsmMercator.YToLat(tiley * 256, zoom);
tilex = (int) lonToTileX(lon, zoom);
tiley = (int) latToTileY(lat, zoom);

Basically extracting the lat/lon from the OSM tilex/tiley, and then convert that lat/lon to Scanex tilex/tiley. But that does not work at all, which makes me doubt that the XToLon and lonToTileX methods actually work correctly. In JOSM there seem to be a lot of other classes with more math which support TMSLayer (which I believe is the layers for the main map?). A lot of these classes are not in JMapViewer. So I am not sure how JOSM makes it work, but that is a lot of code to dig through.

The display offset itself is not the issue, but the wrong handling of coordinates when handling the map.

I am still suspicious that display offset is involved as well. At some zoom levels, the OSM grid and Scanex grid almost match up perfectly, but at other zoom levels they are off by random fractions of a tile. This would seem to imply that display offset would need to be part of the solution. I am also still very confused at how two maps which use different projections are even possible to align, since the land profiles would inherently have differently distorted shapes. And I don't think JOSM does this, since it is always focused at high zoom levels. The web map I linked earlier does align them perfectly at world level, but I really don't have evidence that that web app actually uses the exact same tile source. Again, way beyond my experience level and I am not sure I have the skill or time to fix it now, but maybe I will revisit in a few months after I've learned more about JMV, OSM, and mapping/cartography in general.

comment:16 by glebius, 10 years ago

Owner: changed from team to anonymous
Status: newassigned

comment:17 by glebius, 10 years ago

Cc: glebius added
Owner: changed from anonymous to glebius
Status: assignednew

comment:18 by glebius, 10 years ago

Resolution: fixed
Status: newclosed

comment:19 by stoecker, 10 years ago

In [o30243:30249].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain glebius.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.