Custom maps

Custom maps

Postby Artsi » Tue Jun 24, 2008 12:24 am

How can I create custom maps from saved .jpg images? I did not find any instructions to do that. My ST release is 2.0.3074
Artsi
 
Posts: 3
Joined: Mon Jun 23, 2008 3:15 am
Location: Finland

Postby TomasR » Tue Jun 24, 2008 1:45 am

In ST2 that feature is not available. I am, still, working on a plugin with this features. Release date...sometime soon I hope.
TomasR
Donated!
Donated!
 
Posts: 265
Joined: Mon Dec 12, 2005 1:31 pm
Location: Stockholm, Sweden

Custom Map

Postby ander » Sun Jun 29, 2008 1:50 pm

Good luck! I look forward to the result. Please let me know.
ander
 
Posts: 1
Joined: Mon Jun 23, 2008 12:24 pm

Re: Custom Map

Postby trell » Mon Jun 30, 2008 1:09 am

ander wrote:Good luck! I look forward to the result. Please let me know.

:lol:
trell
 
Posts: 165
Joined: Sat May 21, 2005 2:17 pm

Re: Custom maps

Postby markw65 » Sun Jul 13, 2008 11:37 pm

Artsi wrote:How can I create custom maps from saved .jpg images? I did not find any instructions to do that. My ST release is 2.0.3074


I've just added a feature to the Apply Routes Plugin that is able to do this - or at least, it will be able to do so as soon as I add the settings page to let you configure it :-)

Currently, its just hardcoded to support the various flavors of google maps.

The next version - real soon now, but I dont have much time this week - will have the settings page, and instructions for setting up the maps.

It also has a lot of other possibilities - such as adding the google "street" overlay to any map (eg the terraserver maps, or a jpg etc).
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby AllanHvass » Sat Aug 09, 2008 10:28 am

Monshi - looking forward to that feature. It was one of my favorite features of ST1 to have my own custom maps - very useful for MTB when you're in the woods... Satelite photos just show all green trees and there's no roads to display in the roads map either.
Kind Regards
Allan Hvass
Using Garming Edge 305HR+CAD (and lots of other GPS gadgets)
AllanHvass
Donated!
Donated!
 
Posts: 25
Joined: Sun May 28, 2006 4:44 pm
Location: Høsterkøb, Denmark

Postby AllanHvass » Thu Dec 04, 2008 4:16 pm

Did this ever happen? I'm still longing for getting this functionality back :wink:
Kind Regards
Allan Hvass
Using Garming Edge 305HR+CAD (and lots of other GPS gadgets)
AllanHvass
Donated!
Donated!
 
Posts: 25
Joined: Sun May 28, 2006 4:44 pm
Location: Høsterkøb, Denmark

Postby markw65 » Thu Dec 04, 2008 5:46 pm

AllanHvass wrote:Did this ever happen? I'm still longing for getting this functionality back :wink:


This has come up a lot, and I've mentioned a couple of times that it should be easy to do using Apply Routes (provided the maps are in a format that IE can understand - eg jpg or png).

Basically you just need a bit of html/javascript, and then point one of the Map Provider url's at your script (which can live on your computer). http://maps.myosotissp.com/openlayers.html would be a good template to start from.

It should even be possible to setup the maps as ground overlay's on Google earth.

I'll be happy to help with the scripts. I would create an example - except I dont have any custom maps. If someone gives me a clear example of what they want, I'll show them how to do it...
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby CHnuschti » Sat Dec 06, 2008 4:23 am

Hello. Want to point out that the plugin of Monshi, supposed to be able to handle "every" map format, has been repeatedly "announced" now for over one year. So in the meanwhile I have some doubts if this will be ever completed.
I respect and appreciate the work put in this, and I am also aware that this hole thing is strictly voluntary, however I think some clear words of intention or abandonement would be appropriate.

I also would welcome if in ST2 the simple "custom maps" feature of ST1 would be brought back.

