mike-koch / ets2-mobile-route-advisor

ETS2 / ATS's Route Advisor, for mobile devices
http://mikekoch.me/ets2-mobile-route-advisor
MIT License
134 stars 48 forks source link

Find a Way to Easily Capture Maps #77

Open mike-koch opened 8 years ago

mike-koch commented 8 years ago

A highly requested feature is to include 3rd-party maps (such as ProMods). However there is no easy way to capture maps. There are two options:

denilsonsa commented 8 years ago

For future reference: there has been some discussion about this at issue #79. And the URL for nlhan's ets2-map is: https://github.com/nlhans/ets2-map

Then I wondered, how was http://ets2map.com/ created? I don't know, and the "About" link in that site shows nothing.

But then I found another map: https://map.krashnz.com/ https://forum.ets2mp.com/index.php?/topic/21376-ets2-map/ That map looks awesome! Maybe we should contact them and join forces. I see they used "Leaflet" while we use "Openlayers". No problem, I can convert stuff.

mike-koch commented 8 years ago

I contacted Krashnz (from map.krashnz.com) via the ETS2MP forums a couple hours ago about how the map was generated. I'll post the response here (if I even get one :laughing: )

mike-koch commented 8 years ago

Well, it has been over a week with no response from Krashnz... It looks like either improving the map capture mod or improving the ets2-map solution is our best bet so far :frowning:

mike-koch commented 8 years ago

I've tweaked ets2-map to build a HTML-friendly SVG of the map.... we'll see how well this works, and how long it takes (I had to disable the ContextSwitchDeadlock warning so execution could exceed 60 seconds :laughing: ).

mike-koch commented 8 years ago

Ok, so I gave up on building the SVG using est2-map about 10 minutes later.... there were some road coordinates that made zero sense (9.4E+11 in particular), so I turned it off until I can figure out the min and max coordinates of the map. I tried using Funbit's map capture mod, but I think I set the zoom level too large, as an hour and 1500 screenshots later, it still wasn't finished (and Funbit claimed it should take ~15-20 minutes), so I think that I didn't set something up correctly.


Hey @Funbit, out of curiosity, what zoom level did you use when you built the printable map for ETS2? Also, should a 1920x1080 resolution work fine with the default settings in the .config file? I have a feeling that it shouldn't take over 1.5 hours and 2500 screenshots to generate a printable map.

denilsonsa commented 8 years ago

Do you have some experimental code that exports to SVG? Maybe you forked ets2-map repository and saved your changes to GitHub?

To be honest, for me it is hard/annoying/slow to develop stuff on the Windows machine, so I am very slow regarding anything that requires booting Windows. :-\

mike-koch commented 8 years ago

I tweaked the application to generate a quick and dirty svg using HTML markup; however there were some issues when I tried running it (most likely since I told the program to start from int.MinValue and go to int.MaxValue for both X and Y). I'm going to clean it up first (and probably create a separate executable), and then I'll push it to my fork.

mike-koch commented 8 years ago

The code I wrote up for generating a HTML-friendly SVG can be found at https://github.com/mike-koch/ets2-map/compare/d52dcb8...db1b956. It's very very slow, even using a range of -2000..2000 x -2000..2000 is very slow. Not sure if this is a feasible option or not.

mike-koch commented 8 years ago

It looks like someone used Funbit's tool to build a map of ProMods + RusMap, which I have attached. I have not had a chance to check to see if the scale is the same or not.

http://www.mediafire.com/download/b74886a33ip4fxq/map.png (I didn't want to attach it here due to the size of the image itself)

Koenvh1 commented 8 years ago

Oh, yes, I created that one.

The scale is the same, apart from the UK. Funbit resized the UK to make it the proper size, I left it alone. Therefore there is no need for the calculate coordinates UK logic anymore.

As for the settings: `<?xml version="1.0" encoding="utf-8" ?>

`
denilsonsa commented 8 years ago

Cool! I started rewriting ets2-map code in Python, so that I could explore the data quickly and easily, but never finished it.

Also, I can't download the map:

Direct Access Denied

The page you attempted to load is not intended to be accessed directly.

mike-koch commented 8 years ago

Try this link... this is the one on the forums: http://www.mediafire.com/view/b74886a33ip4fxq/map.png

Koenvh1 commented 8 years ago

Alternatively you can use this URL: https://app.box.com/s/wv331ke4zmabim6zumpp13c4qabiipu0

Funbit commented 8 years ago

Great work @Koenvh1 !

denilsonsa commented 8 years ago

I've sliced @Koenvh1's map and uploaded a version of OpenLayers demo to my ets2-stuff repository. It is also available online.

Then I took some time adjusting the formula to Koenvh1's map. I got it pretty close to the correct values, but it still seems slightly off. If anyone wants to help, look at coords.html and adjust the numbers there. You may also look at the online demo (but you won't be able to edit the formulas there).

To help with the formulas, both online maps (Funbit's map and Koenvh1's map) will print at the JavaScript console the coordinates of where you click. It will be two pairs, one in OpenLayers inverted Y coordinates (ignore this one), and another in the natural image coordinates (look at this one).

Ideally, in the future, the mobile route advisor can have an on-screen configuration of which map tiles to be used.

Koenvh1 commented 8 years ago

Great work @denilsonsa . I am using slightly different coordinates: (x, y, 7.278, 13164, 16260); (Also see https://github.com/Koenvh1/ets2-mobile-route-advisor/blob/promods/js/map.js and https://github.com/mike-koch/ets2-mobile-route-advisor/pull/85)

How did you slice it? I used gdal2tiles-leaflet, but that reverses the x and y.

denilsonsa commented 8 years ago

How did you slice it?

I've described it at the commit message and also at README.md. :smiley:

By the way, you should consider writing down a README for your ETS2-City-Coordinate-Retriever. :wink:

Try these in-game coordinates at coords.html:

It has been a while since the last time I started ETS2, and even longer since I last played it for fun. It's great to see the progress you both did on capturing the cities (using a pretty simple solution).

Koenvh1 commented 8 years ago

Whoops, I should learn how to read :blush:

I've written a short README that should work for most. It's not the most extensive document, but it works (I hope :stuck_out_tongue: )

I am using the same scale as Funbit (unless SCS changed it), so that should not be the issue. I have noticed a little offset, but nothing too bad.

mike-koch commented 8 years ago

@Koenvh1 One question: I noticed in the map.js for promods, all locations are assumed to be at 1:19 scale (every conversion uses the EU conversion, and the UK option is commented out). Did the ProMods team change the scale for UK? I haven't tested that area yet so I thought I'd ask first (plus I'm not home right now so I can't test it for a few hours :laughing: )

Koenvh1 commented 8 years ago

@mike-koch No, but what Funbit did was capture the map, and then shrink the UK to be properly scaled (compared to where Norway is)... I just captured the map and left it that way. Compare the location of Bergen (NO) and Aberdeen (GB) in both maps.

mike-koch commented 8 years ago

Gotcha, I'll check it out later tonight.


By the way @Koenvh1 and @denilsonsa , I went ahead and created a gitter.im room over at https://gitter.im/mike-koch/ets2-mobile-route-advisor. It might be easier to communicate there and in more of a "real-time" environment than over here in the issues section.

dowmeister commented 6 years ago

@mike-koch @denilsonsa @Koenvh1 @Funbit Guys, this thread is really interesting, i'm developer of Trucky ( https://truckyapp.com/ ) now with new Italy DLC i need to extract the whole new map to serve online on my app. I would build it with Leaflet. I've tried Map Mod from Funbit but it seems not working with latest version, tried also ets2-map from nlhan's but got errors building PrefabNode objects.

There is a working way to extract the map with latest game version?

Whatever, awesome work!

Thank you!

Koenvh1 commented 6 years ago

I can't help you with that I'm afraid. Last version introduced the mercator projection for ETS2, which means that maps will now be projected as if they were on a globe. This makes map capturing (and more specifically pixel to coordinate calculation) a whole lot more difficult.

However, I did see this recently: https://www.reddit.com/r/trucksim/comments/7hu1t2/the_good_part_is_that_my_program_worked_with/ No idea what it is, how it works etc., but it might be worth contacting him.

dowmeister commented 6 years ago

Meanwhile i made the map settings mod working with 1.30, here attached.

With some work i was able to capture the map, https://imgur.com/a/99rSf , it takes a while. Now i'm trying to adjust columns and rows to get entire map grabbed.

dowmeister commented 6 years ago

If interested, github project with source code here https://github.com/shardick/ets2-map-settings-mod

Koenvh1 commented 5 years ago

I have created a quicker way, based on ts-map, which I have uploaded here: https://github.com/Koenvh1/ts-map

mike-koch commented 5 years ago

Welcome back 😃 .... I'll have to take a look at your approach when I get some time.... currently backed up on a few other projects at the moment 😆

dowmeister commented 5 years ago

seems great, but why only 5 zoom levels? it's possible to have 8 levels?

Koenvh1 commented 5 years ago

Everything is possible. 😉 Slight nitpick: There are six zoom levels (0, 1, 2, 3, 4, 5).

I set the tile size to 4000×4000, which means that you only have five levels before you reach layer 0 with a single image (or four images with padding). If you set it to something smaller (e.g. 256×256), then you should be able to create more layers. You can also create a more sophisticated pyramid building algorithm, but this suffices for my use case.

dowmeister commented 5 years ago

yeah :D 6 :)

thanks, i will try

Koenvh1 commented 5 years ago

You can see it in action here: https://koenvh.gitlab.io/ets2-map/

denilsonsa commented 5 years ago

That is awesome!

Given that you wrote your own renderer... I wonder if it would be possible to export as some vector format.

OpenLayers has support for vector tiles, look at some examples:

It could be possible to export it as SVG, because that's a well-supported format everywhere. And OpenLayers can use it (without requiring splitting up in tiles): https://stackoverflow.com/q/34416412 I just don't know how large and heavy the resulting SVG would be.

As an extra idea if anyone wants to go beyond, the graphics (i.e. the roads and buildings) could be the SVG format, but all the text could be a separate file that is rendered on top. This would allow for readable text even if the map is rotated or zoomed.

Again, congrats on building your renderer! (And I'm sorry that I won't have time to contribute to this project for the foreseeable future.)

Koenvh1 commented 5 years ago

I did not write my own renderer - I adapted it from https://github.com/dariowouters/ts-map which in turn based it on https://github.com/nlhans/ets2-map (it should show up as a fork from that). I did create the process for capturing the images systematically and turning them into tiles, but I do not want to take credit work the renderer - thank @dariowouters and @nlhans for that.

To answer your question: This would mostly be possible (the renderer currently turns it into a graphic, there is no reason why it couldn't turn it into something else) - however, whilst the roads are vectors, the overlay imagery (rest stops, road numbers, etc) are not. An alternative would be to turn it into OSM XML, so that you could display it using any OSM-compatible style.

meatlayer commented 5 years ago

In develop branch ts-map an easy way to capture map tiles was added, I tested this with max zoom = 8. Works great! Perhaps at the moment it is one of the most really working and useful tools for this.