Mittwoch, 9. März 2011

OpenLayers: Hover & Popup Example

So ive been struggling to get this feature working. Through hard research (reading 5 lines of code) i managed to implement the function without the hassel all the internet smack is talkin bout. So feel free to use this in your project and if you got here by looking into google, leave a comment or a beer coupon or whatever :) because im releasing this under the beerware license.

<code><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>HoverFeature for Highlight - SelectFeature for Popup</title>
    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
    <link rel="stylesheet" href="style.css" type="text/css" />
    <style type="text/css">
        #controlToggle li {
            list-style: none;
        }
    </style>
    <script src="../lib/Firebug/firebug.js"></script>
    <script src="../lib/OpenLayers.js"></script>

    <script type="text/javascript">
    var selectCtrl;
  
    function onPopupClose(evt) {
            selectCtrl.unselect(selectedFeature);
        }
        function onFeatureSelect(feature) {
            selectedFeature = feature;
            popup = new OpenLayers.Popup.FramedCloud("chicken",
                                     feature.geometry.getBounds().getCenterLonLat(),
                                     null,
                                     "<div style='font-size:.8em'>Feature: " + feature.id +"<br />Area: " + feature.geometry.getArea()+"</div>",
                                     null, true, onPopupClose);
            feature.popup = popup;
            map.addPopup(popup);
        }
        function onFeatureUnselect(feature) {
            map.removePopup(feature.popup);
            feature.popup.destroy();
            feature.popup = null;
        } 

        var map, controls;

        OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';

        function init(){
            map = new OpenLayers.Map('map');

            var vectors = new OpenLayers.Layer.Vector("vector", {isBaseLayer: true});
            map.addLayers([vectors]);

            var feature = new OpenLayers.Feature.Vector(
                OpenLayers.Geometry.fromWKT(
                    "POLYGON((28.828125 0.3515625, 132.1875 -13.0078125, -1.40625 -59.4140625, 28.828125 0.3515625))"
                )
            );
            vectors.addFeatures([feature]);

            var feature2 = new OpenLayers.Feature.Vector(
                OpenLayers.Geometry.fromWKT(
                    "POLYGON((-120.828125 -50.3515625, -80.1875 -80.0078125, -40.40625 -20.4140625, -120.828125 -50.3515625))"
                )
            );
            vectors.addFeatures([feature2]);

            var report = function(e) {
                OpenLayers.Console.log(e.type, e.feature.id);
            };
          
            var highlightCtrl = new OpenLayers.Control.SelectFeature(vectors, {
                hover: true,
                highlightOnly: true,
                renderIntent: "temporary",
                eventListeners: {
                    beforefeaturehighlighted: report,
                    featurehighlighted: report,
                    featureunhighlighted: report
                }
            });

            selectCtrl = new OpenLayers.Control.SelectFeature(vectors,
                {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect}
            );
          
            map.addControl(highlightCtrl);
            map.addControl(selectCtrl);
            highlightCtrl.activate();
            selectCtrl.activate();
            map.addControl(new OpenLayers.Control.EditingToolbar(vectors));
            map.setCenter(new OpenLayers.LonLat(0, 0), 1);
        }
    </script>
  </head>
  <body onload="init()">
    <h1 id="title">OpenLayers HoverFeature for Highlight - SelectFeature for Popup Example</h1>
    <p id="shortdesc">
      Activate popup on click, highlight features on hover.
    </p>
    <div id="map" class="smallmap"></div>
    <p>Select features by clicking on them. Just highlight features by hovering over
    them.</p>

  </body>
</html>
</code>

Mittwoch, 2. März 2011

youPad or iPad

Wie man hier lesen kann gehts heute um 19 Uhr los.
Alle Apple Fanboys könnens kaum erwarten.

WOOOOHOOOO.

Dienstag, 1. März 2011

IPAD 2

Das grosse Grauen hat ein ENDE.
Die schlimmste Zeit ist VORBEI.
Das Warten ist VORÜBER.

Ich weiss das es ziemlich Fanboyig klingt aber ich bin endlich an dem Punkt, wo ich mich einfach nur noch 100% komplett darüber freue das morgen der 2. März ist und das iPad 2 vorgestellt wird.

Bleiben nur noch 92384789324 Monate bis Apple das Teil dann auch wirklich auf den Markt wirft.

Andere Frage die ich mir stelle ist:

- lohnen sich die neuen Specs ??
Ich besitze ein iPhone und von daher ist der Drang mit dem iPad unbedingt ein Foto schiessen zu wollen eher gemässigt.

- hat man sogar einen preis/leistungs vorteil wenn man sich ein altes 1. Gen iPad kauft ?


Fragen über Fragen.
So. Ab Morgen gestalte ich diesen Blog mal richtig.

Take.

Montag, 21. Februar 2011

So i just came about this site buildlog.

The very cool thing about this site is that it made all my tinkering dreams come true.
I was thinking of building a reprap on das-labor.org 's cupcake cnc, but i thought that would be too easy so i wanted something better but didnt know what i should do.
So when i finally saw the possibility of the laser cutter i was mindblown.

The way I intend to build the "laser cutter" is this:

Its a 4 (!!! keep that in mind),
4-way Device

