Howto: Automatically create point hotspots from polygonal hotspots for krpanojs

  • I have used polygonal hotspots for my real estate tours. Since krpanojs does not support polygonal hotspots I wanted to automatically create point hotspots when a tour is viewed on iPad/iPhone.

    From the formula described in this wikipedia article, I was able to write a function to calculate the centroid (center of mass) of a polygon and use that point for iPad/iPhone.

    I wrote it in Python using language features that are not common among most programming languages, so I won't post it here because I would have to explain Python before explaining the function. The formula isn't very difficult though, so an average programmer should be able to easily complete it in under an hour.

    The formula is meant for two-dimensional polygons, but seems to work well for krpano pan/tilt polygons. It works across the horizon and at the 0º meridian, but you need to make a few adjustments for the -180º/180º meridian. Also, polygons covering the poles (at tilt -90º/90º), may not be accurate, but it is not likely to have a polygon covering a pole so I did not handle this case.

  • Ah, thanks. I haven't been on the forums much since May when I got a new job, so I've been missing out on some of the better threads.

    Coming back to the forums recently, I was very impressed with pinsane taking the time to thoroughly document variables, parameters, and expansion in krpano. I've struggled through those issues myself and more or less drew the same conclusions, but it is very nice to see it methodically examined and documented.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!