Archive for September, 2005

RDF Parser Updated

Wednesday, September 28th, 2005

I’ve made a couple of changes to the Javascript RDF-Parser, this was to include Opera and Safari support, based on a patch provided Gorm H Eriksen via Chaals. And to fix a couple of bugs found by Ian Dickinson related to xmlbase and some leaking of global variables.

At the same time I’ve updated the very limited documentation and included the owl:sameAs code I wrote some time ago which never made it into a “released” version, also the rdf:datatype and xml:lang support hadn’t previously been mentioned, so that’s documented too now.

If anyone is using it, good luck, and please let me know of bugs, I’ll gladly fix them!

The (current?) failure of local search

Tuesday, September 27th, 2005

There’s lots of talk, and lots of work in the search engine world about local search, I’m sure the reason is to get more advertisers - there’s only so many people who it’s relevant for to advertise globally, or even nationally, local shops for local people however would pay for local adverts.

I wanted to find a bike shop in Kingston, so I could find one that’s likely to have a tourer as I’m thinking hard of cycling longer distances to get rid of the current fat belly (very old readers may remember me running 20:19 in the club handicap a few years back, 28:05 was my this month fat time).

One of things I knew was there was Evans cycles near the station, and there’s one just down the road from me in surbiton - a few miles from Kingston. Google local was my first choice as they put it on the map which is great. First there’s a search for Bike shop and Kingston. First up, google offers me 2 Kingston’s to disambiguate - good, but I’ve searched for stuff in Kingston before, it really should remember which Kingston I’m near, at least give me the results for upon Thames, and give a link “did you mean Kingston upon Hull” if I’ve just asked 5 minutes ago.

Telling it Kingston upon Thames I get some results. The nearest result is Action Bikes - 3.8 miles away from Kingston in Richmond, the furthest is 13 miles away in Harrow or Lewisham - neither of the two bike shops I actually know about are listed at all - this is the big failure of local search - people know their local area, they know if there’s results missing, with a web search it doesn’t matter, I’ve no idea what resources the search engine hasn’t found, but with local search I know what’s missing and I’ll get annoyed.

Yahoo doesn’t have something called a local search, but it does have a business finder which does the same job. So bike shop in kingston returns no results at all, but a suggestion to try more general words, and bike in kingston turns up a big list mostly linked to motorbikes, however there’s one on the first page and it has a link to a category cycle shops clicking on that I get a list of 4 in Kingston, no way to enlarge the area though, and it doesn’t mention the ones just outside Kingston. It also took 4 pages and thought of my search terms, much too much effort on a smartphone, and too much effort even in the office.

MSN search was just crazy bike shop in kingston tells me that “kingston” was not recognized. Please be more specific changing kingston to anything fromKingston upon Thames to Surrey or London didn’t get me anywhere at all, I always got the same message - I couldn’t find any location that it actually worked for!

The providers of business information to google and yahoo are Yell and ThomsonLocal. Yell performed the search without any problems, both guiding me through the process of narrowing down what I wanted to cycle shops, and returning me a list in Kingston and a wider area. Thomson Local however fail to map bike shop to anything about bikes, somehow suggesting I might want shop fittings, if I deliberately choose cycle shops (what I’ve learnt they want them called) then it finds them no problem.

Local search appears to have a very long way to go, and will always suffer the problem of being different to what the local person knows of their locality - if you know the chip shop has closed, you’ll be annoyed if it appears on the map, if you know the best chip shop is on the high street and there’s nothing there on the search you’ll doubt all the results. I can’t see local search being a useful feature to me, they have a very long way to go, if you have to use one though, yahoo is the way to go, even though they still haven’t bothered with a background colour.

Using SVG for paths in Google Maps with Deer Park

Wednesday, September 7th, 2005

The Google Maps API uses VML in Internet Explorer for drawing polylines over the top of the map - for directions etc. In the other supported browsers though, it renders transparent pngs on the server, so a higher bandwidth load, and not so neat for the user. SVG shares a lot in common with VML, so I decided to see if I could hack SVG support into the Google Maps API code in the SVG Enabled Deer Park.

It was surprisingly easy, the google maps API is all in one large function and relies on a closure so modification of the functions requires you to rewrite that function. That’s simple get the source code of the string by converting the function ref to a string: GMapsNamespace+'' then you can use regular expressions to change the code.

