views:

156

answers:

2

I'm currently working on developing a Google Maps API implementation that overlays topographic data from USGS Terra Server. I think I have it pretty much under hand except that I can't figure out how to determine the name of the quad, name, & scale for the current tile being served from Terra Server. If you check out this site and zoom into the map that information is being displayed so it must be possible:

http://www.trails.com/topomap.aspx?trailid=fgu003-087

Here are links to some articles which explains more how the images are named by Terra Server:

About MSR Maps

STANDARDIZED DATA SET NAMES FOR DRG PRODUCTS

I'm hoping that some geoloc expert out there has already done this and can point me in the right direction. I'd appreciate if you could give me any clues how I might determine this information from the current map view when overlaying the USGS topo data over Google Maps to produce a user experience much like that of the example map about.

Thanks in advance for your help!

A: 

In the example, the trails.com server is delivering the custom tile images through their own CDN and displaying those tiles over top of Google Maps using a .NET WebHandler.

Since you need the data to come from MSRMaps.com and not [Trails.com][3], you will point the MSRMaps.com WebHandler instead.

Below is how trails is doing it. Replace the getTileUrl function with something that makes a call to the msrmaps.com server instead, such as MSR Tile Link

var layer = new GTileLayer(new GCopyrightCollection(''), 1, 21);
layer.getTileUrl = function(a, b) 
{
    var ll = G_NORMAL_MAP.getProjection().fromPixelToLatLng(new GPoint(a.x * 256, (a.y + 1) * 256), b);
    var ur = G_NORMAL_MAP.getProjection().fromPixelToLatLng(new GPoint((a.x + 1) * 256, a.y * 256), b);
    return "http://cdn-www.trails.com/services/TopoGetGoogleMapTile.ashx?z=" + b + "&style=drgsr&ll=" + ll.y + "," + ll.x + "&ur=" + ur.y + "," + ur.x;
}
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
map.setUIToDefault();
var mapType = new GMapType([layer], G_NORMAL_MAP.getProjection(), 'Trails', { errorMessage: google.mapError, textColor: "white", linkColor: "white" });
map.addMapType(mapType);
map.setMapType(mapType);
jojaba
@jojaba - I have no problem retrieving the actual tiles which is accomplished exactly how you describe it. If you re-read my question the problem I need help with is how to figure out what the quad, name, and scale are for a particular latitude/longitude point. Any ideas how you might be able to get that from the MSR API?
Russell C.
+1  A: 

You can use the OGC Style Web Map Server Microsoft also hosts. These have a relatively simple lat/lon/scale structure for fetching data, rather than leaving you guessing about the numbers. Here is a url for Aerial. The Scale variable s ranges from 11-21. The t variable lets you choose between Aerial and Topos. Set t=2 for Topos - here is Topo URL.

To get the quad name and map reference etc. You will have to index the topos and build a database. If you have the Topos on a CD and they are in Tiff format you can use GDALTindex to build this index. Beyond this your queries reduce to Point-in-Polygon type, which you can perform using Net Topology Suite.

Since there is no simple intuitive mapping for all the different map-sets and scales, a precomputed index will be the best way to go.

Gdaltindex can index tif files and produce an index in Shapefile format. This can be mapped into MySQL Geometries using Ogr MySQL support.

whatnick
Russell C.
So you need a reason for why USGS Topos are named the way they are. I believe you will have to convert latlon to UTM and go from there.
whatnick
I have extended my answer with a few pointers about Map Indexing. Hope this helps.
whatnick
@whatnick - Is there any way to build the index in MySQL so that we could query against it when pulling the tiles from USGS and not from local storage or a CD? I'm still a little fuzzy on how you're suggesting we build the index so I would appreciate it if you could provide some additional explanation of how we might do this with the publicly accessible USGS tile data. Thanks!
Russell C.
I will extend my answer with mysql tips.
whatnick