Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support maptiles based on GCJ02 (Chinese) #64

Closed
johnd0e opened this issue Jan 16, 2019 · 27 comments
Closed

Support maptiles based on GCJ02 (Chinese) #64

johnd0e opened this issue Jan 16, 2019 · 27 comments
Labels
enhancement New feature or request plugin

Comments

@johnd0e
Copy link
Contributor

johnd0e commented Jan 16, 2019

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 16, 2019

There are currently two attempts to fix the problem.

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 16, 2019

Some links from former discussion:

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 16, 2019

@modos189 could you explain the reason for this change: 6d3e284?

Also I'm interesting what is the source of transforming algorithm.
I found similar:

And here are also different 'point-in-polygon' algorithm implementations: #65 (comment)

@modos189
Copy link
Contributor

modos189 commented Jan 16, 2019

@modos189 could you explain the reason for this change

Previously, the fix coordinates included most of India, all of South and North Korea, the Philippines, Vietnam, Mongolia, Thailand, and a number of other countries:
http://programmerz.ru/images/76604/BG9LI.jpg

Code in 6d3e284 more accurately indicates the borders of China, so as not to affect other countries. I took it here: iitc-project/ingress-intel-total-conversion#1188

@modos189
Copy link
Contributor

Here I managed to partially solve the problem.

BIG plus 1: Do not change the coordinates of portals
BIG plus 2: No changes to other plugins are made

Minus:
With a zoom of 16, to the right sometimes not loaded tiles.
With a zoom of 18, this gets worse and the right side of the screen is already without tiles.

The fact is that due to the correction of coordinates the map moves and goes beyond the boundaries for which the tiles are loaded.

By the way, now the correction of coordinates applies to all maps (except satellite and hybrid)

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 17, 2019

Is it possible to provide this solution to other basemap-plugins?

Code in 6d3e284 more accurately indicates the borders of China

So there is complex polygon now. Doesn't it affect the performance? Or maybe better make 2-steps check?
edit: I see isInGoogle is that 1st step that I mean.

the right side of the screen is already without tiles.

Do you have ideas how to fix it?

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 17, 2019

Also I'm interesting what is the source of transforming algorithm.

Well, I see that the source is mentioned in that PR:

// The algorithm of transforming WGS-84 to GCJ-02 comes from:
// https://on4wp7.codeplex.com/SourceControl/changeset/view/21483#353936

So I wonder why these lines were removed?

P.S.
Just for reference: here are related author's blog's entries:

@modos189
Copy link
Contributor

Is it possible to provide this solution to other basemap-plugins?

Yep, that's what I want to do.

So there is complex polygon now. Doesn't it affect the performance?

Visually, I do not notice the difference.

edit: I see isInGoogle is that 1st step that I mean.

I don't know what that is. And it's not used anywhere.

the right side of the screen is already without tiles.

Do you have ideas how to fix it?

I fixed this in all maps except Google. Now I do not know how to fix

So I wonder why these lines were removed?

Mistakenly deleted. Now returned.

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 17, 2019

I found error in the code (mistype). Also I have concerns about some style's elements.
So I will prepare PR.

@modos189
Copy link
Contributor

modos189 commented Jan 17, 2019

Since there are both maps that require coordinate correction and those that do not require it, I suggest pass an optional parameter when initializing the map.
Example:

            var mapLayer = new L.TileLayer(baseUrl + address, {
                attribution: 'map tiles by autonavi.com, plugin written by GMOogway.',
                subdomains: '1234',
                layer: layer,
                type: '',
                minZoom: minZoom,
                maxNativeZoom: maxZoom,
                maxZoom: 20,

                needFixChinaOffset: true
            });

            layerChooser.addBaseLayer(mapLayer, '高德 ' + name);

@modos189
Copy link
Contributor

I found a solution to fix google maps

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 17, 2019

I suggest pass an optional parameter when initializing the map.

I would be perfect solution.

But I still have concerns about leaflet monkey-patching in fix-googlemap-china-offset script.
I wonder if it could be implemented via leaflet plugin instead.

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 19, 2019

We need to make here a list of known maptiles providers, in order to check:

  • which tiles need correction, and which don't.
  • does area of Hong Kong and Macau is distorted or not.

Even more, we need 2 lists: first for providers included with iitc, and second for all others.

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 19, 2019

Included:

  • Google.com (except satellite and hybrid)
  • CartoDB
  • gmaps-gray
  • Bing
  • Kartverket
  • Here WeGo (no public access to Chinese maptiles)
  • OpenCycleMap
  • OpenStreetMap
  • Stamen
  • Yandex

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 19, 2019

Chinese:

  • Google.cn
  • Baidu
  • AutoNavi
  • NavInfo?
  • TianDiTu
  • GaoDe
  • Geoq
  • Soso
  • Alibaba Cloud
  • Tencent
  • ...

Others:

  • MapQuest
  • Mapbox
  • Esri
  • Thunderforest
  • ...

@magicbug2013
Copy link

@johnd0e
Hong Kong and Macau: WGS84
google map(except satellite and hybrid): gcj02
baidu map: bd09
gaode map and other china maps: gcj02
all the other maps are correct.

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 20, 2019

Hong Kong and Macau: WGS84