@markw65
I can provide a map as *.bmp (which is not in "WGS84" format/projection) with coordinates and separate tracks. As well as the same map with the tracks already integrated so that you have the example how a result should look like.

Regards
CHnuschti
 
Posts: 257
Joined: Tue Feb 13, 2007 3:28 am
Location: Switzerland

Postby TomasR » Fri Dec 12, 2008 7:31 am

..it will be completed. I promise.

I will set down some time to fix it so it hopefully will work easily for the normal user.

not much left....
TomasR
Donated!
Donated!
 
Posts: 265
Joined: Mon Dec 12, 2005 1:31 pm
Location: Stockholm, Sweden

Postby markw65 » Sat Dec 13, 2008 2:06 am

CHnuschti wrote:@markw65
I can provide a map as *.bmp (which is not in "WGS84" format/projection) with coordinates and separate tracks. As well as the same map with the tracks already integrated so that you have the example how a result should look like.


Yes, please do. That would be helpful.

I think I have a solution for WGS84. See my next post.
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby markw65 » Sat Dec 13, 2008 2:44 am

I was sent an example WGS84 map, and I've set up a template that should work for any WGS84 map in a format that IE can display.

I've put a zip file here

It contains a modified version of the openlayers map, together with custom_maps.js.

To use, unpack the files to eg C:\Custom.

Then, in ST, change the url for one of the map providers to be:

file:///C:/Custom/openlayers.html#t=OpenStreetMapMapnik&

If you put your files somewhere else, replace any spaces in the path with %20 (so, eg /My%20Documents/, rather than /My Documents/) - this is due to a bug in the plugin which I'll fix in the next release.

To add custom maps, just put the image file(s) in the same folder, and edit custom_maps.js.

Most of the options should be obvious.
- name is what will appear in the "layer switcher" control.
- url identifies the file. It can either be a relative path from the "Custom" directory, or an arbitrary url (if the custom map is available online somewhere, for example).
- proj specifies the projection. If your map coordinates are in degrees, you probably want EPSG:4326. If they're in meters, you probably want EPSG:900913.
- overlay controls whether the map is a base layer, or an overlay. Overlays are probably best, because then you can use any of the base layers for the rest of the world, with your maps overlaid.
- opacity controls the opacity of the layer, if you decide to make it an overlay (so you can see the basemap through it).

Note also that its an array - you can specify as many custom maps as you like (just specify each one between "{" and "}" per the template, and separate them with ",").
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby gerhard » Sat Dec 13, 2008 7:30 pm

markw65 wrote:I was sent an example WGS84 map, and I've set up a template that should work for any WGS84 map in a format that IE can display.


I have tried it by putting up a jpg with s/n/e/w coordinates in an activity but it does not show.
(The .jpg is a map covering approximately the area.)

What is width/height?
Can layers be controlled when using as a map?
Should the layer be visible in the dropdown in the Activity Page?

Any possibility to get screen overlay for GE in the same way?
gerhard
Contributor!
Contributor!
 
Posts: 1747
Joined: Mon Nov 27, 2006 7:07 pm
Location: Sweden

Postby markw65 » Sat Dec 13, 2008 10:12 pm

gerhard wrote:I have tried it by putting up a jpg with s/n/e/w coordinates in an activity but it does not show.
(The .jpg is a map covering approximately the area.)


What is width/height?


The width/height of the image in pixels.

Can layers be controlled when using as a map?
Should the layer be visible in the dropdown in the Activity Page?


You will just select the map provider that you setup in the settings page.

That will by default have all the custom maps enabled, and whichever base map you chose behind it. You can then use the layer switcher to choose a different base layer, or turn individual custom maps on or off (eg if you had both "street" and "satellite" maps for the same area, you could switch between them this way).

In the ST Route panel, you dont get access to the layer switcher, so all the custom maps will be enabled.

Any possibility to get screen overlay for GE in the same way?