when im finished with it, it will:


- Laser cut
- 3D Print
- CNC
- CNC Scan


im going to put a blu-ray laser in it for the laser part.
reprap precision extruder, for the 3D Printer part.
a router(oberfräse) for the cnc.
and if you turn your head over to ... this Post ,

you can see that its not a matter of €€€ to create outstanding Projects in your home.

Donnerstag, 10. Februar 2011

upgrade...

im making get request like CUUUHRUUUHHHAAZZZZYYY !!!!

expect to be seeing the first eval. version e.g. alpha version of my new Arduino Software. Im currently at the state that im combining three layers off application control, i will implement access control, data logging und interactivity

and as you all know, this is only for the purpose of creating the interactive coffeetable im talkin about for the last 3 weeks.

ive gotta take a nap. gotta work morrow @ 11am :/

p33z 0ut.

Dienstag, 8. Februar 2011

Twitterific....

... i just retried sending a command through twitter again.

and finally it did not take 20minutes to get search query of the tweet.
which was kind of awkward anyway, how come you can display stuff from the db in 1sec but cant be able to index it, that doesnt make no damn sense.

so ill have to keep workin here @ my job, my boss wants me manually dissect a geospatial database :/

ill keep you up to date.

P.S.:

Oh and yeaah today im returning to @DasLabor to continue building my RepRap Prusa Mendel with a Makerbot Cupcake CNC sooo0o 1337.
Whew.

So im finally trying to get some sleep.

ive managed to make my arduino tweet. hooooray ;)
and now im in the process of coding a php parser which parses the result of a twitter api search for @twitduin0 on the whole twitter network , to gather all the commands that people are trying to send to the arduino.

unfortunately ive been sitting here for like 20minutes and the f*** search api wont index my new tweet. so i think i have to find a workaround for the time issue, i cant wait 20 mins to make my table switch colors. i want it fast , as fast as the speed of light, daaaaaaaaaamn.

so heres my little php code that i have. im just posting so i can read it at work tomorrow.errrrr.

twit.php
=========
getTweets();
foreach ($tweets as $tweet) {
echo '

' . $tweet['date'] . ' x ' . $tweet['time'] . ' x ' . $tweet['user'] . ' x ' . $tweet['command'] . ' x ' . $tweet['message'] . '

';
}
?>

libTwit.php
===========
doc = new DOMDocument();
$this->tweets = array();
if ($this->doc->load('http://search.twitter.com/search.atom?q=%40twitduin0&&rpp=1')) {
$i = 0;
foreach ($this->doc->getElementsByTagName('entry') as $node) {
$tweet = array(date => $this->getDate($node), time => $this->getTime($node), user => $this->getUser($node), command => $this->getCommand($node), message => $this->getMessage($node));
$this->tweets[$i] = $tweet;
//if ($i == 0) $this->userLink = $node->getElementsByTagName('link')->item(0)->nodeValue;
$i++;
}
}
}

private function getDate($node) {
$tweet = $node->getElementsByTagName('published')->item(0)->nodeValue;
$DATE_ARR = explode("T",$tweet);

return $DATE_ARR[0];
}

private function getTime($node) {
$tweet = $node->getElementsByTagName('published')->item(0)->nodeValue;
$TIME_ARR = explode("T",$tweet);

return $TIME_ARR[1];
}


private function getUser($node) {
$tweet = $node->getElementsByTagName('name')->item(0)->nodeValue;
$USER_ARR = explode(" ",$tweet);
return $USER_ARR[0];
}


private function getCommand($node) {
$tweet = $node->getElementsByTagName('title')->item(0)->nodeValue;
$CMD_ARR = explode(" ",$tweet);
return $CMD_ARR[1];
}

private function getMessage($node) {
$tweet = $node->getElementsByTagName('title')->item(0)->nodeValue;

$tweet = "@twitduin0 #led2 must turn on ;)";
$tweet = str_replace("@twitduin0", "", $tweet);
$tweet = explode(" ", $tweet);
$tweet = implode(",", $tweet); //back into a comma seperated string, so split off the first stuff...

//$res = count($tweet);

return $tweet;
}

public function getTweets() {
return $this->tweets;
}

public function getLink($msg) {
return '' . $msg . '';
}

}

?>

Montag, 7. Februar 2011

#! MAGIC

So i just came back from sitting around at work, to sitting around at home.

Without any delay, namely taking clothes off, trying to grab something to eat, i directly find myself tinkering with the Arduino again and if you point yourself to @Twitduin0 you will see that the first tweet got sent out ;)

I think until i have my fully applicable table ready to take commands and whatnot it'll take another month. So bear with me.

Sonntag, 6. Februar 2011

trial and error

... so my not so interesting life, just challenged me with inferior boredom and i couldnt help myself but to startup Sketch and tinker around with my Arduino. Ive had it laying around on my desk for like 2 weeks and havent done anything gorgeous with it, so i sad to myself: DUDE!!! DU something.

Voila!!

I present to you:

The Arduino LED Webserver control center, better known as ALWCC i.e. ALLWHACK.

im currently evaluating the thing so i will edit this post. im posting this only so i can come around later and look what kind of stuff i have realized or errrrr not so....