Monday, February 2, 2009

Generate Google Maps tiles with GeoMedia WebMap 6.1

You can use GeoMedia WebMap 6.1 to create Google Maps mashups map tiles with data from GeoMedia warehouses. The WebMap Publisher commands that come out of the box allow you to quickly publish a mashup site, all through easy to use graphical wizards. Although GeoMedia WebMap can dynamically generate the map tiles as users browse the mashup, it can be really slow for users, instead of the couple of seconds wait that they are accustomed to on the public Google Maps site. To improve the performance of the mashup site, there are a couple of things you can do: (a) pre-create the map tiles before hand and (b) group the legend entries. If you don't group the legend entries, each legend entry will have its own set of map tiles; so by grouping the legend entries into a single group, only a single set of map tiles will be generated per zoom scale.

GeoMedia WebMap version 6.1 has a couple of bugs which will give you with some grief. One of them is that the Publisher graphical commands are unable to group the legend entries eventhough there is an option for it on the graphical user interface. The other is that the batch tile generation script has some syntax errors. I have gone through that frustration and will be able to share the steps to actually generate the map tiles successfully in batch and as a group. The steps can be broken down into 3 major tasks: (a) Create a blank Publisher Web Application site, (b) Publish a GeoMedia Workspace to the Web Application, and (c) Generate the map tiles in batch.

Create a blank Publisher Web Application
  1. On the Windows desktop, select Start > All Programs > GeoMedia WebMap > Publisher > Server Configuration Utility.

    The Publisher Server Configuration Utility dialog box appears.

  2. Click Add.

    The GeoMedia WebMap Publisher Application And Service Wizard appears.

  3. Click Next.

    The New Web Application and Service Wizard appears.

  4. Click Next and in the Name field type in a name, e.g. mygooglemaps


  5. Click Next in the following screens until the wizard is completed.










  6. Click Next.

    The new web site is created.
Publish a GeoMedia Workspace
  1. In GeoMedia, open up a workspace with your warehouses connected and features displayed in the map window.


  2. In the Legend, click the Groups tab.


  3. In the Legend, right click on the white space.

    A context menu appears.

  4. Select New Group. Name the group as Group1 if you like. Drag and drop the legend entries onto the group so that they appear underneath the group node, as shown below.


  5. Click the GeoMedia WebMap Publisher Administrator button.

    The Open Application dialog box appears.

  6. In the Open Application dialog box, select a Publisher Web Application, e.g. mygooglemaps.
  7. Click Open.

    The GeoMedia WebMap Publisher Administrator dockable toolbar appears.

  8. Click the Map Content button.

    The Map Content dialog box appears.

  9. Click the Themes node.


  10. Click Add Theme.


  11. In the tree field, right click on the Theme1 node.


  12. Select Add Map.


  13. Click Get from active map window.


  14. Expand the Map1 node.


  15. Click on the Legend node.


  16. Click Synchronize Legend.


  17. Expand the Legend node and click the Group1 node. Toggle on Publish this group as a single layer in mashups.

    Note: in version 6.1, this option does not work properly. Each legend entry will be pulished as a single map tile layer per zoom scale on the mashup web site eventhough the group option is on.


  18. Click OK.
  19. In the GeoMedia WebMap Publisher Administrator toolbar, click the Settings button.

    The Settings dialog box appears.

  20. Click the Map tab.


  21. In the Map format field, select PNG.
  22. In the Viewer type field, select Browser (GM Mashups).


  23. Click OK.
  24. In the GeoMedia WebMap Publisher Administrator toolbox, click Publish and Populate the GeoWorkspace button and select Publish the GeoWorkspace Contents to the Metadata.

    The contents are published to the web site.
  25. Close GeoMedia if you like.
Generate the Map Tiles in Batch
  1. In Windows Explorer, browse to the GeoMedia WebMap folder containing the batch tile generation files tilegen.bat and tilegen.vbs (in C:\Program Files\GeoMedia WebMap\Publisher\TileGen\) as shown below.


  2. Copy the TileGen folder to your mashup web site folder C:\WebMap Publisher Projects\mygooglemaps\ as shown below.


  3. Using your favorite text editor, create the file tilegen.xml and placed in the folder containing the batch tilegen files e.g. C:\WebMap Publisher Projects\mygooglemaps\TileGen\.

    Note: An example of the contents of the tilegen.xml file is as follows:



    <?xml version="1.0" encoding="utf-8" ?>
    <tilegen appname="wpgm"
    minzoom="1"
    maxzoom="4"
    xmin="-180"
    xmax="180"
    ymin="85.0511287798066"
    ymax="-85.0511287798066"
    autorange="no"
    overwrite="no">
    <le>1</le>
    <le>2</le>
    </tilegen>


    However, the ymin and ymax attributes do not work properly because of a coding error in the tilegen.vbs script. You can modify the tilegen.vbs file to correct the error if you like if you want to use the range to limit the map tiles generation.
  4. I prefer to use the following as the tilegen.xml file. Replace appname="mygooglemaps" with the name of your Publisher Web Application. You can define the min and max zoom levels of map tiles to generate (the levels range from 1 to 17, I think). I set autorange to "yes" to let GeoMedia WebMap automatically determine the range of the map tiles to generate.


    <?xml version="1.0" encoding="utf-8" ?>
    <tilegen appname="mygooglemaps"
    minzoom="1"
    maxzoom="4"
    autorange="yes"
    overwrite="no">
    </tilegen>


  5. Open up a command prompt and change the directory to the location of my tilegen files. Type in the following:

    C:\> tilegen tilegen.vbs


  6. At the end of the process, you can browse the tilecache folder to see the generated map tiles as shown below.

