<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: Creating an image map from SVG</title>
	<atom:link href="http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/</link>
	<description>has a blog</description>
	<pubDate>Tue, 06 Jan 2009 00:34:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jiri Barton</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-1736</link>
		<dc:creator>Jiri Barton</dc:creator>
		<pubDate>Tue, 21 Oct 2008 22:24:04 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-1736</guid>
		<description>Interestingly, I want to do the same thing for my django-worldmap application - http://lurkingideas.net/worldmap/.

Having spent the several hours looking for a solution, it seems the only way to do it is to parse the svg and draw the map again somehow - like you have done.

Thanks, at least I know there is probably no other way :)</description>
		<content:encoded><![CDATA[<p>Interestingly, I want to do the same thing for my django-worldmap application - <a href="http://lurkingideas.net/worldmap/" rel="nofollow">http://lurkingideas.net/worldmap/</a>.</p>
<p>Having spent the several hours looking for a solution, it seems the only way to do it is to parse the svg and draw the map again somehow - like you have done.</p>
<p>Thanks, at least I know there is probably no other way :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alpv</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-1693</link>
		<dc:creator>Alpv</dc:creator>
		<pubDate>Sun, 19 Oct 2008 13:56:09 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-1693</guid>
		<description>Hello David,

Great examples. FYI, you mispelled Ecuador (you wrote Equador).</description>
		<content:encoded><![CDATA[<p>Hello David,</p>
<p>Great examples. FYI, you mispelled Ecuador (you wrote Equador).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul McGuire</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-1229</link>
		<dc:creator>Paul McGuire</dc:creator>
		<pubDate>Fri, 26 Sep 2008 13:57:57 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-1229</guid>
		<description>David -

I noticed that your image map of the world contains many doubled coordinates, that is, consecutive coordinates that are the same x-y pair (probably due to float-to-integer roundoff).  

Here (http://pyparsing.pastebin.com/f6d3558d9) is a pyparsing script to post-process your generated image map - on your map of the world, it removes over 7700 duplicate coords.  The maximum number of duplicates was 14 on line 108.

-- Paul</description>
		<content:encoded><![CDATA[<p>David -</p>
<p>I noticed that your image map of the world contains many doubled coordinates, that is, consecutive coordinates that are the same x-y pair (probably due to float-to-integer roundoff).  </p>
<p>Here (http://pyparsing.pastebin.com/f6d3558d9) is a pyparsing script to post-process your generated image map - on your map of the world, it removes over 7700 duplicate coords.  The maximum number of duplicates was 14 on line 108.</p>
<p>&#8211; Paul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: muyi</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-526</link>
		<dc:creator>muyi</dc:creator>
		<pubDate>Sun, 22 Jun 2008 02:02:57 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-526</guid>
		<description>Hi,

I tried using your svg2imagemap.py script to rescale the Wikipedia BlankMap-World6-Equirectangular.svg map, but the script doesn't seem to work. Did you use it in your example?  The width_ratio and height_ratio formulas don't seem to do anything to my image, and the path coordinates come out way higher than the image size that I gave on the command line.  I'm trying to get an image that is 630px wide.  

Thanks for any help / comments.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I tried using your svg2imagemap.py script to rescale the Wikipedia BlankMap-World6-Equirectangular.svg map, but the script doesn&#8217;t seem to work. Did you use it in your example?  The width_ratio and height_ratio formulas don&#8217;t seem to do anything to my image, and the path coordinates come out way higher than the image size that I gave on the command line.  I&#8217;m trying to get an image that is 630px wide.  </p>
<p>Thanks for any help / comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: giovanni</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-501</link>
		<dc:creator>giovanni</dc:creator>
		<pubDate>Thu, 05 Jun 2008 20:56:59 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-501</guid>
		<description>Hi, I'm tryng your python script, but I'm experiencing some problems.
When I first run the script I got this error:
C:\Python25&#62;python.exe svg2imagemap.py Italia.svg 1000 1000 regioni
Traceback (most recent call last):
  File "svg2imagemap.py", line 49, in 
    raw_width = float(svg.getAttribute('width'))
ValueError: invalid literal for float(): 553.423px

I have a tryed editing line 49 e 50 from:

raw_width = float(svg.getAttribute('width'))

to

raw_width = float(svg.getAttribute('width').replace('px', ''))

But now no errors are displayed, but the result file is 0 byte.

If can be useful for debug the doctype of the file is:



Any help appreciated, thank you</description>
		<content:encoded><![CDATA[<p>Hi, I&#8217;m tryng your python script, but I&#8217;m experiencing some problems.<br />
When I first run the script I got this error:<br />
C:\Python25&gt;python.exe svg2imagemap.py Italia.svg 1000 1000 regioni<br />
Traceback (most recent call last):<br />
  File &#8220;svg2imagemap.py&#8221;, line 49, in<br />
    raw_width = float(svg.getAttribute(&#8217;width&#8217;))<br />
ValueError: invalid literal for float(): 553.423px</p>
<p>I have a tryed editing line 49 e 50 from:</p>
<p>raw_width = float(svg.getAttribute(&#8217;width&#8217;))</p>
<p>to</p>
<p>raw_width = float(svg.getAttribute(&#8217;width&#8217;).replace(&#8217;px&#8217;, &#8221;))</p>
<p>But now no errors are displayed, but the result file is 0 byte.</p>
<p>If can be useful for debug the doctype of the file is:</p>
<p>Any help appreciated, thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Caranorn</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-449</link>
		<dc:creator>Caranorn</dc:creator>
		<pubDate>Thu, 17 Apr 2008 17:00:36 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-449</guid>
		<description>Think I finally got it to work, was pretty simple too:-(. At least I have a test map that's working.

Thanks a lot for this script.</description>
		<content:encoded><![CDATA[<p>Think I finally got it to work, was pretty simple too:-(. At least I have a test map that&#8217;s working.</p>
<p>Thanks a lot for this script.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Caranorn</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-448</link>
		<dc:creator>Caranorn</dc:creator>
		<pubDate>Thu, 17 Apr 2008 14:13:36 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-448</guid>
		<description>Hello David,

I just found this post googling for a way to create an imagemap out of an SVG file. Unfortunately I have 0 programming skill. I have no clue how to run a python script (just downloaded python, but have found no way to run your script with the correct command line). Do you plan on creating an application (.exe) for this? Or could you explain to a dummy like me how to use your script?

I'm working on a map (currently a large .psd file) of a Fantasy world which I'd like to turn into several navigable client side imagemaps (.png's of world, continents, regions, countries, counties). From the low scale world map you could navigate to a large scale county map and get more details etc.</description>
		<content:encoded><![CDATA[<p>Hello David,</p>
<p>I just found this post googling for a way to create an imagemap out of an SVG file. Unfortunately I have 0 programming skill. I have no clue how to run a python script (just downloaded python, but have found no way to run your script with the correct command line). Do you plan on creating an application (.exe) for this? Or could you explain to a dummy like me how to use your script?</p>
<p>I&#8217;m working on a map (currently a large .psd file) of a Fantasy world which I&#8217;d like to turn into several navigable client side imagemaps (.png&#8217;s of world, continents, regions, countries, counties). From the low scale world map you could navigate to a large scale county map and get more details etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul McGuire</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-431</link>
		<dc:creator>Paul McGuire</dc:creator>
		<pubDate>Tue, 01 Apr 2008 05:15:56 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-431</guid>
		<description>David -

I looked at your code a bit, I think you might be spending a lot of time in CaselessPreservingLiteral.  Since you only use this class in Command, and all command args are single characters, could you try this?

def Command(char):
    """ Case insensitive but case preserving"""
    # return CaselessPreservingLiteral(char)
    return oneOf([char.upper(),char.lower()])

You might also get some speed boost from these Regex forms of floating and non-neg numbers:
floatingPointConstant = Regex(r"[-+]?\d*\.?\d*([Ee][-+]?\d*)?")
nonnegativeNumber = Regex(r"\d*\.?\d*([Ee][-+]?\d*)?")

Otherwise, without some real in-depth profiling, I don't see any likely places for improving performance.

Nice utility!
-- Paul</description>
		<content:encoded><![CDATA[<p>David -</p>
<p>I looked at your code a bit, I think you might be spending a lot of time in CaselessPreservingLiteral.  Since you only use this class in Command, and all command args are single characters, could you try this?</p>
<p>def Command(char):<br />
    &#8220;&#8221;" Case insensitive but case preserving&#8221;"&#8221;<br />
    # return CaselessPreservingLiteral(char)<br />
    return oneOf([char.upper(),char.lower()])</p>
<p>You might also get some speed boost from these Regex forms of floating and non-neg numbers:<br />
floatingPointConstant = Regex(r&#8221;[-+]?\d*\.?\d*([Ee][-+]?\d*)?&#8221;)<br />
nonnegativeNumber = Regex(r&#8221;\d*\.?\d*([Ee][-+]?\d*)?&#8221;)</p>
<p>Otherwise, without some real in-depth profiling, I don&#8217;t see any likely places for improving performance.</p>
<p>Nice utility!<br />
&#8211; Paul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-427</link>
		<dc:creator>David</dc:creator>
		<pubDate>Mon, 31 Mar 2008 20:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-427</guid>
		<description>The world map was very complicated to do -- part of the reason I chose the USA map for the example was that it didn't involve getting bogged down in painful meddling in the internals of an SVG file.

Firstly, the link on the world map demo page is going to the core map -- I actually used this variant: http://en.wikipedia.org/wiki/Image:BlankMap-World6-Equirectangular.svg

I edited the SVG file in Inkscape and removed a lot of the tiny islands.  I also had to repeatedly change the scale of the image here, in order to make the output line up with the final image.  This was very trial-and-error.

Then I had to use an extremely long command line, because there is no single group id that includes all countries.  Instead, each country has its two-letter ISO code as an id.  So it looked something like:

python svg2imagemap.py BlankMap-World6-Equirectangular.svg 1000 507 se id ye mg ...[etc]... jp au th ve

In retrospect it might have been easier to edit the SVG file to just remove everything that wasn't a country.

Finally, I hand-edited the output to include better titles than, say, "path5325".

Complicated and painful.  In all honesty, if you need a world map imagemap, it would probably be a lot easier to just rescale the one used on my demo.  (It's far simpler to take the already-rewritten map and just scale all the coordinates than it is to deal with the SVG again.)</description>
		<content:encoded><![CDATA[<p>The world map was very complicated to do &#8212; part of the reason I chose the USA map for the example was that it didn&#8217;t involve getting bogged down in painful meddling in the internals of an SVG file.</p>
<p>Firstly, the link on the world map demo page is going to the core map &#8212; I actually used this variant: <a href="http://en.wikipedia.org/wiki/Image:BlankMap-World6-Equirectangular.svg" rel="nofollow">http://en.wikipedia.org/wiki/Image:BlankMap-World6-Equirectangular.svg</a></p>
<p>I edited the SVG file in Inkscape and removed a lot of the tiny islands.  I also had to repeatedly change the scale of the image here, in order to make the output line up with the final image.  This was very trial-and-error.</p>
<p>Then I had to use an extremely long command line, because there is no single group id that includes all countries.  Instead, each country has its two-letter ISO code as an id.  So it looked something like:</p>
<p>python svg2imagemap.py BlankMap-World6-Equirectangular.svg 1000 507 se id ye mg &#8230;[etc]&#8230; jp au th ve</p>
<p>In retrospect it might have been easier to edit the SVG file to just remove everything that wasn&#8217;t a country.</p>
<p>Finally, I hand-edited the output to include better titles than, say, &#8220;path5325&#8243;.</p>
<p>Complicated and painful.  In all honesty, if you need a world map imagemap, it would probably be a lot easier to just rescale the one used on my demo.  (It&#8217;s far simpler to take the already-rewritten map and just scale all the coordinates than it is to deal with the SVG again.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brahim</title>
		<link>http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/comment-page-1/#comment-404</link>
		<dc:creator>brahim</dc:creator>
		<pubDate>Fri, 28 Mar 2008 19:17:36 +0000</pubDate>
		<guid isPermaLink="false">http://davidlynch.org/blog/2008/03/creating-an-image-map-from-svg/#comment-404</guid>
		<description>Hi David (not the director),

Great tutorial !

What group name did you use for countries in the world wikipedia svg map ?

Thanks in advance !</description>
		<content:encoded><![CDATA[<p>Hi David (not the director),</p>
<p>Great tutorial !</p>
<p>What group name did you use for countries in the world wikipedia svg map ?</p>
<p>Thanks in advance !</p>
]]></content:encoded>
	</item>
</channel>
</rss>
