Open Artoria2e5 opened 7 years ago
Tested and fixed...
👍
Should I bump the version to 0.0.2 or something?
For future reproducibility, I grabbed a "SIMPL" borders shapefile from http://thematicmapping.org/downloads/world_borders.php (CC-BY-SA), fed it into http://www.mapshaper.org/, ran a pass of visvalingam (weighted) at 25%, dumped it as geojson and extracted the "China" bit. This gives a polygon with 197+8 (hainan) vertices, which should be possible to further reduce by running a heavier second pass at 50% or giving up precision around the coasts (doing this helps the islands too.)
This json comes from the first 25% pass on the whole-world map. Roughen it by a bit around the coasts, make it a single polygon, add some exceptions around Hong Kong and Macau -- that's all it takes to ready it for replacing the current magic values obtained from randomly eyeing on Google Earth.
TM_WORLD_BORDERS_SIMPL-0.3.zip → CN.zip
The original SIMPL shapefile comes with a 285-vertex mainland with 31 smaller islands. Admittedly the simplification would be more straightforward if I have removed other countries in the first pass input.
@Artoria2e5 , could you tell more about differences between this patch and upstream. I see baidu-related stuff removed, anything else?
And is your code based on mentioned link https://on4wp7.codeplex.com/SourceControl/changeset/view/21483#353936 or not?
The algorithm is based on that thing. Basically everything we know for sure about GCJ-02 is.
The upstream (also me) is basically this with baidu and some utility functions.
... and switch to a new implementation just for tidying up.
This commit should help unfortunate souls who enabled the plugin while in Viet Nam, Mongolia, or just HKSAR. (But well, my polygon is still an approximation, and folks near the borders will still see problems.)
I am not entirely sure about the "pnpoly" licensing. There is a MIT-licensed js implementation (https://github.com/substack/point-in-polygon) based on the documentation (dead, no archive) instead of the 8-line code, and I can switch to that if necessary.