timwaters / mapwarper

free open source public map georeferencer, georectifier and warper
http://mapwarper.net
MIT License
196 stars 80 forks source link

Satellite layer not showing #146

Closed williame closed 6 years ago

williame commented 6 years ago

I have a clean checkout and am running the server in vagrant.

When I try to rectify a map, only the default base layer works. The satellite map doesn't (I see 401 errors for the tiles in the log).

When I look at your mapshaper.net I can't see the satellite layer. Have you removed it? Is it still expected to work?

https://thinkwhere.wordpress.com/2017/04/06/rectify-new-shortcuts-and-add-layer-features-in-mapwarper-net/

I tried to add a custom layer e.g. Esri by copy-pasting URLs from http://leaflet-extras.github.io/leaflet-providers/preview/ I just get a mismatched tiles :(

williame commented 6 years ago

I found and set mapbox_access_token in config/application.yml but, from looking at the browser dev tools networks tab, I can see the access_token is not actually set on the url :(

I tried using it directly as a custom layer but somehow the URL gets truncated and I see broken urls in the networks tab :(

timwaters commented 6 years ago

It's working on mapwarper.net with the url being something like: https://api.mapbox.com/styles/v1/mapbox/satellite-v9/tiles/256/14/8758/6088?access_token=pk.abacjkbaskcbaiusc

image

timwaters commented 6 years ago

For the layers. The tiles should be in this format: https://example.com/osm/{z}/{x}/{y}.png with no support for {s}

so try https://a.tile.openstreetmap.org/{z}/{x}/{y}.png

timwaters commented 6 years ago

regarding the configuration for Vagrant it runs it in development mode, so be sure to edit the correct file, and restart the server :)

williame commented 6 years ago

I found that I had to 'touch' the layers.erb file to get it to reflect changes in the config. You can edit the config all you like, but if you don't touch the layers file you get served up the same old empty access token url.

Grepping found lots of debris and mapbox urls with someone else's api key in vendor/iO and these have {zoom} instead of {z} in the pattern. Not sure what that is.

Now for a tangent:

I needed the satellite layer because the historic maps I was trying to overlay were so old that the road system was completely unrecognisable; the only correspondence points were some very old farms that survive on the same spot.

And when I got the satellite layer to show using a mapbox access token I got myself and touching the layers.erb, I found that the historic maps were hopelessly inaccurately scaled. The mapwarper just seems to use a single transform to project the whole map. Are there any map rectification software that can distort the overlay to force all correspondence points to line up exactly, even if that means turning the overlay into a mesh?

timwaters commented 6 years ago

I found that the historic maps were hopelessly inaccurately scaled. The mapwarper just seems to use a single transform to project the whole map. Are there any map rectification software that can distort the overlay to force all correspondence points to line up exactly, even if that means turning the overlay into a mesh

The software by default will choose a polynomial fit depending on the number of points that are added to the map. (e.g. only 3 points will use a 2D affine transform, add more points and a better fit will be chosen). You can manually change the algorithm in the control panel on the rectify page. 3rd order polynomial is quite good, with enough points, and Thin Plate Spline works best with lots of points spread across the image and will line them up exactly.

williame commented 6 years ago

Thank you for pointing that out, the spline works brilliantly! :1st_place_medal: