Hpricot + GeoRSS + KML
ShapeWiki now supports import for both KML and GeoRSS. GeoRSS testing is a bit sketchy, as I had a hard time finding GeoRSS feeds with shapes in them.
To import shapes from either GeoRSS or KML, go to the KML Import tab on the top of the page.
With KML import, you can now use Google MyMaps to build shapes, and import the shapes directly into ShapeWiki. Give it a try by 1) creating new map at maps.google.com; 2) using the shape tool to create one or may shapes on your map; 3) copying the URL (via "link to this page" on Google Maps) into the ShapeWiki import.
The import code is straightforward. I use Hpricot for XML parsing, as it makes dealing with XML marginally bearable. I check if the shapes are in folder(s), and if they are, I use the folder names for tags. To make his work, I added an #ancestors method to Hpricot's Elem:
module Hpricot
class Elem
def ancestors
element=self
path=Hpricot::Elements.new
while element.class != Hpricot::Doc do
path.push element
element = element.parent
end
path
end
end
end
. . . which returns a nice Elements array of all the ancestors of the element on which it was called. I use it like so:
shape.tag_list=p.ancestors.search('/folder/name').map{|e|e.inner_html.strip.gsub(' ','_').downcase}.uniq.join(' ')
I was a bit surprised that Hpricot's Elem didn't already have an ancestor method. If I missed something, or there's an easier way to do this, drop me a comment!
Continue reading "Hpricot + GeoRSS + KML"»
ShapWiki gets GeoRSS export
ShapeWiki just got a small update today with GeoRSS feed support. You can get GeoRSS feeds for:
- individual shapes: California
- recently added/updated shapes: recent shapes
- tags: state tag
Check it out by going to maps.google.com and pasting http://shapewiki.com/tags/state.rss into the map search box.
Continue reading "ShapWiki gets GeoRSS export"»
ShapeWiki: a collaborative shape repository
http://shapewiki.com is a an open repository for shapes you can use on Google Maps. It includes a point-and-click editor for creating new shapes, and is backed by a tagged, searchable database so you can find shapes made by others.
There are three export formats:
- JSON-- essentially an array of latitude/longitude pairs with some additional metadata
- JavaScript -- the same JSON array, but with some associated JS to easily allow you to add a GPolygon to your map
- XML
Potential future enhancements include: export as encoded polylines, and import from a variety of formats.
When you try out creating a shape, notice the reference image section on the right-hand side. Enter a URL there to pin an image to the map so you can trace neighborhoods, etc. Here's an image of the neighborhoods in San Francisco: http://real-estate-us.com/images/SanFranciscoNeighbourhoodsCA.gif
Continue reading "ShapeWiki: a collaborative shape repository"»