Adding SVG support requires only 2 changes:

  • From this.createImageSegments to this.createSVGVectorSegments this was simply to make the Mozilla path call a new function, and be slightly more robust to changes than trying to replace the entire createImageSegments function.
  • Inserted a function before G.prototype.createVectorSegments that is my new createSVGVectorSegments function.
  • These changes only happen if window.SVGElement exists, which is a current way of testing for SVG support in Mozilla, it may not be future proof when Opera and Safari get scripted SVG support (Opera currently throws a strange script error stopping rendering but the nodes are added to the DOM).

The createSVGVectorSegments function:

G.prototype.createSVGVectorSegments=function(a,b,c){ var d=this.getVectors(a,b); var e=new Array(); var f=new D(); this.getBitmapVectors(d,e,f); if(!c){ c=new D(); } var g=D.intersection(c,f); var h; if(e.length>0){ var i=this.map.centerBitmap; var n=1; var v=1;

This is all the same as the VML version, it just gets the vectors from the polyline and does some initialisation work.

 h=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\"); var path=document.createElementNS(\"http://www.w3.org/2000/svg\",\"path\"); h.appendChild(path); h.style.position=\"absolute\"; h.style.width=\"100px\"; h.style.height=\"100px\";

This creates the svg element and a path element that will be the actual polyline, note the importance of using createElementNS and the SVG namespace -http://www.w3.org/2000/svg.

   var vpath=this.getVectorPath(e).toUpperCase().replace(\"E\",\"\"); arr=vpath.split(/[ML,\s]+/gim);arr=arr.splice(1,arr.length-2); var aminX=arr[0];var aminY=arr[1]; for (var zzz=2;zzz<arr.length;zzz+=2) { if (arr[zzz]<aminX) aminX=arr[zzz]; if (arr[zzz+1]<aminY) aminY=arr[zzz+1]; } outstr=\"M\"+(Number(arr[0])-aminX)+\",\"+(Number(arr[1])-aminY)+\"L\"; for (var zzz=2;zzz<arr.length;zzz+=2) {; outstr+=(Number(arr[zzz])-aminX)+\",\"+(Number(arr[zzz+1])-aminY)+\" \"; } var k=this.map.getDivCoordinate(aminX,aminY,sb); h.style.left=l(k.x); h.style.top=l(k.y);

This converts the VML path into an SVG one, and rescales it to be in a coordinate space near 0, I had to do this because of a bug in deer park where it clips to the initial viewport even if overflow is set to visible, so just translating the coordinates with a translate to bring it back to 0 didn’t work. It’s quite simple, simply loop through the path moving it by the offset of the smallest coordinate in the string. The getDivCoordinate is a Google function which converts the google world coordinates into screen px coordinates, so allows us to position the path in the right place.

 path.setAttributeNS(null,\"d\",outstr); path.setAttributeNS(null,\"opacity\",this.opacity); path.setAttributeNS(null,\"stroke\",this.color); path.setAttributeNS(null,\"fill\",\"none\"); path.setAttributeNS(null,\"stroke-weight\",l(this.weight)); } return h;}

This is just to set the last few properties on the path - this is exact same as in the VML.

And that’s it, that’s all you need to do to make your Google Maps API use SVG for polylines rather than crappy old pngs, hopefully google will soon integrate the code themselves as Deer Park moves towards release, but until then, or at least until google doesn’t break the hack somehow - which is of course extremely easy for it to do. If you want to try it out for yourself, just include the code before you call the new GMap( ... to initialise the google map.

You can also see it in action in my Exmouth to Seaton Cycle ride tracklog demo., which was what got me interested in the Google Maps API, and will be writing more on shortly…

Friendster spams and lies

Tuesday, September 6th, 2005

Today, I got some friendster spam, bad friendster, but not surprising social networking sites like sending spam, so I visited their privacy policy which stated that they were a licensee of the TRUSTe Privacy Program. Unfortunately this appears to be a lie, the TRUSTe people are quite confident that friendster is not a member. It appears that not only are friendster quite willing to send spam, they’re also only pretending to be members of a privacy watchdog, you can check yourself at https://www.truste.org/ivalidate.php?url=www.friendster.com.

This would be very worrying, if friendster didn’t only have information on me that is freely available in a hundred FOAF resources, but if you’ve got actual data in there, do you really want to be storing it somewhere that lies on their privacy policy? I guess I’ll just have to kill the email address friendster have on me to stop the spam…