Yes (or at least, a ground overlay). Should just be a few lines of code in gmaps.html. You should just need to copy that file locally, include custom_maps.js, and create the ground overlay in the eiDone function. The only thing I can think of that wouldnt work is the Where In the World overlay (because you cant do cross domain XMLHttpRequests).
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby pkan » Sun Dec 14, 2008 5:55 pm

It looks like you've mixed up East and West. And I presume that scale_lat and scale_lon are in degrees-per pixel, not pixels-per-degree. In projected coordinates it would be meters-per-pixel.
Code: Select all
     north: 45.82954951640815000,
     east: 11.44745545109904400,
     scale_lat: 0.00002302568741775, /* pixels-per-degree */
     scale_lon: 0.00002302568741776, /* pixels-per-degree */

     /*
       south:45.773551044608155,
       west:11.536587887093154,
     */

I haven't tried it since I don't have any map in WGS84 lat/long or Spherical Mercator (= Google projection = EPSG:900913).

In the general case, you probably won't be able to overlay maps, since maps in different projections won't match unless they are warped to a common projection.
pkan
Donated!
Donated!
 
Posts: 145
Joined: Fri May 12, 2006 2:26 pm
Location: Sweden

Postby gerhard » Sun Dec 14, 2008 6:23 pm

I got the OpenStreetMap overlay working. One thing to note is that the example lists "east" and "west", but that should be switched, or at least a note that users on the east hemisphere should change this.
It would be good if the name set in custom_maps.js were propagated to openlayers.html

It took some tries before it worked. I do not know what was happening:
* No Custom layer at all first.
* Occasionally the "Custom" layer is greyed out.
* No Image
* Track invisible and start marker at center of track (but popup for distance at correct location).

When it has started working, then I cannot recreate the problems. I guess I need to try a JavaScript debugger.

Other notes:
.tif is not supported.
I tried the Swedish EPSG code, but cannot get it working or find what openlayers.org supports.

Monshi's CustomMap plugin is really good IMO, a user fiendly (as much as maps can be...), reading data from digital maps and calibration. The extremely versatile AR plugin also have a use I believe: It is easier to handle web overlays for instance. Getting GroundOverlay for GE would be very useful: Using with simulations. I have not looked in to the tips yet.
gerhard
Contributor!
Contributor!
 
Posts: 1747
Joined: Mon Nov 27, 2006 7:07 pm
Location: Sweden

Postby markw65 » Sun Dec 14, 2008 6:42 pm

pkan wrote:It looks like you've mixed up East and West. And I presume that scale_lat and scale_lon are in degrees-per pixel, not pixels-per-degree.


Oops. You're right. Never post late at night :-)

I've updated the zip with things switched around correctly. That probably explains why gerhard was having trouble getting it to work...
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby markw65 » Sun Dec 14, 2008 6:48 pm

gerhard wrote:I got the OpenStreetMap overlay working. One thing to note is that the example lists "east" and "west", but that should be switched, or at least a note that users on the east hemisphere should change this.


Yes, I just fixed the east west problems (and fixed the corresponding errors in openlayers.html).

It would be good if the name set in custom_maps.js were propagated to openlayers.html


Also fixed.
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby CHnuschti » Wed Dec 17, 2008 1:32 pm

I tried to display a custom map for testing purposes. The map comes as JPG. I use Firefox on WinXP (while IE is still installed), just for the record, I am not sure if this affects anything.
While it does indeed display following your instructions, I notice the size of the map does NOT change if I change the scale_lon , no matter which values I enter. My map is width 3001 and height 2001 pixels (so rectangular), but it is displayed as square. FYI.

I have also a suggestion. I suppose most maps come in a format where the "national" grid is not wgs84, so wgs84 typically would be slighty oblique against these "national" grids. However, i suppose most "national" maps come with a metric (or imperial) grid (meters/miles etc.). Now for some national grids there are formuals available for transformation wgs84<>national grid. I really can't speak for the world, but I know for example for Sweden and Switzerland such formulas do exist.
Having such formulas, the track of the gps (given as wgs84) could be "translated" into national coordinates and therefore also displayed in such national maps. Could be an approach.

regards
CHnuschti
 
Posts: 257
Joined: Tue Feb 13, 2007 3:28 am
Location: Switzerland

Postby markw65 » Wed Dec 17, 2008 2:35 pm

CHnuschti wrote:I tried to display a custom map for testing purposes. The map comes as JPG. I use Firefox on WinXP (while IE is still installed), just for the record, I am not sure if this affects anything.
While it does indeed display following your instructions, I notice the size of the map does NOT change if I change the scale_lon , no matter which values I enter. My map is width 3001 and height 2001 pixels (so rectangular), but it is displayed as square. FYI.


Ugh.

Well, so far Im doing pretty well. 15 lines of code and already 3 different bugs :-)

So I was using scale_lat to scale both lat and lng. I've fixed that, and updated the archive.

But even so, I dont understand how your map came out square - if its 3001x2001 and its being scaled by the same amount in both directions, it should have been rectangular. If you want to send me your custom_maps.js, I can take a look to see what's going wrong (besides the bug I just fixed!).

I have also a suggestion. I suppose most maps come in a format where the "national" grid is not wgs84, so wgs84 typically would be slighty oblique against these "national" grids. However, i suppose most "national" maps come with a metric (or imperial) grid (meters/miles etc.). Now for some national grids there are formuals available for transformation wgs84<>national grid. I really can't speak for the world, but I know for example for Sweden and Switzerland such formulas do exist.
Having such formulas, the track of the gps (given as wgs84) could be "translated" into national coordinates and therefore also displayed in such national maps. Could be an approach.


Right - and openlayers allows you to do just that. But in that case, you cant use the map as an overlay (because it doesnt warp the images, just the vector data). I dont think I've quite got things setup to do that in Custom.zip.

By the way, I did get your email (with a non WGS84 map) and will be experimenting with it to see exactly what I *can* do inside the openlayers framework as soon as I get some time. I will update Custom.zip and post here when I get something working.
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby CHnuschti » Wed Dec 17, 2008 4:34 pm

Hello. Your fixed files of the archive are working correctly now, the *.jpg is displayed in the correct size now, when using scale_lat & scale_lon.

Also tested several maps (*.bmp BTW), listed in the custom_maps.js as array (each defined within {} and separated by ,). It also works.
Basically, your solution more or less corresponds to the custom maps feature of Sporttracks v1.x. If in ST1 you used slightly distorted maps (in order to have a rectangular, horizontal/vertical wgs84 grid), now you just can use the maps from ST1 in ST2. The *.config files in the ...\SportTracks\Images\Custom Maps\ folder also alredy contain the N/S/W/E coordinates, you just have to copy and insert them into the custom_maps.js.

Thanks for your work so far.

There is still one major point IMO. If you use custom maps, I suppose usually you want just to use them alone. From this point of view, the actual layout using them as layers IMO does not make much sense. Would it not be possible to have just a blank sheet/frame for these custom maps? This way, you could avoid to download the "useless" background map each time you zoom/move around etc.. It just would speed up things, no?

regards

EDIT: Preferably 3 or 4 such blank sets. For example, I use different detailed maps (originally 1:25000/50000/100000). Depending what type of activity (MTB/Road/Running), I use different custom maps when viewing the activities.
CHnuschti
 
Posts: 257
Joined: Tue Feb 13, 2007 3:28 am
Location: Switzerland

Postby markw65 » Wed Dec 17, 2008 5:46 pm

CHnuschti wrote:Hello. Your fixed files of the archive are working correctly now, the *.jpg is displayed in the correct size now, when using scale_lat & scale_lon.

Also tested several maps (*.bmp BTW), listed in the custom_maps.js as array (each defined within {} and separated by ,). It also works.
Basically, your solution more or less corresponds to the custom maps feature of Sporttracks v1.x. If in ST1 you used slightly distorted maps (in order to have a rectangular, horizontal/vertical wgs84 grid), now you just can use the maps from ST1 in ST2. The *.config files in the ...\SportTracks\Images\Custom Maps\ folder also alredy contain the N/S/W/E coordinates, you just have to copy and insert them into the custom_maps.js.



Great!

There is still one major point IMO. If you use custom maps, I suppose usually you want just to use them alone. From this point of view, the actual layout using them as layers IMO does not make much sense. Would it not be possible to have just a blank sheet/frame for these custom maps? This way, you could avoid to download the "useless" background map each time you zoom/move around etc.. It just would speed up things, no?


One of the reasons for having a background map (from my point of view) was that if I select an activity in an area not covered by my map, I'd like to see *something* in the map display.

But if the background maps are causing speed problems, then yes. In that case, you could set your custom maps as base layers, and not get the other layers at all.

Or you could delete the other base layers from the openlayers.html file (you can delete any of the unwanted layers.push(new ...) statements. If you remove all the google maps layers, you could also remove the corresponding library from the header:
Code: Select all
 <script src="http://maps.google.com/maps?file=api&amp;v=2&amp..." type="text/javascript"></script>

Similarly for the yahoo and microsoft maps.

Note that you do need at least one base layer - although you could just insert an empty one.

EDIT: Preferably 3 or 4 such blank sets. For example, I use different detailed maps (originally 1:25000/50000/100000). Depending what type of activity (MTB/Road/Running), I use different custom maps when viewing the activities.


Well, you can make several copies of the openlayers.html, and edit each one to point at a different custom_maps.js (or just insert the code from custom_maps.js directly into each copy).

But it would also be possible to set things up so that it picked which map to use based on the zoom (so you could have the 1:25000, 1:50000 and 1:100000 maps all specified in the same custom_maps.js file, and switch between them by zooming in and out).

If that would be useful, I would be happy to extend the template to do that - although having a set of maps to test it out on would help...
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby gerhard » Wed Dec 17, 2008 6:28 pm

I have looked a little into using custom projections.
The API used is here:
http://dev.openlayers.org/apidocs/files ... rs-js.html
Some info about overlay:
http://docs.openlayers.org/spherical_mercator/

Many projections should be supported by using the proj.4 library, but those of interest to me (Swedish grid - EPSG 3021) is not supported. This is likely because openlayers.org is not supporting proj4s in the official build (requiring a private repository) as getUnits() returns NULL.

Only Google style maps (all default?) allows overlay. I believe this means that it should be possible to overlay the "default" maps with other projections, at least to test the fitting.
gerhard
Contributor!
Contributor!
 
Posts: 1747
Joined: Mon Nov 27, 2006 7:07 pm
Location: Sweden

Postby markw65 » Wed Dec 17, 2008 7:39 pm

gerhard wrote:I have looked a little into using custom projections.
The API used is here:
http://dev.openlayers.org/apidocs/files ... rs-js.html
Some info about overlay:
http://docs.openlayers.org/spherical_mercator/

Many projections should be supported by using the proj.4 library, but those of interest to me (Swedish grid - EPSG 3021) is not supported. This is likely because openlayers.org is not supporting proj4s in the official build (requiring a private repository) as getUnits() returns NULL.


Its fully supported, just not included. All you have to do is include proj4.js after including openlayers.js. You can get proj4 here. Just put proj4js-compressed.js in the same directory as openlayers.html, and add a script tag for it after the one for openlayers.js.

I didnt include it, because what I've done so far only works with WGS84 anyway...

Im not sure if proj4 has EPSG 3021 built in, but you can certainly add it:
Code: Select all
 Proj4js.defs["EPSG:3021"] = "+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs";

according to http://spatialreference.org/ref/epsg/3021/

Also note that even in the absense of proj4, you can supply a function to translate between any two projections. See OpenLayers.Projection.addTransform. Of course this rapidly gets out of hand when more than a couple of projections are involved...

Only Google style maps (all default?) allows overlay. I believe this means that it should be possible to overlay the "default" maps with other projections, at least to test the fitting.


I dont quite follow. The only requirement for overlays is that the base map and the overlay have "similar" projections. Similar basically means that the lines of lattitude and longitude line up. And thats just because the only transformations openlayers supports on image tiles are horizontal and vertical scaling.

But also note that the current version of the AR plugin assumes that the projection is "google-like" when displaying maps in the ST Route control, and produces very odd results for other projections. The "AR - Routes" control supports any projection (since its all taken care of by the web page itself).

The various rendering engines in openlayers *do* support arbitrary linear transformations on images - although its only used for transforming icons. I might experiment with writing a layer that warps the image on top of the WGS84 maps. It will probably work reasonably well for relatively small areas.
markw65
Donated!
Donated!
 
Posts: 420
Joined: Fri May 09, 2008 4:35 pm
Location: San Jose, CA

Postby CHnuschti » Thu Dec 18, 2008 5:14 am

Hello. Did try the version of several openlayers.html / custom_map.js in order to be able to display different custom maps separately.

It does work. This way:
- Setup (with the editor for example) custom_maps.js for your purpose/specific map, then save it as custom_maps1.js, custom_maps2.js etc.
- Then setup openlayers.html, there change line 15 to ...custom_maps1.js , custom_maps2.js etc. according to your sets, and save it as openlayers1.html, openlayers2.html etc.
- Finally go into Sporttracks2=>Settings=>Plugins=>Apply Routes Plugin=>Map Providers and for each mapset change the chosen provider to you local file
file:///C:/custom/openlayers1.html#t=OpenStreetMapMapnik&
etc.

A point I notice is the different quality of the display, when using the IDENTIC custom maps (here as *.bmp) in Sporttracks 1 and Sporttracks 2. While in ST1, the quality is perfectly preserved, no matter what zoom you use, in ST2 you get a generally decreased quality that in some cases looks particularly crappy. So i suppose in ST2 the map is not taken as it is but rendered once more?
See the comparison (left ST1, right ST2):
Image
I would welcome if it was possible to just take the map (=image) as it is, without additional rendering). Judging ST1, this is obviously possible. Or is it at least possible to increase that rendering quality in ST2?

