I can see myself!

Google Earth now shows the City of Nanaimo in beautiful 10cm colour.

With our last ortho project, the City ensured that we could provide the images to consumer-oriented providers like Google. We did this for two reasons. First, it would allow local residents, businesses, and educators to benefit from the higher resolution imagery in Google Earth and Maps (eventually). Second, now that our GIS applications support KML output, staff can use Google Earth Pro to visualise and communicate more effectively. In particular, they are able to easily create movies that tell a story in three dimensions.

I’m impressed by the fidelity of the images in Google Earth. If you compare them with our CityMap site (IE/Windows only. Sorry – I’m working on it…), they are actually somewhat cleaner, though there may be some smoothing. The compression format we are using introduces some artefacts.

Nanaimo City Hall in CityMap:

Portion if Nanaimo City Hall in CityNan

Nanaimo City Hall in Google Earth:

Portion if Nanaimo City Hall in Google Earth

This update gives me a stronger platform (and incentive) for providing additional services to our residents, such as interactive KML layers and GeoRSS feeds.

earth.nanaimo.ca data sample

Thanks to the other Michael Jones (data acquisition, not CTO) at Google for working with me to get these images loaded. I heard a funny story from a colleague about a business card mix-up that resulted in him waking up the CTO in India at 4am to talk about data provision. Apparently he was quite nice, despite the confusion :)

If anyone else sees the same value in providing their orthos to Google as I do, please get in touch with me and I’ll pass along the correct Michael’s contact info.

-J

OpenSearch for GIS sites…

Earlier today, Rob over at Spatial Miscellany posted an article on how to add an EDN (ESRI Developer Network) search to Internet Explorer 7.

I don’t have a real use for EDN search, but just for fun I’ve created a page where anyone can add this OpenSearch to their modern (Firefox 2.0 or IE 7) browser without having to copy and paste URLs.

Adding an EDN search to your browser

Anybody feel like creating a resource page that stores a bunch of GIS searches in this easily-accessible format? :)

I’d love to see the earth browsers and online maps support this sort of feature as well. For instance, it would be great if I could build some plugins to allow Google Earth users to easily search my municipality’s geospatial data without relying on the Google KML Search to know what they are interested in.

-J

KML Support in MapGuide 1.1.0

With the final 1.1.0 release of MapGuide Open Source just around the corner, I thought I’d talk about the initial support for KML 2.1 (Google Earth 4.0 or newer only) in this release.

Key Features:

  • Any Map Definition that you publish to the MapGuide server repository can be accessed as KML
  • KML 2.1 Regions are used, so you only serve data when necessary
  • Published scale ranges are honoured (to an approximate level with oblique views)
  • MapTips are published as feature descriptions

As an example, I’m going to use the default MapDefinition that comes with the Sheboygan sample data set (available on the MapGuide Open Source website).

Here is a picture of the map as it appears in Autodesk MapGuide Studio:

Sheboygan Map Definition in MapGuide Studio

This is the request I sent to the MapAgent to view this MapDefinition in Google Earth:

http://localhost:8008/mapguide/mapagent/mapagent.fcgi?
OPERATION=GetMapKml&
VERSION=1.0.0&
MAPDEFINITION=Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition

Which gave me the following KML:

Sheboygan Map Definition as KML

Which in turn looks like this in Google Earth:

Sheboygan Map Definition in Google Earth

Although you could just push out any of your maps to Google Earth, in practice you will likely want to create a special Map Definition just for GE so that you can account for some of the display limitations in Google Earth.

So, how do you publish your maps to Google Earth? Using the ever-helpful MapGuide MapAgent. The MapAgent is a URL-based web service which interacts with the MapGuide Server based on the parameters you pass. In the case of KML, the primary parameter that is important to you is OPERATION=GetMapKml. Full documentation for this parameter can be found on the KML in MapGuide RFC page, but the basics follow…

Required parameters:

  • OPERATION=GetMapKml – tells the MapAgent that you want a KML version of the Map Definition
  • VERSION=1.0.0 – can currently only be 1.0.0
  • MAPDEFINITION=<PathToYourMapDefinition> – path to your map definition in the repository. For example: Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition

Optional parameters:

  • FORMAT=<KML|KMZ|XML> – allows you to publish in either KML, compressed KML (KMZ) or, for easy debugging, XML
  • DPI=<default: 96> – is used to perform the viewer-to-map calculations required to honour the scale ranges defined in your map
  • USERNAME=<Anonymous or whatever you want>(unsupported) can be used to prevent an authentication prompt on first request. Generating this initial request from a server-side script that creates a session is the preferred method.
  • PASSWORD=<no value for Anonymous, or whatever you want>(unsupported) as above.

If you want to play around with these parameters some more to see what they do, the MapAgent test html pages that come with MapGuide 1.1.0 include test cases for the KML service. This can be found by default at http://localhost:8008/mapguide/mapagent/index.html .

If you have any questions about this functionality, or want to help expand the functionality offered by this tool, please join us in the MapGuide Open Source community.