There could be difference depending on map. In current code (#72) HK positions are also processed for Baidu map.
So we really need to check HK for every Chinese map, to make sure that it's Baidu-only.

gaode map and other china maps: gcj02

We also need to check all their variations (incl. satellite/hybrid).
Do you have sample plugins for other china maps?

all the other maps are correct.

According Wikipedia Here are also in GSJ02. Could you check it?

@magicbug2013
Copy link

Hong Kong and Macau: WGS84

There could be difference depending on map. In current code (#72) HK positions are also processed for Baidu map.
So we really need to check HK for every Chinese map, to make sure that it's Baidu-only.

gaode map and other china maps: gcj02

Do you have sample plugins for other china maps?

all the other maps are correct.

According Wikipedia Here are also in GSJ02. Could you check it?

Too complicated? I think we can use gedo-map + fix-china-map-gcj02-offset in China. Otherwise, we can use Google map directly without fix-china-map-gcj02-offset. We don't use baidu-map (bd09), and now baidu-map can't be displayed in intel.

baidu map in intel:
image

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 20, 2019

Otherwise, we can use Google map directly without fix-china-map-gcj02-offset

We fix-china-map-offset for Google, don't we?

baidu map in intel:

How have you got this screen?

@magicbug2013
Copy link

We fix-china-map-offset for Google, don't we?

yes, but if I have gaode map in china, why use google map? google map update is not in timely, In China, gaode map is enough.

How have you got this screen?

I used the same method as gaode map, but it didn't display correctly.

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 20, 2019

gaode map is enough

Ok. And what is difference between 'gaode' and 'autonavi'?

I used the same method as gaode map, but it didn't display correctly.

May be this can help: https://github.com/muyao1987/leaflet-tileLayer-baidu

@magicbug2013
Copy link

Ok. And what is difference between 'gaode' and 'autonavi'?

gaode=autonavi ^^

May be this can help: https://github.com/muyao1987/leaflet-tileLayer-baidu

ok

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 20, 2019

@modos189
Copy link
Contributor

May be to use 2 parameters in which to pass a list of layers that need correction?
needFixChinaGCJ02Offset: ['roads']
or
needFixChinaBD09Offset: ['roads'] // only for baidu

@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 23, 2019

May be to use 2 parameters in which to pass a list of layers that need correction?

As I stated here #72 (comment), we need to test some real maps before we could make proper decisions.

  1. It's possible that we could leave hybrid and satellite excludes internal (for google), and not expose any option for this.
  2. As well, I have not seen Baidu map yet, so I am not sure if we ever need some special handling for it.
    It's possible that we just remove all baidu-related stuff.

@johnd0e johnd0e added enhancement New feature or request plugin labels Jan 23, 2019
@johnd0e
Copy link
Contributor Author

johnd0e commented Jan 26, 2019

johnd0e pushed a commit to johnd0e/ingress-intel-total-conversion that referenced this issue Jan 28, 2019
In current state it doesn't function.
Maybe someone reimplement it in future.
More info here: IITC-CE#64.
modos189 added a commit that referenced this issue Mar 13, 2019
* Modify "China" boundary for offset fix plugin
iitc-project/ingress-intel-total-conversion#1188 #2

* Update Fix Google Map offsets in China to GoogleMutant. But not working =(
The plugin changes coordinates, but the change is not applied

* An example of a working solution. Described in more detail in a task
#64

* Smooth operation with map, fixed get map options, fixed download of map tiles (except Google maps)

* fix-googlemap-china-offset: fix style issues

lint:
* `let` is not in es5
* 'HK_LENGTH' is assigned a value but never used
* 'original' is defined but never used

style:
* == vs ===
* Mixed spaces and tabs
* fix indents, missed/extra/trailing spaces, missed semi

* Fix offset in Google maps

* Rename to fix-china-offset.user.js

* Edited the documentation, because now plugin works not only in Google maps

* fix-googlemap-china-offset: refactoring

divide PRCoords into 2 distinct functions:
* plugin.fixChinaOffset.isInGoogle
* plugin.fixChinaOffset.gcjObfs

added stub for old fix-googlemap-china-offset plugin

* fixup! fix-googlemap-china-offset: refactoring

* Revert changes in Leaflet.GoogleMutant.js

* Rename fix-china-offset -> fix-china-map-offset

* Previous indent returned

* Update plugins/fix-china-map-offset.js

Co-Authored-By: modos189 <[email protected]>

* Update plugins/fix-china-map-offset.js

Co-Authored-By: modos189 <[email protected]>

* Update plugins/fix-china-map-offset.js

Co-Authored-By: modos189 <[email protected]>

* fix-china-map-offset: Baidu support

* Sources refactored to be closer to upstream https://github.com/Artoria2e5/PRCoords
* Baidu support
* Clarify comment about usage

* fix-china-map-offset: appied to googleMutant

* fix-china-map-offset: fix filename

* fix-china-map-offset: fixme: options for HongKong and map type

* fixup! fix-china-map-offset: fixme: options for HongKong and map type

* fix-china-map-offset: refactor (intermediate function eliminated)

* fix-china-map-offset: refactor (redefine leaflet methods cleaner)

* fix-china-map-offset: cosmetics (restore original source indents)

* fix-china-map-offset: change leaflet extending

do not touch L.GridLayer
extend L.TileLayer and L.GridLayer.GoogleMutant

* fix-china-map-offset: set 'needFixChinaOffset' option in boot.js

* fix-china-map-offset: fix: put actions into setup function

* fix-china-map-offset: patch GoogleMutant in plugin completely (not in boot.js)

* fixup! fix-china-map-offset: cosmetics (restore original source indents)

* fix-china-map-offset: remove Baidu-stuff

In current state it doesn't function.
Maybe someone reimplement it in future.
More info here: #64.

* fix-china-map-offset: shorten 'namespace' access

* fix-china-map-offset: fix: L.Util may not be available yet

* fix-china-map-offset: fix: namespace conflict
@johnd0e
Copy link
Contributor Author

johnd0e commented Mar 28, 2019

Fixed by #68

@johnd0e johnd0e closed this as completed Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin
Projects
None yet
Development

No branches or pull requests

3 participants