Third I was not able to NOT have your script displaying the background map of google or whatever it is. Tried some things, none worked.
- I edited the openlayers.html and deleted all lines between
// create OSM layer
and
if (window.custom_maps && custom_maps.length)
But there is still a background map displayed

- If I just delete the line
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp; ...
then no custom map is loaded at all and the rotating arrow ("download") in the route view spins forever.



You other version you suggest is:
But if the background maps are causing speed problems, then yes. In that case, you could set your custom maps as base layers, and not get the other layers at all.

Yes, but HOW? I suppose its in the custom_maps.js, the line
overlay: true,
How shall this line look like?

An elegant overcome of these problems might be, if you create just a few lines in your script for custom maps ALONE?
So that in the route view of ST2 in the down arrow menu with AR-hybrid, AR-Mars etc. there are e.g. 3 separate lines custom map 1, custom map 2 etc.? This way also the other possiblity of custom maps as overlay is preserved. Just a thought.

As for a feature of choosing different sets of custom maps depending upon the zoom factor, IMO its not recommendable, i suppose it would interfere to much with the users preferences/"operations".

Last question. Does your script somehow operate with the browsers cache? This would explain some "renewing" problems I experienced here.

regards
CHnuschti
 
Posts: 257
Joined: Tue Feb 13, 2007 3:28 am
Location: Switzerland

Next

Return to * General Info *

Who is online

Users browsing this forum: No registered users and 0 guests

cron