-J

Using MultiGeometry for Mouseover Effects in Google Earth KML

Well, this has been sitting in my half-finished pile for a long time, so I figured I’d better polish it up and kick it out the door (I’m practicing for my kids). There are probably other sites that have documented this, but here’s my version.

Google’s KML format has some really strong styling elements built into it, similar to HTML/CSS. In a single <Style> tag, you can specify how points, lines, and polygons should display in the Google Earth browser. For instance:

<Style id="parcelNormal">
  <IconStyle>
    <scale>0.8</scale>
    <Icon>
      <href>http://maps.google.com/mapfiles/kml/pal4/icon56.png</href>
    </Icon>
  </IconStyle>
  <LabelStyle>
    <scale>0</scale>
  </LabelStyle>
  <LineStyle>
    <color>ff4090ff</color>
    <width>10</width>
  </LineStyle>
  <PolyStyle>
    <color>00000000</color>
  </PolyStyle>
</Style>

This allows you to define polygons, points, and lines, all referencing the same style definition. Definitely a space saver over having to define the style against each feature:

<Placemark>
  <name>238 Franklyn St.</name>
  <styleUrl>#parcelNormal</styleUrl>
  <Point>
    <coordinates>-123.938788334,49.1646409443,0</coordinates>
  </Point>
</Placemark>
<Placemark>
  <name>238 Franklyn St.</name>
  <styleUrl>#parcelNormal</styleUrl>
  <Polygon>
    <outerBoundaryIs>
      <LinearRing>
        <coordinates>
          -123.93904811,49.16434558280001,0
          -123.939274779,49.16457225540001,0
          -123.939105984,49.1646449658,0
          -123.93924107,49.1647800536,0
          -123.938876261,49.16493630590001,0
          -123.938424057,49.1646143977,0
          -123.93904811,49.16434558280001,0
        </coordinates>
      </LinearRing>
    </outerBoundaryIs>
  </Polygon>
</Placemark>

And this is what it looks like:

Basic Styling

There is also a <StyleMap> entity that allows you to specify a style to apply when a feature is active and when a feature is inactive:

<StyleMap id="parcel">
  <Pair>
    <key>normal</key>
    <styleUrl>#parcelNormal</styleUrl>
  </Pair>
  <Pair>
    <key>highlight</key>
    <styleUrl>#parcelHighlight</styleUrl>
  </Pair>
</StyleMap>

Unfortunately, the only feature type that triggers this normal/highlight switch is the point:

Highlight Style on Point

The secret to working around this is to provide a point feature as part of every line or polygon Placemark that you want to be affected by a mouseover. Then, when the user hovers over the point, the line or polygon is affected by the stylemap that applies to that composite feature. The key to doing this is a “wrapper” called MultiGeometry. MultiGeometry allows you to have multiple geometries tied to a single feature. For example:

<Placemark>
  <name>238 Franklyn St.</name>
  <styleUrl>#parcel</styleUrl>
  <MultiGeometry>
    <Point>
      <coordinates>-123.938788334,49.1646409443,0</coordinates>
    </Point>
    <Polygon>
      <outerBoundaryIs>
        <LinearRing>
            <coordinates>
              -123.93904811,49.16434558280001,0
              -123.939274779,49.16457225540001,0
              -123.939105984,49.1646449658,0
              -123.93924107,49.1647800536,0
              -123.938876261,49.16493630590001,0
              -123.938424057,49.1646143977,0
              -123.93904811,49.16434558280001,0
            </coordinates>
        </LinearRing>
      </outerBoundaryIs>
    </Polygon>
  </MultiGeometry>
</Placemark>

As you can see, both the point and the polygon are affected:

Highlight Style on MultiGeometry

This trick is useful for those hand-crafting their KML, but it is also possible to build this kind of construct in some of the KML generating tools out there. For instance, in Safe Software‘s FME, you can generate a point at the centroid of a polygon with a CenterPointReplacer, and then merge the polygons and their centroids using an Aggregator before writing this out into KML format (pdf). You can even generate the StyleMap elements (see format docs for details). In MapGuide Open Source, I use the GetPointInRegion() method to determine the centroid of the polygon, and build my MultiGeometry from this and the polygon coordinates. Most other GIS software has similar functionality.

The final example shown here is available for download in KML, XML and TXT formats.

-J

Interesting MapGuide Open Source bundling strategy

Earlier today, Adena posted about Autodesk’s government solutions bundle that includes Map 3D, Raster Design, MapGuide and Google Earth Pro.

From the DLTSolutions (an Autodesk Government Reseller) website, the Autodesk / Google bundle actually looks like a pretty good deal, with the package costing considerably less than the sum of the parts.

What I found really interesting is that Autodesk is positioning the MapGuide Open Source licensing level into their offerings. This is markedly different than other companies that only sell/support the “commercial” version of their open source-based applications, but it makes sense to offer it as an option. This allows organisations to choose the price/functionality level that works best for them.

-J