8 comments:

WLB said...

How do I get the Google Map mashup Key? Tq.

dominoc925 said...

WLB, you can go sign up for a key here http://code.google.com/apis/maps/signup.html

WLB said...

Tq. That helps. Now I have another problem. THis error come out when I try the tilegen.

W:\WebMap Publisher Projects\SalisExecBrowser\TileGen>cscript tilegen.vbs //NoLo
go "tilegen.xml"
XML config file 'tilegen.xml' could not be parsed.

Maybe my tilegen.xml not complete as I follow exactly your xml file.

dominoc925 said...

WLB,there were some xml encoding errors on the post. I have corrected the examples.

WLB said...

d0min0c, is that the full script? anyway, do we have to set the coordinate system of our geoworkspace to follow those of google map? if so, whats the format? any csf file I can download? tq.

dominoc925 said...

WLB, Google Maps are in Mercator projection. You have to set your geoworkspace to Mercator projection on WGS84 datum before you publish.

WLB said...

Hi dominoc,

Im having problem generating the tiles. When i generate, this came out...

C:\TileGen>cscript tilegen.vbs //NoLogo "a.xml"
Zoom level range: 1 - 2
Autorange: True
Overwrite: True
Range not provided
added legend entry 2
Calling GenerateTiles with no range
C:\TileGen\tilegen.vbs(189, 3) GWMPub: GenerateTiles: ProcessLERecordset: Method
'~' of object '~' failed

-Any Idea?

WLB said...

Hi d0min0c,
I also have another problem. Once map is published (overlayed with google map), if click on legend entry, it wont show on the map. Here's the log.

GeoMedia Web Map Version 06.01.03.08

Fri Jul 08 14:14:17 2011(0.000005) - Process ID 4704
Fri Jul 08 14:14:17 2011(0.000047) - Q:5 T:1
Fri Jul 08 14:14:17 2011(0.001101) - Loading C:\WebMap Publisher Projects\s1\connection\connect.mss
Fri Jul 08 14:14:17 2011(0.006831) - Enter CGWMMapServer::Load
Fri Jul 08 14:14:17 2011(0.006901) - Enter CGWMMapServer::SetCoordinateSystem C:\WebMap Publisher Projects\s1\connection\s1.csf
Fri Jul 08 14:14:17 2011(0.006936) - Setting CS
Fri Jul 08 14:14:17 2011(0.017561) - Exit CGWMMapServer::SetCoordinateSystem 0(0)
Fri Jul 08 14:14:17 2011(0.017820) - Loading DisplayRange
Fri Jul 08 14:14:17 2011(0.017836) - Loading Citerias
Fri Jul 08 14:14:17 2011(0.017853) - Loading Display Rules
Fri Jul 08 14:14:17 2011(0.017870) - Loading Scripts
Fri Jul 08 14:14:17 2011(0.017886) - Loading Connections
Fri Jul 08 14:14:17 2011(0.023369) - Reading Libraries
Fri Jul 08 14:14:17 2011(0.023398) - Name:1 Type:1
Fri Jul 08 14:14:17 2011(0.023419) - Entering AddLibraryConnection Name:s1LibraryConnection ConnString:TYPE=GDO;PROGID=Access.GDatabase;LOCATION=C:\WebMap Publisher Data\s1.mdb;SOURCE=;
Fri Jul 08 14:14:17 2011(0.023445) - Exiting AddLibraryConnection - 0
Fri Jul 08 14:14:17 2011(0.023459) - Loading Data Sources
Fri Jul 08 14:14:17 2011(0.023474) - Loading Auto Scales
Fri Jul 08 14:14:17 2011(0.023506) - Loading Queries
Fri Jul 08 14:14:17 2011(0.023521) - Loading Markers
Fri Jul 08 14:14:17 2011(0.036800) - Publisher: ModLibraryUtils: ValidateLibraryConnection : library :s1LibraryConnection connection string :TYPE=GDO;PROGID=Access.GDatabase;LOCATION=C:\WebMap Publisher Data\s1.mdb;SOURCE=;
Fri Jul 08 14:14:17 2011(0.036875) - Publisher: ModLibraryUtils: ValidateLibraryConnectionInMapServer : another connection exists with conn string :TYPE=GDO;PROGID=Access.GDatabase;LOCATION=C:\WebMap Publisher Data\s1.mdb;SOURCE=;
Fri Jul 08 14:14:17 2011(0.057015) - Entering GetFromLibrary LibraryConnection,GeoMedia.LegendEntry,DefaultTheme.S1-Default S1 Theme|5
Fri Jul 08 14:14:17 2011(0.057054) - Library Name LibraryConnection