<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ItOpen - Open Web Solutions, WebGis Development &#187; JavaScript</title>
	<atom:link href="http://www.itopen.it/category/programmazione/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.itopen.it</link>
	<description>[lang_en]Open Web Solutions: WebGis, Open Source development[/lang_en][lang_it]Soluzioni WebGIS e sviluppo software Open Source[lang_it]</description>
	<lastBuildDate>Tue, 31 Jan 2012 14:19:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>TileStache Django tiny wrapper</title>
		<link>http://www.itopen.it/2012/01/09/tilestache-django-tiny-wrapper/</link>
		<comments>http://www.itopen.it/2012/01/09/tilestache-django-tiny-wrapper/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 17:47:09 +0000</pubDate>
		<dc:creator>Alessandro Pasotti</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[WebGis]]></category>

		<guid isPermaLink="false">http://www.itopen.it/?p=697</guid>
		<description><![CDATA[This is the second part of the story about my experiments with the wonderful TileStache that I started with TileStache and Polymaps SVG experiments. First, I would like to thank Michal for the quick patch inclusion, the Polymaps patch is still waiting for the pull and the Django admin patch is awating for somebody to [...]]]></description>
			<content:encoded><![CDATA[<p>This is the second part of the story about my experiments with the wonderful TileStache that I started with <a href="http://www.itopen.it/2012/01/05/polymaps-tilestache-and-svg-css-styling-issues/">TileStache and Polymaps SVG experiments</a>.</p>
<p>First, I would like to thank Michal for the quick patch inclusion, the Polymaps patch is still waiting for the pull and the Django admin patch is awating for somebody to take care of that 18-months-old bug.</p>
<p>My experiments have continued with Django integration, I just wanted to see how easy it was (and it was really easy indeed). There aren&#8217;t any clear advantages using a Django app instead of the standalone TileStache server, but writing the wrapper was a nice exercise to learn something more about TileStache and Polymaps, and having all the pieces into one place is always tempting for me (not to mention that you can dribble the <a href="http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing">CORS</a> completely).</p>
<p>The wapper consists in a single router rule in urlconf:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">    url<span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^tiles/(?P&lt;layer_name&gt;[^/]+)/(?P&lt;z&gt;[^/]+)/(?P&lt;x&gt;[^/]+)/(?P&lt;y&gt;[^/]+)<span style="color: #000099; font-weight: bold;">\.</span>(?P&lt;extension&gt;.+)$'</span>, <span style="color: #483d8b;">'pm_points.views.tiles'</span>, name=<span style="color: #483d8b;">'tiles_url'</span><span style="color: black;">&#41;</span>,</pre></div></div>

<p>&#8230; a view for the tiles (get_config implements a singleton to avoid parsing TileStache config every time):</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #808080; font-style: italic;"># proper imports go here...</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> tiles<span style="color: black;">&#40;</span>request, layer_name, z, x, y, extension<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    Proxy to tilestache
    {X} - coordinate column.
    {Y} - coordinate row.
    {B} - bounding box.
    {Z} - zoom level.
    {S} - host.
    &quot;&quot;&quot;</span>
    config = get_config<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    path_info = <span style="color: #483d8b;">&quot;%s/%s/%s/%s.%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>layer_name, z, x, y, extension<span style="color: black;">&#41;</span>
    coord, extension = TileStache.<span style="color: black;">splitPathInfo</span><span style="color: black;">&#40;</span>path_info<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>
    mimetype, content = TileStache.<span style="color: black;">getTile</span><span style="color: black;">&#40;</span>config.<span style="color: black;">layers</span><span style="color: black;">&#91;</span>layer_name<span style="color: black;">&#93;</span>, coord, extension<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> HttpResponse<span style="color: black;">&#40;</span>content, mimetype=mimetype<span style="color: black;">&#41;</span></pre></div></div>

<p>&#8230; and a simple view for the map:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> home<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;
    Pass layers by
    &quot;&quot;&quot;</span>
    config = get_config<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    layer_urls = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> l <span style="color: #ff7700;font-weight:bold;">in</span> config.<span style="color: black;">layers</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">isinstance</span><span style="color: black;">&#40;</span>config.<span style="color: black;">layers</span><span style="color: black;">&#91;</span>l<span style="color: black;">&#93;</span>.<span style="color: black;">provider</span>, TileStache.<span style="color: black;">Providers</span>.<span style="color: black;">Vector</span>.<span style="color: black;">Provider</span><span style="color: black;">&#41;</span>:
            layer_urls.<span style="color: black;">append</span><span style="color: black;">&#40;</span>reverse<span style="color: black;">&#40;</span><span style="color: #483d8b;">'tiles_url'</span>, args=<span style="color: black;">&#91;</span>l, <span style="color: #483d8b;">'{Z}'</span>, <span style="color: #483d8b;">'{X}'</span>, <span style="color: #483d8b;">'{Y}'</span>, <span style="color: #483d8b;">'geojson'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'%7B'</span>, <span style="color: #483d8b;">'{'</span><span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'%7D'</span>, <span style="color: #483d8b;">'}'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> render_to_response<span style="color: black;">&#40;</span><span style="color: #483d8b;">'home.html'</span>, <span style="color: black;">&#123;</span> <span style="color: #483d8b;">'layer_urls'</span> :  layer_urls<span style="color: black;">&#125;</span>, context_instance=RequestContext<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>&#8230; and a template for Polymaps (I paste the js part only):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> po <span style="color: #339933;">=</span> org.<span style="color: #660066;">polymaps</span><span style="color: #339933;">,</span>
        map<span style="color: #339933;">,</span>
        layers <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
        stylist<span style="color: #339933;">;</span>
        jQuery<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            map <span style="color: #339933;">=</span> po.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">container</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;map&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>po.<span style="color: #660066;">svg</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;svg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">center</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>lat<span style="color: #339933;">:</span> <span style="color: #CC0000;">40</span><span style="color: #339933;">,</span> lon<span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">zoomRange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">16</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">zoom</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>po.<span style="color: #660066;">interact</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>po.<span style="color: #660066;">hash</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #339933;">;</span>
&nbsp;
            map.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>po.<span style="color: #660066;">image</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">url</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://s3.amazonaws.com/com.modestmaps.bluemarble/{Z}-r{Y}-c{X}.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            stylist <span style="color: #339933;">=</span> po.<span style="color: #660066;">stylist</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> d.<span style="color: #660066;">geometry</span>.<span style="color: #660066;">type</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'_'</span> <span style="color: #339933;">+</span> d.<span style="color: #660066;">properties</span>.<span style="color: #660066;">id</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">title</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> d.<span style="color: #660066;">properties</span>.<span style="color: #000066;">name</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
                <span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #009900;">&#123;</span><span style="color: #339933;">%</span> <span style="color: #000066; font-weight: bold;">for</span> lay_url <span style="color: #000066; font-weight: bold;">in</span> layer_urls <span style="color: #339933;">%</span><span style="color: #009900;">&#125;</span>
            <span style="color: #003366; font-weight: bold;">var</span> layer <span style="color: #339933;">=</span> po.<span style="color: #660066;">geoJson</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">url</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;{{ lay_url|safe }}&quot;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">zoom</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>z<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    <span style="color: #000066; font-weight: bold;">return</span> z<span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">id</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pmcollection'</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;load&quot;</span><span style="color: #339933;">,</span>  stylist<span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'show'</span><span style="color: #339933;">,</span> stylist<span style="color: #009900;">&#41;</span>
                <span style="color: #339933;">;</span>
            map.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>layer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            layers.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>layer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#123;</span><span style="color: #339933;">%</span> endfor <span style="color: #339933;">%</span><span style="color: #009900;">&#125;</span>
&nbsp;
            map.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>po.<span style="color: #660066;">compass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                .<span style="color: #660066;">pan</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            map.<span style="color: #660066;">container</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;class&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;mymap&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Quick and dirty, it also dynamically adds layers to the Polymap.</p>
<p>This story continues with: <a href="http://www.itopen.it/2012/01/11/tilestache-vector-simplify-provider/">TileStache Vector simplify provider</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itopen.it/2012/01/09/tilestache-django-tiny-wrapper/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Polymaps, TileStache and SVG CSS styling issues</title>
		<link>http://www.itopen.it/2012/01/05/polymaps-tilestache-and-svg-css-styling-issues/</link>
		<comments>http://www.itopen.it/2012/01/05/polymaps-tilestache-and-svg-css-styling-issues/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 16:38:00 +0000</pubDate>
		<dc:creator>Alessandro Pasotti</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[WebGis]]></category>

		<guid isPermaLink="false">http://www.itopen.it/?p=682</guid>
		<description><![CDATA[A few days ago I started playing with Polymaps and TileStache, two very promising WebGIS building tools. The final goal of this experiments was the integration with Django. Polymaps Polymaps is a Javascript library aimed to display svg maps in a web page, recently I&#8217;ve watched to an interesting talk about a Django-powered app built [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I started playing with <a href="http://polymaps.org/">Polymaps</a> and <a href="http://tilestache.org/">TileStache</a>, two very promising WebGIS building tools.</p>
<p>The final goal of this experiments was the integration with Django.</p>
<h2>Polymaps</h2>
<p>Polymaps is a Javascript library aimed to display svg maps in a web page, recently I&#8217;ve watched to an interesting talk about a Django-powered app built on top of Polymaps: </p>
<p><iframe src="http://blip.tv/play/AYLUmmQC.html?p=1" width="550" height="442" frameborder="0" allowfullscreen></iframe><embed type="application/x-shockwave-flash" src="http://a.blip.tv/api.swf#AYLUmmQC" style="display:none"></embed></p>
<p>The main reason to give Polymaps a try is the interesting support to tiled vector layers, as far as I know a unique feature.</p>
<p>I&#8217;ve found the documentation of Polymaps a bit obscure and still incomplete (I just hope it isn&#8217;t another facade Open Source product where the lack of documentation and community support limits the use to commercial projects).</p>
<p>A quick look in the code shows no comments and rather obscure variable names, debbugging this library would certainly be a nightmare if you&#8217;re not the author, if you compare the source code with OpenLayers&#8217;s code you get the idea.</p>
<p>BTW I managed to make it work in a few hours (with all the server stuff).</p>
<h2>TileStache</h2>
<p>TileStache is a python library aimed to build, cache and manage map tiles. It&#8217;s similar to TileCache in scope and uses the well known Mapnik renderer while the data provider is implemented with shapely and OGR and can read the most widely used formats (postgis, shapefile, geojson).</p>
<p>TileStache is the ideal companion to Polymaps because it can handle and cache vector tiles (geojson) through the Vector class (don&#8217;t even try to use the PostgreSQL class you can find in Goodies, it&#8217;s kind of unofficially deprecated and it will let you waste your time).</p>
<p>I had to fork the project on github and made a pull request to fix the missing &#8220;port&#8221; parameter to the DB connection since I&#8217;m using a not-standard port.</p>
<h2>SVG CSS</h2>
<p>I admit I am a true beginner with SVG and while I was trying to experiment with the stylist features of Polymaps  I discovered some counter-intuitive (at least for me, coming from XHTML CSS) behaviours:</p>
<p>You can define styles in three ways:</p>
<ol>
<li>CSS rules</li>
<li>&#8220;style&#8221; attribute of the SVG element</li>
<li>individual attributes (&#8220;stroke&#8221;, &#8220;fill&#8221; etc. etc.) of the SVG element</li>
</ol>
<p>Strange enough, the priority is top-down, while I would have expected that point 3 had a higher priority.</p>
<p>Another thing worths noting is that what distinguish a polygon from a linestring in the Polymaps generated &#8220;path&#8221; SVG element is just that the &#8220;d&#8221; element (which contains the geometry) ends with a &#8220;Z&#8221;.</p>
<p>This is a linestring:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">d</span>=<span style="color: #ff0000;">&quot;M101.99999715555555,189.9999971369224</span>
<span style="color: #009900;">L75.00000142222234,219.00000190473258</span>
<span style="color: #009900;">L75.00000142222234,242.49999834108655</span>
<span style="color: #009900;">L94.49999928888906,242.99999806558844</span>
<span style="color: #009900;">L102.49999928888906,255.4999976705726</span>
<span style="color: #009900;">L101.99970702222231,256&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>;</pre></div></div>

<p>This is a polygon:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;path</span> <span style="color: #000066;">d</span>=<span style="color: #ff0000;">&quot;M95.07080533333351,256.00000052462633</span>
<span style="color: #009900;">L0,196.67516186124612</span>
<span style="color: #009900;">L0,192.0000022835775</span>
<span style="color: #009900;">L0,128.0000001888236L0,70.92093168072711</span>
<span style="color: #009900;">L175.92470186666674,0.000006325172648757871</span>
<span style="color: #009900;">L192,0.000006325172648757871</span>
<span style="color: #009900;">L256,0.000006325172648757871</span>
<span style="color: #009900;">L256,64.00000444302805</span>
<span style="color: #009900;">L256,128.0000001888236</span>
<span style="color: #009900;">L256,160.99230434784874</span>
<span style="color: #009900;">L113.66593991111131,256.00000052462633Z&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>;</pre></div></div>

<p>Styling the plygon fill without hitting linestring in a GEOMETRYCOLLECTION layer turned out to be quite troublesome.</p>
<p>I ended up with a CSS-3 attribute CSS rule:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.layer</span> path <span style="color: #00AA00;">&#123;</span>
fill<span style="color: #00AA00;">:</span> cyan<span style="color: #00AA00;">;</span>
fill-opacity<span style="color: #00AA00;">:</span> .85<span style="color: #00AA00;">;</span>
stroke<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#012</span><span style="color: #00AA00;">;</span>
stroke-linecap<span style="color: #00AA00;">:</span> round<span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.layer</span> <span style="color: #993333;">circle</span> <span style="color: #00AA00;">&#123;</span>
fill<span style="color: #00AA00;">:</span> cyan<span style="color: #00AA00;">;</span>
fill-opacity<span style="color: #00AA00;">:</span> .85<span style="color: #00AA00;">;</span>
stroke<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#012</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Don't fill in SVG */</span>
<span style="color: #6666ff;">.layer</span> path<span style="color: #00AA00;">:</span>not<span style="color: #00AA00;">&#40;</span><span style="color: #00AA00;">&#91;</span>d$<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;Z&quot;</span><span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#123;</span>
fill<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
stroke-<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>I wonder if there is a better way&#8230;</p>
<p>This story continues with: <a href="http://www.itopen.it/2012/01/09/tilestache-django-tiny-wrapper/">TileStache Django tiny wrapper</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itopen.it/2012/01/05/polymaps-tilestache-and-svg-css-styling-issues/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>OpenStreeetMap and OpenCycleMap extent bookmarklet</title>
		<link>http://www.itopen.it/2011/11/24/openstreeetmap-and-opencyclemap-extent-bookmarklet/</link>
		<comments>http://www.itopen.it/2011/11/24/openstreeetmap-and-opencyclemap-extent-bookmarklet/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 13:42:40 +0000</pubDate>
		<dc:creator>Alessandro Pasotti</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.itopen.it/?p=636</guid>
		<description><![CDATA[Today I wrote a simple bookmarklet to get the map extent in EPSG:4326 from the wonderful OpenCycleMaps.org website. It also works on the OpenStreetMap.org website. You can just right-click and save it on your bookmarks, the click on the bookmark while in the OpenCycleMap site and a popup will appear with the extent coordinates printed [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-637" title="map_extent_bookmarklet" src="http://www.itopen.it/wp-content/uploads/2011/11/map_extent_bookmarklet.png" alt="" width="321" height="133" />Today I wrote a simple bookmarklet to get the map extent in EPSG:4326 from the wonderful <a title="Open Cycle Maps Website" href="http://www.opencyclemap.org">OpenCycleMaps.org</a> website. It also works on the OpenStreetMap.org website.</p>
<p>You can just right-click and save it on your bookmarks, the click on the bookmark while in the OpenCycleMap site and a popup will appear with the extent coordinates printed on screen.</p>
<p><a title="MapExtent" href="javascript:b=map.getExtent().transform(map.getProjectionObject(),%20new%20OpenLayers.Projection('EPSG:4326'));alert('Extent:%20'+b.left+'%20'+b.bottom+'%20'+b.right+'%20'+b.top);">Bookmarklet</a>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itopen.it/2011/11/24/openstreeetmap-and-opencyclemap-extent-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GeoExt debug build</title>
		<link>http://www.itopen.it/2011/11/08/geoext-debug-build/</link>
		<comments>http://www.itopen.it/2011/11/08/geoext-debug-build/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 18:26:02 +0000</pubDate>
		<dc:creator>Alessandro Pasotti</dc:creator>
				<category><![CDATA[GeoExt]]></category>
		<category><![CDATA[GIS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.itopen.it/?p=630</guid>
		<description><![CDATA[How to build an uncompressed debug version of GeoExt.]]></description>
			<content:encoded><![CDATA[<p>After struggling for a while with a nasty bug in my<a title="GeoExt website" href="http://geoext.org/" target="_blank"> GeoExt</a>-based code, I&#8217;ve managed to build an uncompressed version.</p>
<p>Strangely enough there is no way to download an uncompressed version from the project website, even if they provide a nice custom build form.</p>
<p>The recommended way is to use &#8220;<a title="JsBuild website" href="http://jsbuild.kodfabrik.com/" target="_blank">jsbuild</a>&#8220;, which turned to be a nightmare because it does not run out-of-the-box, at least on my Ubuntu lucid.</p>
<p>A one-liner did the trick, run it from a &#8220;build&#8221; folder under GeoExt main folder, the correct order of inclusion (which does really matter) is taken from the &#8220;single&#8221; file GeoExt.js.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> f <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">'&quot;GeoExt/'</span> ..<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>GeoExt.js<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/&quot;//g'</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/,//g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> ; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #ff0000;">&quot;../lib/<span style="color: #007800;">$f</span>&quot;</span> ; <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&gt;</span> GeoExt-debug.js</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.itopen.it/2011/11/08/geoext-debug-build/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Right click map control in OpenLayers</title>
		<link>http://www.itopen.it/2011/01/11/right-click-map-control-in-openlayers/</link>
		<comments>http://www.itopen.it/2011/01/11/right-click-map-control-in-openlayers/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 12:39:59 +0000</pubDate>
		<dc:creator>Alessandro Pasotti</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.itopen.it/?p=493</guid>
		<description><![CDATA[Thanks to a post in Spatial Notes Blog I&#8217;ve finally found a cross-browser way to handle right click on an OL map, I&#8217;ve been using an homebrew solution only to discover how it did not work correctly in MSIE. The proposed solution involves a custom control subclass and the standard OL machinery, the MSIE oddities [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to a post in <a href="http://spatialnotes.blogspot.com/2010/11/capturing-right-click-events-in.html">Spatial Notes Blog</a> I&#8217;ve finally found a cross-browser way to handle right click on an OL map, I&#8217;ve been using an homebrew solution only to discover how it did not work correctly in MSIE.</p>
<p>The proposed solution involves a custom control subclass and the standard OL machinery, the MSIE oddities are handled internally by OL itself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itopen.it/2011/01/11/right-click-map-control-in-openlayers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>P.mapper JS compression</title>
		<link>http://www.itopen.it/2007/10/23/compressione-js-in-pmapper/</link>
		<comments>http://www.itopen.it/2007/10/23/compressione-js-in-pmapper/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 16:50:20 +0000</pubDate>
		<dc:creator>Alessandro Pasotti</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[WebGis]]></category>

		<guid isPermaLink="false">http://www.itopen.it/2007/10/23/compressione-js-in-pmapper/</guid>
		<description><![CDATA[

This short note describe a technique to compress JavaScript files in p.mapper WebGIS.
Compressing JS files can speed significantly up loading times in this popular WebGIS client application.
]]></description>
			<content:encoded><![CDATA[<p>I would like to share some thought about p.mapper loading time, I feel that<br />
having many uncompressed js files push up loading time significantly due to<br />
two main reasons:</p>
<ol>
<li>file size (188KB uncompressed)</li>
<li>number of requests</li>
</ol>
<p>Point 2 is browser dependant but AFAIK most browsers typically can handle no<br />
more than 2 (IE) http requests simultaneously.</p>
<p>I&#8217;ve come up with a solution that I&#8217;m using in many projects (mainly ajax) and<br />
tests in pmapper give good results.</p>
<p>This is what I&#8217;ve done:</p>
<p><code lang="bash"><br />
cd javascript<br />
for i in $(ls *.js); do mv $i $i.src; done<br />
for i in $(ls *.js.src); do jsjavacompress.sh $i >> pm.js ; done<br />
</code></p>
<p>This produces a single 95KB pm.js file that is loaded at startup.<br />
additionally gzip gives a 27KB file.</p>
<p>So we can go from 20 files 188KB to one file 27KB compressed and gzipped.</p>
<p><code lang="bash"><br />
cat jsjavacompress.sh<br />
java -jar custom_rhino.jar -c $1 2>&#038;1<br />
</code></p>
<p>You can download custom_rhino.jar from<br />
<a href="http://trac.dojotoolkit.org/browser/trunk/buildscripts/lib/custom_rhino.jar?rev=5877&amp;format=raw">here</a></p>
<p>The same could be done in jquery directory.</p>
<p>Some measurements on javascript/ :</p>
<p>uncompressed: 179 KB, 19 files<br />
compressed with jsjavacompress.sh: 85 KB, 1 file (24 KB gzipped)<br />
compressed with compress_js.php (without licences): 91 KB, 1 file (24 KB gzipped)<br />
compressed with jsmin.php : 91 KB, 1 file (24 KB gzipped)<br />
compressed with jspack.php : 69 KB, 1 file (28 KB gzipped)</p>
<p>References:<br />
jsmin: PHP adaptation of JSMin, published by Douglas Crockford as jsmin.c, also based on its Java translation by John Reilly.<br />
jspack: This is the php version of the Dean Edwards JavaScript &#8216;s Packer</p>
<p>So jspack appears the most efficient so far but only when gzip compression is not enabled, all other soutions are equivalent and are slightly smaller when gzipped.</p>
<p>The only real advantage I see in the java solution is that it is a &#8220;semantic&#8221; parser since it uses a real javascript engine (RHINO) and hence it does always produce valid js code. The same is not true for the other solutions, if we have a missing &#8220;;&#8221; or other oddiness in source js code, they will produce invalid code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.itopen.it/2007/10/23/compressione-js-in-pmapper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A DHTML form builder based on jQuery</title>
		<link>http://www.itopen.it/2007/08/27/un-form-builder-dhtml-basato-su-jquery/</link>
		<comments>http://www.itopen.it/2007/08/27/un-form-builder-dhtml-basato-su-jquery/#comments</comments>
		<pubDate>Mon, 27 Aug 2007 15:39:33 +0000</pubDate>
		<dc:creator>Alessandro Pasotti</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programmazione]]></category>

		<guid isPermaLink="false">http://www.itopen.it/2007/08/27/un-form-builder-dhtml-basato-su-jquery/</guid>
		<description><![CDATA[
Still in the process of learning jQuery, I'm writing a DHTML form builder, the target audience is non experienced users that should be able to build simple forms that will be used by another application.



]]></description>
			<content:encoded><![CDATA[<p><a style="float:right" href='http://www.itopen.it/wp-content/uploads/2007/08/formbuilder.png' title='FormBuilder example'><img src='http://www.itopen.it/wp-content/uploads/2007/08/formbuilder.thumbnail.png' alt='FormBuilder example' /></a></p>
<p>
This form builder is based on several jQuery plugins, and has the following features:</p>
<ul>
<li>validation support</li>
<li>preview</li>
<li>in-place editing of labels and descriptions</li>
<li>support for text fields, text area, select, checkboxes and radio buttons</li>
<li>internationalisation support (currently it and en languages are supported)</li>
</ul>
<p>
Persistance of the generated form is left to the programmer, in my final application, the XHTML code will be sent to the server through an ajax call.
</p>
<p>An interesting review of similar softwares is avaliable at <a href="http://ajaxian.com/archives/attack-of-the-ajax-form-builders/trackback/">Ajaxian</a>
</p>
<p>
You can give it a shot at the following address:
</p>
<p><a href="http://elpaso.homelinux.org/formbuilder">http://elpaso.homelinux.org/formbuilder</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itopen.it/2007/08/27/un-form-builder-dhtml-basato-su-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A super-simple JavaScript templating system</title>
		<link>http://www.itopen.it/2007/08/24/un-semplicissimo-sistema-di-template-in-javascripta-super-simple-javascript-templating-system/</link>
		<comments>http://www.itopen.it/2007/08/24/un-semplicissimo-sistema-di-template-in-javascripta-super-simple-javascript-templating-system/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 15:22:47 +0000</pubDate>
		<dc:creator>Alessandro Pasotti</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programmazione]]></category>

		<guid isPermaLink="false">http://www.itopen.it/2007/08/24/un-semplicissimo-sistema-di-template-in-javascripta-super-simple-javascript-templating-system/</guid>
		<description><![CDATA[


Moving from prototype framework to jQuery, I missed the nice templating engine that was available as a prototype plugin. After some testing with the templating plugins for jQuery, I wrote this few lines to have a super-simple templating system readily available.
]]></description>
			<content:encoded><![CDATA[<p><code lang="javascript"><br />
/**<br />
* Simple template system<br />
* Usage:<br />
* var t = new Template('
<div id="div_{id}" class="{class}"></div>
<p>');<br />
* var html = t.run({id : 'div_one', class : 'my_class'});<br />
*/<br />
Template = function(tpl){<br />
    this.tpl = tpl;<br />
    this.tokens = [];<br />
    this.is_compiled = false;<br />
    this.compile = function(){<br />
        var re = /\{(\w+)\}/g;<br />
        var tok;<br />
        while((tok = re.exec(this.tpl)) != null) {<br />
            this.tokens.push(tok[1]);<br />
        }<br />
        this.is_compiled = true;<br />
    }<br />
    this.run = function(json){<br />
        if(!this.is_compiled){<br />
            this.compile();<br />
        }<br />
        if(json){<br />
            for (var jk = 0; jk < this.tokens.length; jk++){<br />
                var pattern = new RegExp('\{' + this.tokens[jk] + '\}', 'g');<br />
                this.tpl = this.tpl.replace(pattern, json[this.tokens[jk]]);<br />
            }<br />
        }<br />
        return this.tpl;<br />
    }<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.itopen.it/2007/08/24/un-semplicissimo-sistema-di-template-in-javascripta-super-simple-javascript-templating-system/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

